Voilà j'ai une requete de creation de table temporaire
1 2 3
| create table SWIFT_PRSW_FIELDS_TMP as select distinct FIELD_NUMBER||OPTION_LETTER||'_'||REPLACE(UPPER(ct.LABEL), ' ', '') as code, vt.LABEL||'('||ct.LENGTH||')' as type
from SWIFT_OPTION_level ol, SWIFT_OPTION o, SWIFT_MANDATORY_LEVEL ml, swift_type t ,SWIFT_OPTION_CONTENT oc, swift_CONTENT_TYPE ct, SWIFT_VAR_TYPE vt
where ol.FK_OPTION = o.OID and ol.FK_MANDATORY_LEVEL = ml.OID and oc.FK_CONTENT_TYPE = ct.OID and oc.FK_OPTION = o.oid and ct.FK_VAR_TYPE = vt.OID |
Bon c'est pas super joli mais ça me donne le résultat attendu !
Maintenant je voudrais mettre faire cette création au sein d'une procedure PL/SQL. J'utilise donc le bout de code suivant :
execute immediate('create table SWIFT_PRSW_FIELDS_TMP as select distinct FIELD_NUMBER||OPTION_LETTER||_||REPLACE(UPPER(ct.LABEL), '' '', '''') as code, vt.LABEL||''(''||ct.LENGTH||'')'' as type from SWIFT_OPTION_level ol, SWIFT_OPTION o, SWIFT_MANDATORY_LEVEL ml, swift_type t ,SWIFT_OPTION_CONTENT oc, swift_CONTENT_TYPE ct, SWIFT_VAR_TYPE vt where ol.FK_OPTION = o.OID and ol.FK_MANDATORY_LEVEL = ml.OID and oc.FK_CONTENT_TYPE = ct.OID and oc.FK_OPTION = o.oid and ct.FK_VAR_TYPE = vt.OID');
Ca compile mais à l'exécution j'ai un sushi :
1 2 3 4 5
| ORA-06550: line 4, column 0:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
; <an identifier> <a double-quoted delimited-identifier>
The symbol ";" was substituted for "end-of-file" to continue. |
Je pense que c'est du a un problème de cotes ...
Ça fait 2 h que j'essaye tout et n'importe quoi quelle est la règle d'ajout de cotes ?
juste pour information la procedure complète
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| CREATE OR REPLACE PROCEDURE PROC_GEN_PRSW IS
TABLE_TO_CREATE CONSTANT VARCHAR2(10) := 'PRSW2' ;
tmpVar NUMBER;
isAlreadyDefined int;
BEGIN
-- loading all attended PRSW fields into a temporary table
select count(*) into isAlreadyDefined from user_tables where table_name = TABLE_TO_CREATE;
if (isAlreadyDefined = 1)
then -- update
tmpVar := 1;
else -- insert
-- creating table
-- get all fields
tmpVar := 1;
execute immediate('create table SWIFT_PRSW_FIELDS_TMP as select distinct FIELD_NUMBER||OPTION_LETTER||_||REPLACE(UPPER(ct.LABEL), '' '', '''') as code, vt.LABEL||''(''||ct.LENGTH||'')'' as type from SWIFT_OPTION_level ol, SWIFT_OPTION o, SWIFT_MANDATORY_LEVEL ml, swift_type t ,SWIFT_OPTION_CONTENT oc, swift_CONTENT_TYPE ct, SWIFT_VAR_TYPE vt where ol.FK_OPTION = o.OID and ol.FK_MANDATORY_LEVEL = ml.OID and oc.FK_CONTENT_TYPE = ct.OID and oc.FK_OPTION = o.oid and ct.FK_VAR_TYPE = vt.OID');
end if;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
RAISE;
END PROC_GEN_PRSW;
/ |
Voilà si quelqu'un a une piste ou une fonction qui pourrait m'aider ... à vot' bon coeur
Emilien
Partager