Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variable substitution
Message
From
29/12/2000 03:34:16
 
 
To
28/12/2000 12:53:50
Christian Cote
Les Logiciels Onoma Inc.
Longueuil, Quebec, Canada
General information
Forum:
Oracle
Category:
PL/SQL
Miscellaneous
Thread ID:
00457423
Message ID:
00457688
Views:
22
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform