I have a couple of update statements that I have to execute dynamically . I am executing both these update statements using execute immediate. However, I get the following error when I do so :
ORA-00911: invalid character
ORA-06512: at line 7
00911. 00000 - "invalid character"
*Cause: identifiers may not start with any ASCII character other than ..
Is there a limitation that one cannot execute more than 1 update statement in Execute immediate ?
Edit: With example:
begin
EXECUTE IMMEDIATE 'UPDATE tt_TGT_TABLE SET PK_1 = ''Demand10'' where ROW_ID = 3923866 ; UPDATE tt_TGT_TABLE SET PK_1 = ''Demand11'' where ROW_ID = 3923868';
end;
The EXECUTE IMMEDIATE statement executes a dynamic SQL statement or anonymous PL/SQL block. You can use it to issue SQL statements that cannot be represented directly in PL/SQL, or to build up statements where you do not know all the table names, WHERE clauses, and so on in advance.
You can use the RETURNING BULK COLLECT INTO clause with the EXECUTE IMMEDIATE statement to store the results of an INSERT , UPDATE , or DELETE statement in a set of collections. You can use the BULK COLLECT INTO clause with the FETCH statement to store values from each column of a cursor in a separate collection.
You cannot simply concatenate multiple statements within an EXECUTE IMMEDIATE
call - you'll either have to use several calls:
begin
EXECUTE IMMEDIATE 'UPDATE tt_TGT_TABLE SET PK_1 = ''Demand10'' where ROW_ID = 3923866';
EXECUTE IMMEDIATE 'UPDATE tt_TGT_TABLE SET PK_1 = ''Demand11'' where ROW_ID = 3923868';
end;
or feed an anonymous PL/SQL block into EXECUTE IMMEDIATE
:
begin
EXECUTE IMMEDIATE '
begin
UPDATE tt_TGT_TABLE SET PK_1 = ''Demand10'' where ROW_ID = 3923866;
UPDATE tt_TGT_TABLE SET PK_1 = ''Demand11'' where ROW_ID = 3923868;
end;';
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With