Posts

Showing posts with the label dynamic-sql

Oracle pl/sql: executing dynamic delete within a transaction

Image
Clash Royale CLAN TAG #URR8PPP Oracle pl/sql: executing dynamic delete within a transaction I need to delete one or more row from list of tables stored in a table, and commit only if all deletion succeed. So I wrote something like this (as part of a bigger procedure): BEGIN SAVEPOINT sp; FOR cur_table IN (SELECT * FROM TABLE_OF_TABLES) LOOP EXECUTE IMMEDIATE 'DELETE FROM ' || cur_table.TABNAME || ' WHERE ID = :id_bind' USING id; END LOOP; EXCEPTION WHEN OTHERS THEN ROLLBACK TO SAVEPOINT sp; END; I know this couldn't work, because of the "execute immediate". So, what is the correct way to do that? what is the issue? are you having an error, a wrong result, ... ? – Aleksej 1 hour ago I haven't tried yet. I guess "execute immediate...

Print Max query in sql

Image
Clash Royale CLAN TAG #URR8PPP Print Max query in sql How to print dynamic query that contains more than 8000 chars. Declare @sql varchar(max) set @Qry='....(more than 8000 char)' Print (@Qry) Any help? Thanks. Print (CAST(@Qry as TEXT)) – Tapakah Ua 10 mins ago varchar(max) can store up to 2gb .... – JeffUK 7 mins ago 1 Answer 1 Just do it, varchar(max) can hold upto 2gb. E.g. declare @test varchar(max); declare @loop int = 1; set @test= 'select ''1000000000000000000000000000000000000000000'''; while @loop < 1001 begin set @test = @test + ',''1000000000000...