Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Variable substitution
Message
De
29/12/2000 03:34:16
 
 
À
28/12/2000 12:53:50
Christian Cote
Les Logiciels Onoma Inc.
Longueuil, Québec, Canada
Information générale
Forum:
Oracle
Catégorie:
PL/SQL
Divers
Thread ID:
00457423
Message ID:
00457688
Vues:
24
Hi Christian,

If you are using the variables as bind variables in an SQL statement you can use DBMS_SQL.

Method 1:
********************

l_sql:='insert into mytable values(:nb1_prod,:nb2_prod),......';

--Step 1 open cursor
csr_handle:=DBMS_SQL.OPEN_CURSOR();

--Step 2 Parse!

DBMS_SQL.PARSE(csr_handle,l_sql,DBMS_SQL.NATIVE);

-Step 3: Bind variables
FOR i IN 1..Max LOOP
DBMS_SQL.BIND_VARIABLE(csr_handle,':nb'||'_prod',xvalue(i));
END LOOP;

-Step 4: Execute
DBMS_SQL.EXECUTE(csr_handle);

-Step 5: Close
DBMS_SQL.CLOSE_CURSOR(csr_handle);

This can be rewritten as on 8i only using EXECUTE IMMEDIATELY see message #437045. However you amy still have the same problem but the syntax you may
like better than using bind variables if you only have ten bind variables.
It's much more readable but I'm assuming you have more then ten variables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform