plsql - Oracle: dynamically select script -


how run script in sqlplus pathname passed in string. following (fails):

set serveroutput on; declare    path varchar2(128); begin    path := '<runtime_path>' || 'test_script.sql';    dbms_output.put_line(path);    @ path; end; / 

you can pass parameter sqlplus cannot mix pl/sql sqlplus commands. example not fly. might need wrap shell script. @ pl/sql routine try add path. maybe possible though.

call sqlplus this

sqlplus user/password@database @genericscript.sql path 

and within genericscript.sql

set serveroutput on start &1.myscript.sql quit 

in example myscript.sql has content

select 'hello welt' dual; 

so got following output sqlplus

[oracle@localhost sqp]$ sqlplus user/pw@db @genericscript.sql /home/oracle/sqp/  sql*plus: release 11.2.0.2.0 production on tue may 14 22:53:15 2013  copyright (c) 1982, 2010, oracle.  rights reserved.   connected to: oracle database 11g enterprise edition release 11.2.0.2.0 - production partitioning, olap, data mining , real application testing options   'hellowelt ---------- hello welt  disconnected oracle database 11g enterprise edition release 11.2.0.2.0 - production partitioning, olap, data mining , real application testing options 

hope helps. can have @ sqlplus reference manual.

http://docs.oracle.com/cd/e11882_01/server.112/e16604/ch_five.htm#autoid13

i prefer pdf

http://docs.oracle.com/cd/e11882_01/server.112/e16604.pdf


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -