PostgreSQL La base de donnees la plus sophistiquee au monde.

Forums PostgreSQL.fr

Le forum officiel de la communauté francophone de PostgreSQL

Vous n'êtes pas identifié(e).

#1 Re : Java » JDBC 3 et postgres » 05/06/2009 17:53:04

Pour info, je suis dans le cadre d'une migration Oracle 9i -> PostgreSQL 8.3.

Sous Oracle avec le driver ojdbc14.jar :

Dans une requête, je recupére un champ de type NUMBER(10,0) qui est null (ce champ est non nullable dans sa table mais j'utilise une jointure externe, j'ai donc des correspondances avec la valeur null).
Via jdbc, je récupère bien null.


Sous PostgreSQL avec le driver postgresql-8.3-604.jdbc3.jar :

Je récupère la valeur 0, ce qui ne me convient pas puisque mes tests java sont basés sur la nullité ou non etc etc.


Je voulais donc savoir d'une part si ce comportement était normal et d'autre part s'il était possible de paramétrer ce comportement, au niveau de la base ? du driver ? ailleurs ? En effet, idéalement, j'aimerais ne pas modifier le code java.

Merci à vous.

#2 Re : Migration » Migration Vues Oracle avec jointures externes. » 04/06/2009 14:45:06

C'est bon, c'est bien ça.

Ce n'est pas encore tout à fait clair, mais c'est déjà mieux, à pratiquer encore.

Merci !

#3 Re : Migration » Migration Vues Oracle avec jointures externes. » 03/06/2009 15:33:53

Vraiment merci Flo, tu m'as permis d'avancer et de convertir un certain nombres de requêtes, tout fonctionne bien, je coince cependant sur celle-ci et donc, je sollicite à nouveau votre aide (je n'ai pas encore tout saisi...mais j'ai bon espoir...)


J'ai ceci

SELECT p_entity.ENTITY_INCDE,ENTITY_DSC,RESULT_INCDE,ENTITY_GO_INCDE,DOC_AUTHOR,RESULT_REAL_DTE,RESULT_TYPE_INCDE,REF_EXCDE 
             FROM p_resultat,r_resultat_type rr, p_entity, r_go, a_entity_document aed, p_document doc
             WHERE p_entity.entity_incde = p_resultat.result_incde
             AND p_entity.entity_go_incde = r_go.go_incde
             AND p_entity.entity_status_incde = 4 
             AND p_entity.entity_sec_lvl = 0
             AND p_entity.entity_incde =  aed.ENTITY_INCDE(+)
             AND p_resultat.RESULT_TYPE_INCDE =  rr.REF_INCDE(+)
             AND aed.DOC_INCDE = doc.DOC_INCDE (+) 
             ORDER BY p_entity.ENTITY_INCDE DESC

et j'ai commencé à écrire ceci, il reste une jointure à faire mais je ne vois pas bien comment faire :

SELECT p_entity.ENTITY_INCDE,ENTITY_DSC,RESULT_INCDE,ENTITY_GO_INCDE,DOC_AUTHOR,RESULT_REAL_DTE,RESULT_TYPE_INCDE,REF_EXCDE 
             FROM r_go,
             p_entity INNER JOIN p_resultat LEFT OUTER JOIN r_resultat_type
             ON (p_resultat.RESULT_TYPE_INCDE =  r_resultat_type.REF_INCDE)
             ON (p_entity.entity_incde = p_resultat.result_incde),
             a_entity_document LEFT OUTER JOIN p_document ON (a_entity_document.DOC_INCDE = p_document.DOC_INCDE)
             
             WHERE p_entity.entity_go_incde = r_go.go_incde
             AND p_entity.entity_status_incde = 4 
             AND p_entity.entity_sec_lvl = 0
             and p_entity.entity_incde =  a_entity_document.ENTITY_INCDE(+)
             
			 ORDER BY p_entity.ENTITY_INCDE DESC

désolé et encore merci, je continue à investiguer...

#4 Re : Migration » Migration Vues Oracle avec jointures externes. » 01/06/2009 15:03:34

Je reviens à la charge car j'ai un petit souci.

La transformation de cette requête (Oracle 9i) :

SELECT  AAP_INCDE, AAP_CLOS_MODE, AAP_CLOS_DTE,  AAP_CLOS_TIM, AAP_CTC_1, AAP_CTC_2,  AAP_CTC_3, AAP_CTC_4, AAP_CTC_5,
AAP_CTC_EMAIL_1, AAP_CTC_EMAIL_2, AAP_CTC_EMAIL_3,   AAP_CTC_EMAIL_4, AAP_CTC_EMAIL_5, AAP_SEND_1,
AAP_SEND_2, AAP_SEND_EMAIL_1, AAP_SEND_EMAIL_2,    AAP_SEND_ADRESS, p_entity.ENTITY_INCDE, ENTITY_EXCDE, ENTITY_DSC,
ENTITY_TYPE_INCDE, ENTITY_CRT_INCDE, ENTITY_CRT_DTE,   ENTITY_MDF_INCDE, ENTITY_MDF_DTE, ENTITY_PUB_INCDE,
ENTITY_PUB_DTE, ENTITY_SEC_LVL, ENTITY_STATUS_INCDE,    ENTITY_VERSION, ENTITY_GO_INCDE, ENTITY_ROOT_INCDE,
ENTITY_SUMMARY, ENTITY_DATA_1, ENTITY_DATA_2,    ENTITY_DATA_3, ENTITY_DATA_4, ENTITY_DATA_5,    ENTITY_FNC_INCDE
FROM p_entity, a_theme_go, p_aap, a_entity_go
where p_aap.aap_incde = p_entity.entity_incde 
and p_entity.entity_status_incde = CAST(3 as integer)
and	 p_entity.entity_incde = a_entity_go.ENTITY_INCDE(+)
and a_entity_go.GO_INCDE = a_theme_go.go_incde(+)
and a_theme_go.theme_incde  =  CAST(2 as integer)

en cette requête (syntaxe standard - destination PostgreSQL 8.3):

SELECT  AAP_INCDE, AAP_CLOS_MODE, AAP_CLOS_DTE,  AAP_CLOS_TIM, AAP_CTC_1, AAP_CTC_2,  AAP_CTC_3, AAP_CTC_4, AAP_CTC_5,
AAP_CTC_EMAIL_1, AAP_CTC_EMAIL_2, AAP_CTC_EMAIL_3,   AAP_CTC_EMAIL_4, AAP_CTC_EMAIL_5, AAP_SEND_1,
AAP_SEND_2, AAP_SEND_EMAIL_1, AAP_SEND_EMAIL_2,    AAP_SEND_ADRESS, p_entity.ENTITY_INCDE, ENTITY_EXCDE, ENTITY_DSC,
ENTITY_TYPE_INCDE, ENTITY_CRT_INCDE, ENTITY_CRT_DTE,   ENTITY_MDF_INCDE, ENTITY_MDF_DTE, ENTITY_PUB_INCDE,
ENTITY_PUB_DTE, ENTITY_SEC_LVL, ENTITY_STATUS_INCDE,    ENTITY_VERSION, ENTITY_GO_INCDE, ENTITY_ROOT_INCDE,
ENTITY_SUMMARY, ENTITY_DATA_1, ENTITY_DATA_2,    ENTITY_DATA_3, ENTITY_DATA_4, ENTITY_DATA_5,    ENTITY_FNC_INCDE
FROM p_aap,
p_entity left join a_entity_go on (p_entity.entity_incde = a_entity_go.ENTITY_INCDE),
a_entity_go left join a_theme_go  on (a_entity_go.GO_INCDE = a_theme_go.go_incde)
where p_aap.aap_incde = p_entity.entity_incde 
and p_entity.entity_status_incde = CAST(3 as integer)
and a_theme_go.theme_incde  =  CAST(2 as integer)

ne renvoit pas le même résultat (plein de lignes identiques dans la 2ème)

Je ne vois pas ou est mon erreur (surement une jointure mal faite puisque plein de doublons mais où...), si vous avez un tuyau, merci.

#5 Re : Général » Appeler différents scripts sql dans un fichier sql » 28/05/2009 13:47:01

Non, ça ne fonctionne pas.

Il doit bien y avoir un moyen, je cherche en effet à automatiser l'insertion de mes données, sachant que j'ai un fichier par table, je voulais rassembler les appels dans un seul afin de pouvoir tout insérer via un seul fichier...

#6 Re : Général » serveur ne demarre plus » 28/05/2009 10:33:10

Tu peux peut être faire une sauvegarde tes bases et fait une réinstallation ?

#7 Général » Appeler différents scripts sql dans un fichier sql » 28/05/2009 10:30:05

djalouk
Réponses : 4

Je cherche à appeler des scripts sql dans un seul, je pensais pouvoir faire :

@mon_script1.sql
@mon_script2.sql
...

visiblement ça ne fonctionne pas sous pgadmin.

Des idées ?

#8 Re : Migration » Migration Vues Oracle avec jointures externes. » 22/05/2009 14:22:38

Oui c'est mieux en effet wink

Pour info, cela fonctionne très bien, la syntaxe de flo est la bonne, la requête est d'ailleurs beaucoup plus rapide avec la syntaxe LEFT OUTER JOIN à la place de (+).

Merci à tous !

#9 Re : Migration » Migration Vues Oracle avec jointures externes. » 20/05/2009 18:08:52

Comme je vous sens chauds, j'essaie également de transformer ce SELECT :

select
          t_fnc_principal.entity_incde as entity_incde,
          t_fnc_principal.entity_excde as entity_excde,
          t_fnc_principal.entity_dsc as entity_dsc,
          t_fnc_principal.entity_summary as entity_summary,
          t_fnc_principal.entity_data_5 as entity_data_5,
          t_fnc_principal.acro as  acro,
          t_fnc_principal.proj_prj_titre as proj_prj_titre, 
          t_fnc_principal.proj_obj_fin_porteur_projet as proj_obj_fin_projet,
          t_fnc_principal.proj_pos_exist_projet as proj_pos_exist_projet,
          t_fnc_principal.proj_methode_oeuvre as proj_methode_oeuvre,
          t_fnc_principal.proj_apport_result as proj_apport_result,
          t_fnc_principal.proj_mode_val as proj_mode_val,
          t_fnc_principal.proj_nom_syn as proj_nom_syn,
          t_fnc_principal.entity_data_4 as entity_data_4,
          t_fnc_principal.entity_type_incde as entity_type_incde,
          t_fnc_principal.entity_crt_dte as entity_crt_dte,
          t_fnc_principal.entity_sec_lvl as entity_sec_lvl,
          t_fnc_principal.entity_status_incde as entity_status_incde,
          t_fnc_principal.entity_version as entity_version,
          t_fnc_principal.entity_go_incde as entity_go_incde,
          t_go_secondaire.go_secondaire as go_secondaire,
          t_financeur.ref_dsc as ref_dsc
          from
                (select entity_incde, entity_excde, entity_dsc, entity_summary,
                    entity_data_5, 
                    pp.proj_prj_acro as acro, 
                    pp.proj_prj_titre as proj_prj_titre, 
                    pp.proj_obj_fin_porteur_projet ,
                    pp.proj_pos_exist_projet ,
                    pp.proj_methode_oeuvre ,
                    pp.proj_apport_result ,
                    pp.proj_mode_val ,
                    pp.proj_nom_syn ,
                    entity_data_4,
           	        entity_type_incde, entity_crt_dte, entity_sec_lvl,
                    entity_status_incde, entity_version, entity_go_incde
                from   p_entity pe, p_projet pp
                where  pe.entity_incde = pp.proj_incde) t_fnc_principal ,
                (select p.entity_incde, a.go_incde as go_secondaire
                from   p_entity p, a_entity_go a
                where  a.entity_incde = p.entity_incde) t_go_secondaire, p_entity t_entity, 
                (select  ref_incde, ref_dsc from a_bo_financement, r_financeur
                     where fin_finceur_incde(+) = ref_incde ) t_financeur
   
   
   
   where t_fnc_principal.entity_incde(+) = t_entity.entity_incde
   and   t_go_secondaire.entity_incde(+) = t_entity.entity_incde
   and   t_financeur.ref_incde (+)       = t_entity.entity_incde 
   and  t_entity.entity_status_incde!=12
   and  t_entity.entity_status_incde!=14
   and  t_entity.entity_status_incde!=13

Merci !

#10 Re : Migration » Migration Vues Oracle avec jointures externes. » 20/05/2009 15:31:12

Voici la vue obtenue :

CREATE VIEW "v_pe" ("entity_data_5", "entity_fnc_incde", "usr_fnc_principal", "usr_fnc_secondaire", "usr_go_principal", "usr_go_secondaire", "go_secondaire", "fnc_secondaire", "go_principal", "fnc_principal", "bo_usr_excde", "entity_incde", "entity_excde", "entity_dsc", "entity_type_incde", "entity_crt_incde", "entity_crt_dte", "entity_mdf_incde", "entity_mdf_dte", "entity_pub_incde", "entity_pub_dte", "entity_sec_lvl", "entity_status_incde", "entity_version", "entity_go_incde", "entity_root_incde", "entity_summary", "entity_data_1", "entity_data_2", "entity_data_3", "entity_data_4") AS (select t_fnc_principal.usr_incde as usr_fnc_principal,
           t_fnc_secondaire.usr_incde as usr_fnc_secondaire,
           t_go_principal.usr_incde as usr_go_principal,
           t_go_secondaire.usr_incde as usr_go_secondaire,
           t_go_secondaire.go_secondaire as go_secondaire,
           t_fnc_secondaire.fnc_secondaire, t_go_principal.go_principal,
           t_fnc_principal.fnc_principal,  t_bo_usr.usr_excde as bo_usr_excde, t_entity.*
      from (select entity_incde, entity_go_incde as go_principal, usr_incde
              from p_entity, a_bo_usr_go
             where entity_go_incde = go_incde) t_go_principal,
           (select entity_incde, entity_fnc_incde as fnc_principal, usr_incde
              from p_entity, p_bo_usr
             where entity_fnc_incde = usr_fnc_incde) t_fnc_principal,
           (select p.entity_incde, fnc_incde as fnc_secondaire, usr_incde
              from p_entity p, a_entity_fnc a, p_bo_usr
             where a.entity_incde = p.entity_incde
               and fnc_incde = usr_fnc_incde) t_fnc_secondaire,
           (select p.entity_incde, a.go_incde as go_secondaire, usr_incde
              from p_entity p, a_entity_go a, a_bo_usr_go abug
             where a.entity_incde = p.entity_incde
               and a.go_incde = abug.go_incde) t_go_secondaire,
           p_entity t_entity, p_bo_usr t_bo_usr,
	   t_fnc_principal LEFT OUTER JOIN t_entity on ( t_fnc_principal.entity_incde = t_entity.entity_incde ),
	   t_go_principal LEFT OUTER JOIN t_entity on ( t_go_principal.entity_incde = t_entity.entity_incde ),
	   t_fnc_secondaire LEFT OUTER JOIN t_entity on ( t_fnc_secondaire.entity_incde = t_entity.entity_incde ),
	   t_go_secondaire LEFT OUTER JOIN t_entity on ( t_go_secondaire.entity_incde = t_entity.entity_incde ),
	   t_bo_usr LEFT OUTER JOIN t_entity on ( t_bo_usr.usr_incde = t_entity.entity_crt_incde )
);

J'ai maintenant l'erreur suivante :
ERROR: relation "t_fnc_principal" does not exist
État SQL :42P01

Désolé, mais là, je suis dépassé.

Merci pour votre aide.

#11 Re : Migration » Migration Vues Oracle avec jointures externes. » 20/05/2009 14:39:55

J'ai testé ta ligne, même erreur, en fait je pense qu'il n'aime pas les (+).

#12 Migration » Migration Vues Oracle avec jointures externes. » 20/05/2009 12:05:09

djalouk
Réponses : 15

Bonjour,

J'effectue une migration de Oracle 9.2 vers Postgre 8.3.
J'utilise le script perl Ora2Pg.

Il me génère le script suivant

CREATE VIEW "v_pe" ("entity_data_5", "entity_fnc_incde", "usr_fnc_principal", "usr_fnc_secondaire", "usr_go_principal", "usr_go_secondaire", "go_secondaire", "fnc_secondaire", "go_principal", "fnc_principal", "bo_usr_excde", "entity_incde", "entity_excde", "entity_dsc", "entity_type_incde", "entity_crt_incde", "entity_crt_dte", "entity_mdf_incde", "entity_mdf_dte", "entity_pub_incde", "entity_pub_dte", "entity_sec_lvl", "entity_status_incde", "entity_version", "entity_go_incde", "entity_root_incde", "entity_summary", "entity_data_1", "entity_data_2", "entity_data_3", "entity_data_4") AS (select t_fnc_principal.usr_incde as usr_fnc_principal,
           t_fnc_secondaire.usr_incde as usr_fnc_secondaire,
           t_go_principal.usr_incde as usr_go_principal,
           t_go_secondaire.usr_incde as usr_go_secondaire,
           t_go_secondaire.go_secondaire as go_secondaire,
           t_fnc_secondaire.fnc_secondaire, t_go_principal.go_principal,
           t_fnc_principal.fnc_principal,  t_bo_usr.usr_excde as bo_usr_excde, t_entity.*
      from (select entity_incde, entity_go_incde as go_principal, usr_incde
              from p_entity, a_bo_usr_go
             where entity_go_incde = go_incde) t_go_principal,
           (select entity_incde, entity_fnc_incde as fnc_principal, usr_incde
              from p_entity, p_bo_usr
             where entity_fnc_incde = usr_fnc_incde) t_fnc_principal,
           (select p.entity_incde, fnc_incde as fnc_secondaire, usr_incde
              from p_entity p, a_entity_fnc a, p_bo_usr
             where a.entity_incde = p.entity_incde
               and fnc_incde = usr_fnc_incde) t_fnc_secondaire,
           (select p.entity_incde, a.go_incde as go_secondaire, usr_incde
              from p_entity p, a_entity_go a, a_bo_usr_go abug
             where a.entity_incde = p.entity_incde
               and a.go_incde = abug.go_incde) t_go_secondaire,
           p_entity t_entity, p_bo_usr t_bo_usr
     where t_fnc_principal.entity_incde(+) = t_entity.entity_incde
       and t_go_principal.entity_incde(+) = t_entity.entity_incde
       and t_fnc_secondaire.entity_incde(+) = t_entity.entity_incde
       and t_go_secondaire.entity_incde(+) = t_entity.entity_incde
	   and t_bo_usr.usr_incde(+) = t_entity.entity_crt_incde);

Et bien évidemment lorsque je joue le script, Postgre n'aime pas les jointures externes avec (+)

Des idées ?

Pied de page des forums

Propulsé par FluxBB