Multiple SQL statements
Posted: Thu 05 Mar 2015 16:33
Can I execute multiple SQL statements in a single OracleCommand? I need to run a script that checks/drops/creates tables, sequences and all the things my application needs. This works fine with standard providers for SQL Server, MySQL and SQLite, but I have trouble using it with Oracle. There are begin/end blocks in my script, and if I just put them together, I get the error "found 'begin'". If I put a slash between them, I get the error "found '/'". Any ideas?
Here's an example that fails after the first statement:
Here's an example that fails after the first statement:
Code: Select all
begin
execute immediate 'drop table "Companies"';
exception
when others then if sqlcode != -942 then raise; end if;
end;
/
begin
execute immediate 'drop table "People"';
exception
when others then if sqlcode != -942 then raise; end if;
end;
/