This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / pl/sql question, how can I execute sql code, in file sql_code.sql from pl/sql code ? thanks in advancename of sql code sql_code.sql is got from database, not hardcode
declare
...
begin
...
select script_name into v_script_name from table_name where ...;
-- execute script_name.sql
...
end;
-yyqllxh(xiang xiang);
2005-4-6
{197}
(#2223481@0)
-
Probably Oracle Packages is the answer
-kpax(kosmo);
2005-4-6
(#2223560@0)
-
Is it something like DBMS_SQL ? it seems that package is good for dynamic SQL, I want to execute an exsiting SQL code. Can you offer any details ? thank you
-yyqllxh(xiang xiang);
2005-4-6
(#2223722@0)
-
This is a dynamic SQL. You can use DBMA_SQL for version 7 or 'execute immediate' for later versions
-handd(学做盆景的大熊猫);
2005-4-6
(#2223806@0)
-
please come inI tried:
EXECUTE IMMEDIATE 'sql_code.sql'
EXECUTE IMMEDIATE 'start sql_code.sql'
EXECUTE IMMEDIATE '@sql_code.sql'
EXECUTE IMMEDIATE 'start @sql_code.sql'
no one working, only working stuff is
@sql_code.sql
but I can't call sql code that way, since the name of sql code is got from database, any idea about that ? THX
-yyqllxh(xiang xiang);
2005-4-6
{333}
(#2223867@0)
-
@sql_code.sql 是SQL/PLUS命令,EXECUTE IMMEDIATE 执行的是SQL语句,我想,如果你要RUN一个.sql的脚本,应该用一个操作系统命令,或者EXECUTE IMMEDIATE 整个SQL语句。
-hard20(hard20);
2005-4-6
(#2223901@0)
-
well, it's probably the only way to do, thank you all!
-yyqllxh(xiang xiang);
2005-4-6
(#2224027@0)
-
there are more than 1 way to do it1) DBMS_SQL
2) using util_file to write out the xxx.sql pulled from database
-kpax(kosmo);
2005-4-6
{77}
(#2224868@0)
-
I think DBMS_SQL is same as EXECUTE IMMEDIATEfor the second one, due to security reason, oracle doesn't have access to the directory which holds sql_code.sql, so UTL_FILE won't work
-yyqllxh(xiang xiang);
2005-4-6
{138}
(#2225270@0)
-
Investigate thisNew HTMLDB studio would allow you upload sql script (DML or DDL) from web page. The scripts will be stored inside the databse, it can be executed right away by pressing a button on the web page. The HTMLDB have a lot of poackages inside database, maybe the way behind scence is DBMS_SQL, who knows?
If you have time, you can find out. Maybe there is a different way of doing things
-kpax(kosmo);
2005-4-7
{384}
(#2225631@0)
-
thank you, you guys are great !
-yyqllxh(xiang xiang);
2005-4-7
(#2225795@0)
-
you can try advanced sql statements against Oracle, that could be ok. you can do lots of low level tasks using advanced sql statement
-a-z(A-Z);
2005-4-6
(#2224531@0)
-
any clue please
-yyqllxh(xiang xiang);
2005-4-6
(#2224651@0)
-
take a look at the following link, hope that can help.http://www.oraclefans.com/oraclefans/forum/dev2000/messages/2451.html
-a-z(A-Z);
2005-4-6
{69}
(#2225025@0)
-
c or java code ..., buddy, that goes too farthere may be two options now, 1 - change design, put sql code into database, not only script name. 2 - program has to be re-written in shell script
-yyqllxh(xiang xiang);
2005-4-6
{147}
(#2225281@0)
-
that is just a clue. although i do not check it out, i think you do not need write any java or c code.
-a-z(A-Z);
2005-4-6
(#2225285@0)
-
thank you, I have to say you guys are great here
-yyqllxh(xiang xiang);
2005-4-7
(#2225796@0)
-
or, take a look at : http://www.oracle.com/oramag/code/tips2001/021201.html
-a-z(A-Z);
2005-4-6
(#2225033@0)
-
or, to google " pl/sql os command". you can find anything you want from google.
-a-z(A-Z);
2005-4-6
(#2225038@0)
-
but, i remember i read a pl/sql developer guide, that may show how to develop your requirement. I remember i borrowed it from toronto library.probably you can implement your requirement directly using advanced SQL. you need to check that book up.
-a-z(A-Z);
2005-4-6
{104}
(#2225076@0)