Calling 'start' from a pl/sql block or function

hi all,
i want to start a script from a Procedure, but using start is invalid, so i think the command 'start' is SQL*PLUS-Command. When i run the following code:
declare
stmt varchar2(200);
begin
stmt := 'start C:\null.sql';
execute immediate stmt;
end;
i get this Error:
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at line 5
how can i run a script from a Procdure???
thanks

hi,
i know that man can use java to run external commads, but this is not a system command. its sql*plus command!??
my solution befor having the idea tu use "start sql_script" is to read the commands from the script file ( either using utl_file or java) and then executing it.
is there an other way to run sql*plus commands (like start) from a PL/SQL block?

Similar Messages

  • Is there any way to call a sql file from a pl/sql block

    Hi,
    I want to call a sql file from a pl/sql block.
    the pl/sql block has an exception handler. The pl/sql block will execute the sql file and in case it throws error then the exception handler will take care of it.
    The sql file will be a master file and it will itself call other sql files.
    is it possible to call any sql file from pl/sql block ?

    When you say "sql file", what precisely do you mean? Do you have a file that has just SQL statements? Or do you have SQL*Plus scripts?
    Where are the files stored? Are they on your client machine? Or the database server?"which in turn calls other sql files" seems to imply that the answer to the first question is that you have SQL*Plus scripts. If you have SQL*Plus scripts, you need SQL*Plus to execute them. PL/SQL is running in the Oracle database, SQL*Plus is a client application. It is not practical to have PL/SQL call SQL*Plus. Since you've already ruled out the best of the bad options, it appears that the answer is no, you can't have your PL/SQL run these files.
    As Alex points out, that's probably a good thing. It sounds like your application has been designed incorrectly. If you need PL/SQL, you should be creating stored procedures and functions and calling those from PL/SQL. Having PL/SQL depend on code in flat files outside the database is not a good idea.
    Justin

  • Call VB dll in pl/sql block

    Hi Every 1
    How to call VB dll in pl/sql block.
    Is there any inbuilt oracle package?
    please give me sample code for this.
    Thanx
    Anil

    Yes, a RPC was set up.
    Listner.ora
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Server1)(PORT = 1521))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = NMP)(SERVER = Server1)(PIPE = ORAPIPE))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = E:\Oracle\Ora81)
    (PROGRAM = extproc)
    tnsnames.ora
    extproc_connection_data =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA = (SID = PLSExtProc))
    Thanks
    RCE

  • Calling a SQL script from the PL/SQL block.

    Hello All,
    I am using oracle 11g database.
    My requirment is as follows. I have a SQL script to alter the table. But before alter the table I need to test some condition , if the condition satisfy then I have to alter the table through the SQL script. For the checking the condition I have to use the plsql block and inside I need to call the SQL script.
    Can I call a SQL script from PL/SQL block, if yes then how?
    I am tring to use START, RUN and @ command but it is throughing error.
    Thanks
    SUN

    [PL/SQL manual|http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/functions55a.htm#77600] Ctrl-F start, finds nothing. [SQLPlus manual|http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/toc.htm] Ctrl-F start finds this. Isn't it wonderful that Oracle documents this stuff so we don't have to guess.
    Can I call a SQL script from PL/SQL block, if yes then how? No.
    You could call the stored procedure in a SQL*Plus script before the alter table and have it raise an exception if the condition is not met and have the script quit when there is an error.

  • Exit from a pl/sql block

    Hi all. I'm on oracle 9i.
    I have a problem: I launch my sql file, which has a part made of some SQL commands and then inside it there is a part that is a PL/SQL block.
    What I want is that if a certain if condition is verified it must exit from PL/SQL block and also it must exit from all the file!
    Here is a part of code:
    drop table test1;
    create table test1
    as select * from test2;
    create table prova_test1
    as select * from test_1
    where 1=2;
    DECLARE
    conta number := 0;
    valore number := 0;
    contap number := 0;
    valorep number := 0;
    istruzione varchar2(2000) := null;
    BEGIN
    select count(1), sum(val) into contap,valorep
    from prova_test1;
    select count(1), sum(val) into conta,valore
    from test_1;
    if conta <> contap or valore <> valorep then
    istruzione := 'exit';
    execute immediate istruzione;
    else
    others sql statements.....
    end if;
    end;
    So what I want is that if the condition is verified it must exit from pl/sql block and also from all the process.
    How can I achieve that??
    Thanks for collaboration,
    Fabrizio

    Fabrizio Delli Priscoli wrote:
    whenever sqlerror exit 99
    whenever oserror exit 98
    Number 99 or 98, are SQLCODE returned from my exception?No, they are NOT SQLCODE.
    SQLCODE is an oracle database error code.
    Now,
    sqlerror is how 'Sql*Plus' (the one that is calling the pl/sql block) would handle ANY SQL ERROR coming out of pl/sql block OR other parts of the sql you are running within the SQL*Plus construct.
    99 and 98 are the error numbers that SQL*Plus is returning to the script or code that is calling SQL*Plus. In this case, probably the 'shell script' that calls this SQL*Plus construct.
    So, you would handle that error in the shell script.
    Maybe something like this: (this is the shell script that is calling a sqlplus session).
    1>>$LOGFILE 2>>$LOGFILE sqlplus -s $DBCONN <<EOF
    whenever sqlerror exit 99
    whenever oserror exit 98
    set serveroutput on
    set feedback off
    BEGIN
    some_code;
    END;
    exit
    EOF
    ret_value=$(echo $?)
    case "$ret_value" in
        99) mail -s "Error: Some sqlerror on the script on $(date)" $SOME_EMAIL <$LOGFILE ;;
        98) mail -s "Error: Some oserror on the script on $(date)" $SOME_EMAIL <$LOGFILE ;;
    esac

  • Some "formula" interpreter or returning value from unnamed PL/Sql blocks

    Hello,
    My company is developing Payroll and HR software and we use Oracle 10G Database. For a new module we are looking for a system were the end user (power user) can put in some kind of "formula's" to define what info/figures he wants for certain calculations done by de module (the budget module calculations will be done in PL/SQL stored proc written by us).
    Example: item "MonthlySalaryCost" = (BaseYearSal + TotalBonus)/12
    Where BaseYearSal and TotalBonus are functions that exist our will exist in or database. The idea is that a PL/SQL proc (which will be the same for all our customers), at runtime will execute that "formula" and use the result in its further calculations. The "formulas" will be stored in a table. (I foresee of course a "formula" validation to prevent dangerous sql-injection).
    My idea was to use Execute Immediate in the proc to execute the formula's and work with the results. In this approach we have to write (and foresee) all possible functions to access the data the user wants to use.
    Another (more powerful) solution I think about, is seeing these "formula's" as unnamed PL/SQL blocks (stored in a table), were the end user (or consultant) can use the full power of PL/SQL (if then else, select into ..., etc..) to obtain the result he wants to return into the item.
    My problem here is : how to return a value from a unnamed PL/SQL block that is executed via Execute Immediate in a stored proc ?
    And a general question: what do you think of this approach ? are there others possibilities to do this ?
    Thanks in advance,
    Philippe.

    Hi,
    Welcome to the forum!
    This is a simple example:
    Some functions to test:
    CREATE OR REPLACE FUNCTION f_test1 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 12;
       RETURN(RESULT);
    END f_test1;
    CREATE OR REPLACE FUNCTION f_test2 RETURN NUMBER IS
       RESULT NUMBER;
    BEGIN
       RESULT := 10;
       RETURN(RESULT);
    END f_test2;
    CREATE OR REPLACE PACKAGE pack_test_functions IS
       PROCEDURE proc_test;
    END pack_test_functions;
    CREATE OR REPLACE PACKAGE BODY pack_test_functions IS
       PROCEDURE proc_test IS
          v_sql    VARCHAR2(4000);
          v_result NUMBER;
       BEGIN
          v_sql := 'SELECT F_TEST1() + F_TEST2() FROM DUAL';
          EXECUTE IMMEDIATE v_sql
             INTO v_result;
          dbms_output.put_line(v_result);
       END proc_test;
    END pack_test_functions;
    /into v_result you have the result of the operation.
    Regards,

  • How to report an error from anonymous PL/SQL blocks

    Hello,
    The following SQL*Plus script
    WHENEVER OSERROR EXIT FAILURE
    WHENEVER SQLERROR EXIT FAILURE
    DECLARE
    EXIST_INDEXES BOOLEAN := FALSE;
    BEGIN
    FOR INDEX IN (SELECT * FROM INDEXES)
    LOOP
    EXIST_INDEXES := TRUE;
    DBMS_OUTPUT.PUT_LINE(INDEX.SCHEMA || '.' || INDEX.NAME);
    END LOOP;
    IF EXIST_INDEXES THEN
    RAISE_APPLICATION_ERROR(-20000,'Before proceeding, it is recommended to drop the indexes listed above');
    END IF;
    END;
    -- Here go SQL statements that should be executed if no indexes were found
    produces this output when there is an entry in table/view INDEXES:
    SCHEMA_1.INDEX_1
    DECLARE
    ERROR at line 1:
    ORA-20000: Before proceeding, it is recommended to drop the indexes listed above
    ORA-06512: at line 13
    When there are entries in table/view INDEXES, how to:
    - suppress the 'DECLARE' and '*' lines from appearing in the script output;
    - skip executing the SQL statements after the PL/SQL block;
    - have the script return a non-zero code?
    Regards,
    Angel Tsankov

    1 You want the rest of the code not to execute, SO all code should be in one anonymous block.
    The scope of exceptions is one block.
    2 If you want to suppress
    - suppress the 'DECLARE' and '*' lines from appearing in the script output;you should not use raise_application_error, because this is how raise_application_error works.
    - whenever you raise an exception, the return code will be non-zero.
    The code you posted is really very poor, and inefficient, but as it is unclear what you are up to (you seem to want to skip executing everything when there are any indexes, if so you can just count them), it is not possible to provide working code.
    If you want to skip the rest of the code, you can declare your own exceptions, and you should just raise your own exception and the block will abort.
    Hth
    Sybrand Bakker
    Senior Oracle DBA

  • How to send a mail from a PL/SQL-block in Apex

    Hi, I am using Apex 3.0. On a page in my application users are fill out some fields, and clicking a button Apex inserts a new record in an table processing a PL/SQL-block.
    I would like to add "something" in this block so that Apex every time when it adds a new reord, also sends a mail to some people to inform them....
    A short e-mail: sender:...... receiver..... subject: New record, Text: New record was added
    Is that possible??Thx

    Hey Robert2,
    Apex has an API for sending emails: APEX_MAIL, you will need to have an SMTP server for this.
    Have a look in the user_guid, you will find what you need there.
    OLI

  • Calling Webservices from Oracle PL/SQL

    Hi,
    I am trying to call a webservice from PL/SQL using Oracle-10g database.
    I am getting the error at the line ::
    http_req:=utl_http.begin_request(p_url,'POST','HTTP/1.0');
    p_url parameter is populated with the corresponding correct url.
    ERROR ::
    ORA-29273: HTTP request failed
    ORA-06512: at "SYS.UTL_HTTP", line 1029
    ORA-12541: TNS:no listener
    However my application is runing fine in the server and from Toad/SQL plus I am able to connect to the database.
    From outside also , the webservices are working. Please help me to solve this problem.
    - Thanks
    Sandipan

    You're probably behind a firewall and need to set a proxy server in the database.
    You can do this by adding the following code (of course before you make a call to the SOAP request)
    utl_http.set_proxy('yourproxy.yourcompany.com', NULL);

  • Execute immediate in pl/sql block not functioning

    Hello,
    I've made a short plsql block which create's a bind variable on an dynamic select. when i try this in sqplus with a dbms_output.put_line(v_temp) the correct value is displayed but within the execute immediate commando the bind variable is not filled. Here's the code:
    DECLARE
    v_count number(5) := 1;
    v_text varchar2(200);
    v_temp varchar2(200);
    BEGIN
    select count(*) into v_count from v_survey_questions where page_id=2;
    for c1 in 1..v_count
    loop
    v_temp:='select text into :P2_Q'||c1||' from v_survey_questions where page_id=2 and ord='||c1||'';
    execute immediate v_temp;
    end loop;
    END;
    Any help would be appreciated.
    Thanks Leo.

    Hi Vikas,
    Thanks but i've tried that. The thing is that the bind variable :P2_Q1 is dynamic generated like this:
    DECLARE
    v_count number(5) := 1;
    v_temp varchar2(2000);
    v_temp2 varchar2(200);
    BEGIN
    select count(*) into v_count from v_survey_questions where page_id=2;
    for c1 in 1..v_count
    loop
    v_temp:='select text from v_survey_questions where page_id=2 and ord=1';
    v_temp2:=':P2_Q'||c1;
    execute immediate v_temp into v_temp2;
    end loop;
    END;
    Hope you can help me out.
    Greetings,
    Leo.

  • Call DLL from PL-SQL block

    Hello all,
    I want to call a function located in an external DLL from a PL-SQL block. I execute the followin steps :
    1. Create a database library pointing to the external DLL :
    create or replace library libstk as 'C:\SUMMIT\libstkdte_s_trade1.dll'
    2. Create the definition and the body package :
    CREATE OR REPLACE PACKAGE dllcall IS
         FUNCTION s_trade (
              s_in VARCHAR2 )
    RETURN VARCHAR2;
    PRAGMA RESTRICT_REFERENCES(s_trade, WNDS);
    end dllcall;
    show errors
    CREATE OR REPLACE PACKAGE BODY dllcall IS
    FUNCTION s_trade (s_in IN VARCHAR2) RETURN VARCHAR2
    IS EXTERNAL
    NAME "s_trade"
    LIBRARY libstk
    PARAMETERS (s_in           STRING,
    RETURN STRING);
    END dllcall;
    show errors
    set serveroutput on
    3. Start the PL-SQL block calling the external function. And I got the foolowing error :
    1 begin
    2 dbms_output.put_line ( dllcall.s_trade ( '<Request> ' ||
    3 '<CurveId>MYCURVE</CurveId> ' ||
    4 '<Mode>02</Mode> ' ||
    5 '<ExpCcy>GBP</ExpCcy> ' ||
    6 '<AsOfDate>20001023</AsOfDate> ' ||
    7 '<Entity>***SUMMIT-XML***</Entity> ' ||
    8 '</Request>') );
    9* end;
    10
    11 /
    begin
    ERROR à la ligne 1 :
    ORA-06520: PL/SQL: Error loading external library
    ORA-06522: Unable to load DLL
    ORA-06512: at "V31.DLLCALL", line 0
    ORA-06512: at line 2
    The "Read - Execute permissions" of the DLL file was given to "Authentified users" .
    What's wrong ?
    TIA
    PS : NT2K environment, DB 8.1.7
    R. Charles Emile

    Yes, a RPC was set up.
    Listner.ora
    LISTENER =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = Server1)(PORT = 1521))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = NMP)(SERVER = Server1)(PIPE = ORAPIPE))
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    SID_LIST_LISTENER =
    (SID_LIST =
    (SID_DESC =
    (SID_NAME = PLSExtProc)
    (ORACLE_HOME = E:\Oracle\Ora81)
    (PROGRAM = extproc)
    tnsnames.ora
    extproc_connection_data =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    (CONNECT_DATA = (SID = PLSExtProc))
    Thanks
    RCE

  • How to call SQL script from PL/SQL block

    Hi All,
    I have a pl/sql block from which i need to call a *.sql script file.
    Please tell me that how can i do this?
    Thanks and Regards.

    > Though just for knowledge sake, would you please tell if there is a way
    to call a sql script from a pl/sql block.
    This question stems usually from a confusion about client-server and which is which in Oracle.
    SQL*Plus is a client. PL/SQL is a server side language. SQL is a server side language.
    When entering either one of these two languages in SQL*Plus (or TOAD, SQL-Developer, etc), the content is shipped to an Oracle server process, is parsed there, and is executed there.
    The Oracle server process servicing the client can accept a single SQL statement or PL/SQL block at a time.
    It cannot accept a block of SQL statements delimited with a semicolon. That is a client concept where the client will read each delimited statement and send that, one after the other (in synchronous call mode) to the Oracle server for execution.
    The Oracle server does not have a "script parser". It understands SQL. It understands PL/SQL. And that is what it expects from the client.
    Whether the client supports the SET command, the HOST command, SPOOL command, ability to run scripts, and so... have no bearing on what the server itself is capable of doing. The server does not care what feature set the client has. It is tasked with servicing the client via SQL and PL/SQL.
    It is not tasked to support or emulate client features like running SQL scripts.
    Nor confuse PL/SQL with the very limited command set of SQL*Plus. The two has nothing in common. And just as PL/SQL cannot understand C# or Delphi commands, it cannot understand SQL*Plus commands.

  • Displaying a Message from PL/SQL block to Java Application

    Hi
    How can One display or populate a message in Java Application, that is generated from a PL/SQL block?

    Well, the easiest option would be to have a "message" parameter that gets passed back from the PL/SQL block to the calling Java application.
    I'm guessing, though, that you wouldn't be asking the question if the easy solution was a viable option... If that's the case, you're going to have to describe the problem in a bit more detail...
    Justin

  • Spooling from PL/SQL Block

    Hi,
    Is it possible to do spooling from a pl/sql block.The spool cannot be the first command because I want to give the spool file name in a loop and each time the spool name should change based on the value.
    I tried all possiblities,but I couldn't can anyone give me some idea on how to do this.
    I cannot use UTL_FILE option ,because the client agreed only for spooling.
    Is it possible to write the spool data is excel format..
    Please find below an example of my requirement..
    DECLARE
    CurSor Cur_Designation IS
    Select Designation from tbl_Designation;
    N_Desig Cur_Designation%RowType;
    Cursor Cur_Emp(Desig Number) IS
    Select Emp_no,Emp_name
    From Employee Where Emp_Designation = Desig;
    N_Emp Cur_Emp%RowType;
    BEGIN
    Open Cur_Designation ;
    Loop
    Fetch Cur_Designation INTO N_Desig;
    EXIT WHEN Cur_Designation %NOTFOUND;
    --Here I want to give the spool file name
    Spool --Should be designation name
    Open Cur_Emp(N_Desig.Designation);
    Loop
    Fetch Cur_Emp INTO N_Emp ;
    EXIT WHEN Cur_Emp %NOTFOUND;
    -- All employee details I need to come to log file
    End Loop;
    Close Cur_Emp;
    End Loop;
    Close Cur_Desingnation;
    End;
    Please advice me how to do this..
    Thanks,
    Bindu

    << I cannot use UTL_FILE option ,because the client agreed only for spooling. >>
    << I want to use it in a PL/SQL Block.I have some variables to declare and some cursors to be used.
    So where should I use the spool command.
    I tried to given after a fetch command ,but it is not working. >>
    you can't use SPOOL inside PLSQL
    you may use dbms_output calls in PLSQL
    so create a procedure test2 instead of sqlscript test2 and you will be fine
    rem =========== procedure test2 ================
    create or replace
    procedure test2 (p_param number) is
    begin
                 dbms_output.enable (1000000);
                 dbms_output.put_line('A' || chr(9) || 'B' || chr(9) || 'C' ) ;
                 FOR i_rec in (select a,b.c from xyz where a = p_param) LOOP
                     dbms_output.put_line (to_char(a) || chr(9) || b || chr(9) || c ) ;
                 END LOOP ;
    end ;
    REM ====================================================                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Error while invoking webservice using UTL_HTTP from PL/SQL Block

    Hi All,
    I am invoking a webservice (SOAP Request) from a PL/SQL block using UTL_HTTP package.
    I am able to send the complete request and am getting the required instance on the BPEL Console, but the process is erroring out while getting response back.
    and the PL/SQL Block is ending in error mentioned below:
    ERROR at line 1:
    ORA-29266: end-of-body reached
    ORA-06512: at "SYS.UTL_HTTP", line 1321
    ORA-06512: at "APPS.CSM_BPEL_TEST_PKG", line 34
    ORA-06512: at line 1
    Package is completing successfully if i test in local DB and local BPEL.
    But giving above error in client's.
    Can anyone let me know what is the cause of this.
    Thanks in advance

    I got it working by making process Synchronous.
    But with asynchronous process it is still same error.
    Thanks...

Maybe you are looking for

  • Fixed Asset and Depreciation method in SAP B1 2005B

    Hi All, I want to know what is the method by which we can do depreciation for fixed asset in SAP Business One 2005B. Looking for a postive response from all. Regards, Kawish

  • Computer wont recognize iPhone 3G

    So situation is as follows. READ VERY CAREFULLY BEFORE RESPONDING!!!! So i got iPhone 3g from a finnish Apple forum and it worked perfectly untill today. I tried to re-install the phone and i got 1600 error on iTunes, and phone got stuck on DFU mode.

  • Heavy server load with few users

    Hi, i'm running a flash media server 2.0.4 on linux and a video/audio-flashchat. When i have about 9 Users, 3 sending, all others just watching, the network-traffic is acceptable (200kb/s out, 50kb/s in) but the cpu-load is incredible high. On averag

  • Continually receive an attached file I tried to send

    I keep getting an email in a folder called Recovered Messages. I get one every couple minutes. It's a 16 mb pdf I tried to send out last week. It took 30 gigs of my hard drive before I found the problem. I tried to delete the folder, but it comes bac

  • CDP on Access Points

    Hi Using WISM with 7.0.220 and 1240 and 3502 APs. Just found that some of our 3502 AP didn't enbale their clean air and CDP when installed. This only happened on a few new APs.  But the area these APs where we seem to have had a few problems with PCs