I have a .sql file with name Alter_table.sql which have the following code.
alter table mytable add newcolumn VARCHAR2(1);
I don't want to edit this file and add a spool command. However I need to execute Alter_table.sql by writing spool in another file (execute_sql.sql) which should look like the below. I am not sure of the correct syntax. Can anyone please help here?
SET SERVEROUTPUT ON
SET DEFINE OFF
SPOOL Alter_Table_STD_SOURCE.log
EXEC username/password@database `Alter_table.sql`
SPOOL OFF;
SET DEFINE ON
SET SERVEROUTPUT OFF
(Thanks to Alex Poole) :-)
You need to connect first, then run your .sql file in the wrapper script using the '@' sign or 'START' commands:
...
-- Connect if not already connected.
CONNECT username/password@database
@Alter_table.sql
...
I'm not sure its a good idea to keep login/password in a file but you need to take security into account.
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