cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic SQL Script - Multiple Inserts

Former Member
0 Kudos

Hi:

I want to make a multiple insert using a Dynamic SQL Script. The code is similar this:

query := 'INSERT INTO "LGARAY"."AUTOMATONS" VALUES (' || :id || ',' || :colValue || ') ' ||

                              ' INSERT INTO "LGARAY"."AUTOMATONS_NEIGHBOUR" VALUES (' || :countNeighbour || ',' || ((:i-1) * :cant) + (:j-1) || ') ' ||

                              ' INSERT INTO "LGARAY"."AUTOMATONS_NEIGHBOUR" VALUES (' || :countNeighbour+1 || ',' || ((:i) * :cant) + (:j-1) || ') ' ||

                              ' INSERT INTO "LGARAY"."AUTOMATONS_NEIGHBOUR" VALUES (' || :countNeighbour+7 || ',' || ((:i+1) * :cant) + (:j+1) || ') ';

EXEC :query;

The problem when I execute this, is seems to be related with SQL sentences in the same line, not supported. I try to use ;, but doesnt works.

I need to execute this, nothing else, not other type of way to do this, I need to test this, so:

Is possible to prepare a STRING with 2 or more queries ?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

former_member184768
Active Contributor
0 Kudos

Hi Leonardo,

I don't think it is possible. Just out of curiosity, why should it be EXACTLY like this and not other type like breaking the query string into individual INSERT statements and executing them in a loop or something.

Regards,

Ravi

Former Member
0 Kudos

Thanks for your anwer!

Using a Loop has low perfomance, so want to check to use a Dynamic Query, but with only one sentence.

Answers (0)