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.