Executing a procedure automatically after another procedure

Hi , I have a procedure X , I want a procedure Y to run right after procedure X is executed ...Is there some kind of database trigger or scheduling to do that?
Thanks

Although there is often too much reticence about using AQ, I'm not sure I agree about it being the most appropriate or simplest solution here.
Oasis,
As I understand it, you've got a form calling a procedure X.
When procedure X finishes you want to call procedure Y.
You're not bothered about that call to procedure Y happening in the same transaction.
This seems a classic case for using DBMS_JOB to do some asynchronous work
And I mean DBMS_JOB and not DBMS_SCHEDULER from 10g onwards because when you can't create a job with DBMS_SCHEDULER as part of a wider transaction, i.e. the creating of a job via DBMS SCHEDULER does an implicit commit.
In which case, you would make a change something like
PROCEDURE x
l_job BINARY_INTEGER;
BEGIN
DBMS_JOB.SUBMIT
(job => l_job,
what => 'begin y; commit; end;');
END;Your user will need CREATE JOB privilege.
Edited by: DomBrooks on Jan 21, 2010 2:45 PM

Similar Messages

  • PL/SQL: Executing a procedure from within another procedure

    Hello, I'm a newbie and I need help on how to execute procedures from within another procedure. The procedure that I call from within the procedure have return values that I want to check.
    I tried: EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    but I get the error message:
    PLS-00103: Encountered the symbol "USER_GET_FORUM_INFO" when expecting one of the following::= . ( @ % ; immediate
    The symbol ":=" was substituted for "USER_GET_FORUM_INFO" to continue.
    And when I tried: EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    I get the error message:
    PLS-00222: no function with name 'USER_GET_FORUM_INFO' exists in this scope
    PL/SQL: Statement ignored
    The procedure USER_GET_FORUM_INFO exists. (don't understand why it says "no FUNCTION with name", it's a procedure I'm executing)
    I'm stuck so thanks for any help...
    Below is all the code. I'm using Oracle 9i on RedHat Linux 7.3.
    ================================================================================
    CREATE OR REPLACE PROCEDURE user_forum_requestsaccess (
    p_forumid IN NUMBER,
    p_requestmessage IN VARCHAR2
    AS
    var_forumid NUMBER;
    var_forum_exists NUMBER;
    var_forum_access NUMBER;
    request_exists NUMBER;
    var_forumname VARCHAR2(30);
    FORUM_DOESNT_EXIST EXCEPTION;
    FORUM_USER_HAS_ACCESS EXCEPTION;
    FORUM_REQUEST_EXIST EXCEPTION;
    BEGIN
    SELECT SIGN(NVL((SELECT request_id FROM forum.vw_all_forum_requests WHERE forum_id = p_forumid AND db_user = user),0)) INTO request_exists FROM DUAL;
    EXECUTE(user_get_forum_info(p_forumid, var_forum_exists, var_forum_access, var_forumname));
    IF var_forum_exists = 0 THEN
    RAISE FORUM_DOESNT_EXIST;
    ELSIF var_forum_access = 1 THEN
    RAISE FORUM_USER_HAS_ACCESS;
    ELSIF request_exists = 1 THEN
    RAISE FORUM_REQUEST_EXIST;
    ELSE
    INSERT INTO tbl_forum_requests VALUES (SEQ_TBL_FORUM_REQ_REQ_ID.NEXTVAL, SYSDATE, p_requestmessage, p_forumid, user);
    INSERT INTO tbl_forum_eventlog VALUES (SEQ_TBL_FORUM_EVNTLOG_EVNT_ID.NEXTVAL,SYSDATE,1,'User ' || user || ' requested access to forum ' || var_forumname || '.', p_forumid,user);
    COMMIT;
    END IF;
    EXCEPTION
    WHEN
    FORUM_DOESNT_EXIST
    THEN RAISE_APPLICATION_ERROR(-20003,'Forum doesnt exist.');
    WHEN
    FORUM_USER_HAS_ACCESS
    THEN RAISE_APPLICATION_ERROR(-20004,'User already have access to this forum.');
    WHEN
    FORUM_REQUEST_EXIST
    THEN RAISE_APPLICATION_ERROR(-20005,'A request to this forum already exist.');
    END;
    GRANT EXECUTE ON user_forum_requestsaccess TO forum_user;
    ================================================================================
    Regards Goran

    you don't have to use execute when you want to execute a procedure (only on sql*plus, you would use it)
    just give the name of the funtion
    create or replace procedure test
    as
    begin
        dbms_output.put_line('this is the procedure test');
    end test;
    create or replace procedure call_test
    as
    begin
        dbms_output.put_line('this is the procedure call_test going to execute the procedure test');
        test;
    end call_test;
    begin
        dbms_output.put_line('this is an anonymous block calling the procedure call_test');
        call_test;
    end;
    /

  • Database is Hanging after executing the Procedure ...

    Dear All i am using 10G.
    I Have a procedure . After executing the Procedure when i try to call that procedure it is hanging ...
    it is creating Locks .. As our DBA told..And told to check the code ...
    Can any one tell me how can i put mu codes with formatting ? When i copy paste my code it is showing properly but after POST MESSAGE it is showing like i have written history ...--*
    I am Executing the procedure like this ...
    EXEC simulator_validation ('0|BP-V1|20101004|01|1|2430962.89|27|2430962.89|MUR|20100928120106','04-SEP-2010',27,2430962.89,'MUR','000111111111');
    And my code is :-
    {Create Or Replace Procedure simulator_validation (lstring varchar2,ldate date,lno_item number,ltotal number,lcur varchar2,lac_no Varchar2)
    IS
      l_swift_code_acno number;
      l_ACno_Valid number;
      l_swift_code_others Number;
      lpcode varchar2(5);
      lCcode Varchar2(4);
      lval number;
      lacno varchar2(16);
      v_file varchar2(20);
      v_path varchar2(50);
      LToken   VARCHAR2(100) ;
      i        PLS_INTEGER := 2 ;
      lfirst_char  number;
      lvalue  Varchar2(100) ; 
      lcol number:= 1;
    Begin
      lfirst_char := Substr(lstring,0,1);
      Dbms_output.put_line(lfirst_char);
          IF lfirst_char  = '0' Then ------------------- For the 1st Line - Should be start from 0
                Loop
                  LToken := mcb_simulator_pkg.Split( lstring, i , '|') ;  
                  lvalue := LToken;
                      IF lcol=1 then
                             If lvalue='BP-V1' THEN
                                   Dbms_output.put_line('1');
                             Else
                                 Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0003','Invalid file type and version number');
                                Dbms_output.put_line('2');
                            End if;
                      Elsif lcol=2 then
                              If lvalue=To_Char(ldate,'YYYYMMDD') THEN
                                 Dbms_output.put_line('3');                                                                                                                                                                                                                                       
                            Else
                                 Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0004','Due date differs from the value inputted in the loading screen');
                                 Dbms_output.put_line('4');
                            End if;
                      Elsif lcol=3 then
                                   Begin
                                         Select PAYMENT_PURPOSE_CODE into lpcode
                                         From MU_PURPOSE_CODE
                                         Where PAYMENT_PURPOSE_CODE = lvalue;
                                     IF lpcode = lvalue Then
                                           Dbms_output.put_line('5');
                                     Else
                                          Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0006','Invalid payment purpose code');
                                          Dbms_output.put_line('6');
                                     End If;
                                Exception
                                    When No_data_found Then
                                    Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0006','Invalid payment purpose code');
                                End;
                      Elsif lcol=4 then
                                    If lvalue='1' THEN
                                         Dbms_output.put_line('7');
                                    Else
                                       Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0008','Total number of debit records in header does not tally with number                   debit records in the file.');
                                      Dbms_output.put_line('8');
                                   End if;
                      Elsif lcol=5 then
                                    If lvalue=ltotal THEN
                                          Dbms_output.put_line('9');
                                    Else
                                        Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0010','Total debit transaction amount in header does not tally with the sum of debit transaction amount in the file');
                                       Dbms_output.put_line('10');
                                  End if;
                     Elsif lcol=6 then
                                    If lvalue=lno_item THEN
                                         Dbms_output.put_line('11');
                                    Else
                                        Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0025','Number of credit records does not tally with credit records in the file.');
                                    End if;
                     Elsif lcol=7 then
                                    If lvalue=ltotal THEN
                                         Dbms_output.put_line('12');
                                    Else
                                         Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0026','Sum of credit records does not tally with total transaction amount as inputted in the loading screen');
                                    End if;
                    Elsif lcol=8 then                
                                    If lvalue=lcur  THEN
                                          Begin
                                                    Select Cur_CODE into lCcode
                                                      From Mu_currency_Code
                                                    Where Cur_CODE = lvalue;
                                                    Dbms_output.put_line('13');
                                          Exception
                                              When No_data_found Then--------------------
                                                 Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0014','Invalid Currency');
                                          End;
                                    Else
                                          Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0013','Currency differs from the value inputted in the loading screen');
                                   End if;
                     Elsif lcol=9 then
                                    If lvalue=Null  THEN
                                          Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0015','Timestamp should not be null');
                                    Elsif lvalue <> lvalue Then
                                         Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0046','Timestamp in header should be in the format YYYYMMDDHHMMSS');
                                    End if;
                       End IF;
                      EXIT WHEN LToken IS NULL ;
                         i := i + 1 ;
                         lcol:=lcol+1;
                       End LOOP;
              Else
                                      Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (9999,'0002','First line should always start with 0');
              End if ;}
    -------------------- For the 2nd Line , should be start from 9 .-----------------------------
    {  lfirst_char := Substr(lstring,0,1);
    IF lfirst_char = '9' Then
    LOOP
    LToken := mcb_simulator_pkg.Split( lstring, i , '|') ;
    lvalue := LToken;
    IF lcol=1 then
    If lvalue < 0 THEN
    Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0017','Amount should be greater than zero');
    Elsif lvalue = ltotal THEN
    Dbms_output.put_line('20');
    Else
    Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0018','Transaction amount differs from the value inputted in the loading screen');
    End if;
    ELSIF lcol = 2 THEN
    If lvalue = Substr(lac_no,4,9) THEN
    mcb_simulator_pkg.Acct_no_Validator(lvalue,1111,l_ACno_Valid);
    mcb_simulator_pkg.Swift_code_validator_for_ac_no(lvalue,1111,l_swift_code_acno);
    Else
    Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0020','Account number differs from the account number inputted in the loading screen');
    End if;
    ELSIF lcol = 3 THEN
    If lvalue is not null THEN
    mcb_simulator_pkg.Swift_code_validator_for_other(lvalue,1111,l_swift_code_others);
    Else
    Dbms_output.put_line('21');
    End if;
    END IF;
    EXIT WHEN LToken IS NULL ;
    i := i + 1 ;
    lcol:=lcol+1;
    End Loop;
    Else
    Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (8888,'0016','Second line should start with 9');
    End IF; }
    -------------------- For the 3rd Line Should be start from 1.--------------------------
    { LOOP
    lfirst_char := Substr(lstring,0,1);
    IF lfirst_char = '1' Then
    Loop
    LToken := mcb_simulator_pkg.Split( lstring, i , '|') ;
    lvalue := LToken;
    IF lcol=1 then
    If lvalue > 0 THEN
    Dbms_output.put_line('24');
    Else
    Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (1111,'0017','Amount should be greater than zero'); End if;
    ELSIF lcol=2 then
    Mcb_simulator_pkg.Acct_no_Validator(lvalue,1111,l_ACno_Valid);
    Mcb_simulator_pkg.Swift_code_validator_for_ac_no(lvalue,1111,l_swift_code_acno);
    ELSIF lcol = 3 THEN
    If lvalue is not null THEN
    mcb_simulator_pkg.Swift_code_validator_for_other(lvalue,1111,l_swift_code_others);
    Else
    Dbms_output.put_line('26');
    End
    END IF;
    EXIT WHEN LToken IS NULL ;
    i := i + 1 ;
    lcol:=lcol+1;
    End Loop;
    Else
    Insert into MU_SIMULATOR_output_ERR (load_no,ERR_CODE,ERR_DESC) values (7777,'0022','The third line onward should start with 1');
    End if;
    END LOOP;
    Commit;
    End;}
    Edited by: LuKKa on Oct 4, 2010 9:20 PM
    Edited by: LuKKa on Oct 4, 2010 9:25 PM

    Yes i gave {} but it is also coming like this ...Yes, since you should use {noformat}{noformat} before and after your example, and not putting your example between a '{' and a '}'.
    So, when you post/type/copypaste:
    {noformat}select *
    from emp;{noformat}
    on this forum, it will appear as:select *
    from emp;See the FAQ for more tags/tips:
    http://forums.oracle.com/forums/help.jspa                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Shows output / summary after executing a procedure

    Developers have come to me, with below challenge, I am not able to solve / help with, found nothing from my 1 hour search on Google and forums.
    Is there parameter in database or SQLPlus that shows output / summary after executing a procedure?
    I have few updates and few inserts in my procedures, I also user[b] execute immediate once on my proc.
    I want to know how many rows were updated / inserted, at the moment you just get ‘successfully completed.’ After executing a procedure.
    SQL> @myproc.sql
    PL/SQL procedure successfully completed.If anyone is 100% it's not possible, and you have to do it manually using dbms_output, please let me know.
    Thanks for any help

    PL/SQL executes inside the Oracle server process that is servicing your client session. How can it display anything on the client side?
    SQL*Plus (a typical client) displays information messages such as "PL/SQL procedure successfully completed." - and it reads the DBMS_OUTPUT buffer in PL/SQL and write it to your display (when the SERVEROUTPUT SQL*Plus environment variable is set).
    PL/SQL is incapable of "displaying" anything. Rendering is done the client.
    It is important to grasp this basic client-server concept.
    PL/SQL is also in fact two very distinct languages that are tightly integrated. PL and SQL. When PL executes a SQL statement, it does so via the same basic Oracle call interface as any other language. Part of this call interface contains the results of the SQL statement executed - this not only include a return code, but also the number of rows reported affected by the SQL engine. PL "publishes" that result via its system variable called SQL%ROWCOUNT.
    However, due to the way PL calls SQL with respect to the different ways you can construct SQL in PL (implicit cursors, explicit cursors, ref cursors, etc), this variable is only valid when dealing with an implicit cursor. Cursor "system/SQL" variables also exist and these are prefixed with the variable name of the cursor in the format <cursorvar>%<sqlvar>.
    Details can be found in the [url http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm]Oracle® Database PL/SQL User's Guide and Reference.

  • Execute the Procedure automatically

    Hello,
    is it possible to execute a procedure for example every 5 minutes automatically?

    VARIABLE jobno number;
    BEGIN
       DBMS_JOB.SUBMIT(:jobno,
          'proc;'
          SYSDATE, 'SYSDATE + 5/1440');
       commit;
    END;
    /See here for more information:
    Re: trigger to copy old data
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_job2.htm#1002030

  • How to execute my procedure automatically every second

    dear all
    i made a procedure that simply insert a record in a table . i need to execute this procedure automatiaclly every one second. how can i achive this. please help

    well , i'm going to tell you what exactly is the business.
    we have two distributed databases , 'local_db' and 'remote_db'.
    'local_db' is ours, i mean we desinged and created it . it contains our own views tables. but it contains no data at all.
    we get our data from the remote_db. this remote_db is located on the stock exchange. it is not ours, we did not create it, but we have the privilage to read form its tables.(only select ). in other words , the stock exchange is the our data vendor.
    tha changes that takes palce in the remote_db occures every second.And i urgently need to copy these changes on time to my database(local_db)

  • Strage behaviour while executing the Procedure

    Hi All,
    In Schema "Dwr_trade" we have one procedure Proc1. There is another schema
    " Dwr_trade_user " this schema has execute privilege on Proc1 of "Dwr_trade" schema.
    When we are executing the procedure Proc1 from "Dwr_trade" schema as follows
    Dwr_trade --- (Procedure is created here)
    Begin
    Exec procedure Dwr_trade.Proc1
    End;
    It gives error ,but when we are executing the same procedure after removing the prefix "Dwr_Trade" it is executing successfully.
    when we are executing the procedure from "Dwr_trade_user " then also is working fine.We are executing it as follows.
    Dwr_trade_user
    Begin
    Exec procedure Dwr_trade.Proc1
    End;
    Any pointer why this is giving error in 1st case.
    Many Thanks
    Dikshit

    Begin
    Exec procedure Dwr_trade.Proc1 <----Isnt Syntax prob
    End;
    SQL> CREATE OR REPLACE PROCEDURE mypro AS
      2  BEGIN
      3  null;
      4  END;
      5  .
    SQL> /
    Procedure created.
    SQL> EXECUTE PROCEDURE mypro;
    BEGIN PROCEDURE mypro; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00103: Encountered the symbol "PROCEDURE" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge
    <a single-quoted SQL string> pipe
    SQL> EXECUTE PROCEDURE scott.mypro;
    BEGIN PROCEDURE scott.mypro; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00103: Encountered the symbol "PROCEDURE" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge
    <a single-quoted SQL string> pipe
    The symbol "PROCEDURE" was ignored.
    SQL> EXECUTE mypro;
    PL/SQL procedure successfully completed.
    SQL> EXECUTE scott.mypro;
    PL/SQL procedure successfully completed.Khurram

  • How to execute a procedure depending on the result of a query?

    Hello, I'm new in ODI.
    I want to execute a procedure depending on the result of a query Oracle table.
    We have a Oracle Table whit a column that contains two possibles values.
    I want read the table, row by row, and depending on this value, execute a Procedure or execute another.
    How can i do?

    what you need to do is
    1. create a variable which "new_var2" which has the count of the number of rows you want to process. must be data type numeric.
    2. copy "new_var2" to the package screen.
    3. duplicate the "new_var2" on the package screen and evaluate the variable and test for "> 0" zero, call it "new_var2_E"
    3. create a new odi variable "new_var1" with a refresh of "select field1 fom (select field1,rownum as rownumber from tablex) where rownumber = #new_var2" in the relevant schema and technology.
    4. copy "new_var1" into your package (some where in the flow)
    5. right click the "new_var1" variable in you package screen and you should get the option duplicate step (click on that)
    6. select the the duplicate "new_var1" on the package screen and correct the the name to something meaning full to you "new_var1_E", also change the "type" to "evaluate variable" then you should see a "value" box. enter one of the values you want to test in the box (remember do not put in quotes ' )
    7. now back on the package screen join the "new_var1" to the "new_var1_E" with an OK line
    8 you now join "new_var2" to "new_var2_E" with OK
    9 you join "new_var2_E" to "new_var1"
    10. you then join the "new_var1_E" with an OK or a KO line to the relevant procedure.
    12. you need to duplicate "new_var2" in the package screen one more time this time and call it "new_var2_D" set the type to evaluate and then select the increment of -1
    13. the relevant procedure to "new_var2_D" with an OK
    14. join the "new_var2_D" to the "new_var2_E" with an OK
    15. this should close off the loop now the exit point is "new_var2_E" with a KO line to the next part of your process....
    Basically you should end up with a loop on new_var2 decementing, and it is used to get a specific next record row from your table.
    Hope this helps, sorry it is a little long winded..
    Edited by: DavidGD on Feb 8, 2009 3:29 PM

  • Error while executing PlSQL Procedure

    Hi Chris,
    Procedure SPR_VISAMAST_SWITCHCATEGORIZE is created in the TimesTen interchange user. and all object used by this procedure also cached in the TimesTen.
    While executing it is giving error.
    I traced out where execution is failing, i found that update query on cached table it is giving error.
    Command> DECLARE
    > SOUTPUT VARCHAR2(4000);
    > BEGIN
    > INTERCHANGE.SPR_VISAMAST_SWITCHCATEGORIZE('123456', 'SWTCH.030709', 'v2.01', 'fl.01' , 'v2.02' , '1' , SOUTPUT);
    > END;
    > /
    5213: Bad Oracle login error in OCISessionBegin(): ORA-01017: invalid username/password; logon denied rc = -1
    5131: Cannot connect to backend database: OracleNetServiceName = "geni11g", uid = "INTERCHANGE", pwd is hidden, TNS_ADMIN = "/u01/app/oracle/product/11.1.0/db_1/network/admin", ORACLE_HOME= "/u01/app/oracle/product/11.1.0/db_1"
    8507: ORA-06512: at "INTERCHANGE.SPR_VISAMAST_SWITCHCATEGORIZE", line 39
    8507: ORA-06512: at line 4
    The command failed.
    Please tell me how to solve this issue.

    So when you execute this procedure it is actually executing as user INTERCHANGE. Any objects that the procedure references whcih do not include an explicit owner will assume the object is owned by user INTERCHANGE and this may mean that an object cannot be found.
    Here is an example...
    Let's say you have a cached table in TimesTen and the table is owned by the user 'CACHEUSER' - CACHEUSER.MyCachedtable.
    If you create a PL/SQL procedure owned by the user INTERCHANGE - INTERCHANGE.Someprocedure and within thie procedure include a statement like SELECT * FROM MyCachedtable then when the procedure is executed it will by default always look for the table INTERCHANGE.MyCachedTable even if the user executing the procedure is 'CACHEUSER'. As a result, it would not find the table MyCachedTable in TimesTen and, depending on the setting for PassThrough it might try and go to Oracle for this table.
    Another possibility is that the PL/SQL procedure is performing some cache operation that requires interaction with the Oracle DB and you did not include 'OraclePWD=xxx' to provide the password for Oracle when you connected. Remember that the procedure will be executing, by default, as the user INTERCHANGE not as the user 'CACHEUSER'.
    Chris

  • Executing A Procedure In a Package Using DBLink

    I need to execute a procedure which is residing in a package using dblink.
    The package got a execute PUBLIC grant.
    When I execute the following statement, I am getting error ORA: 00904, Invalid Identifier
    select PKG_NAME.PROCEDURE_NAME@dblink(null,null,null,null,null,null,null,null,null,null,null) from dual
    How can I execute the above statement.
    Thanks in advance

    I have a database INLABNEW in that i have done this
    SQL> create table temp(no number)
      2  /
    Table created.
    SQL> create or replace package pkg
      2  as
      3     procedure p;
      4  end;
      5  /
    Package created.
    SQL>  create or replace package body pkg
      2   as
      3      procedure p
      4      is
      5      begin
      6             insert into temp values(1);
      7      end;
      8   end;
      9  /
    Package body created.
    SQL> select * from temp
      2  /
    no rows selectedNow i executed the procedure pkg.p from another database
    SQL> exec pkg.p@to_inlabnew
    PL/SQL procedure successfully completed.
    SQL> commit
      2  /And i query the table tmp in INLABNEW
    SQL> select * from temp
      2  /
            NO
             1Now question is have you given your procedure name properly.
    as your procedure is in a package it should be Your_package_name.Your_procedure_name@Your_db_link

  • Why doesn't the "grant execute any procedure" work?

    Hi to all.
    I want to grant the execute privilege for all SYS schema functions/procedures. To achieve it I do the following:
    SQL> connect sys/*****@orcl
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Connected as SYS
    SQL> create user test identified by test;
    User created
    SQL> grant create session to test;
    Grant succeeded
    SQL> grant execute any procedure to test;
    Grant succeeded
    According to the [http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9013.htm] the "grant execute any procedure" - grants Execute procedures or functions, either standalone or packaged.
    So, the steps seem to be right. Then, I try to connect to the test user and execute any procedure from the SYS schema, for example, dbms_lock.sleep:
    SQL> connect test/test@dizzy/orcl
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Connected as test
    SQL> begin
    2 sys.dbms_lock.sleep(1);
    3 end;
    4 /
    begin
    sys.dbms_lock.sleep(1);
    end;
    ORA-06550: line 3, column 1:
    PLS-00201: identifier 'SYS.DBMS_LOCK' must be declared
    ORA-06550: line 3, column 1:
    PL/SQL: Statement ignored
    So, the execution fails due to insufficient rights. However, the direct grant on the sys.dbms_lock works!
    SQL> connect sys/*****@dizzy/orcl as sysdba
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Connected as SYS
    SQL> grant execute on dbms_lock; to test;
    grant execute on dbms_lock; to test
    ORA-00911: invalid character
    SQL> grant execute on dbms_lock to test;
    Grant succeeded
    SQL> connect test/test@dizzy/orcl
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Connected as test
    SQL> begin
    2 sys.dbms_lock.sleep(1);
    3 end;
    4 /
    PL/SQL procedure successfully completed
    So, to be sure that the grant on any procedure from the definite scheme is given, should I avoid giving the execute any procedure grant?
    P.S. Is there any special tag for code?
    Thanks in advance.

    Sybrand, thank you for the reply.
    You are right. I tried to connect by another user NOT SYS and created the function:
    SQL> create user testic identified by i;
    User created
    SQL> grant create session, execute any procedure to testic;
    Grant succeeded
    SQL> create or replace function get1 return number is
      2  begin
      3  return 1;
      4  end;
      5  /
    Function created
    SQL> connect testic/i@orcl
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Connected as testic
    SQL> select get1 from dual;
    select get1 from dual
    ORA-00904: "GET1": invalid identifier
    SQL> select kaisa_rgali.get1 from dual;
          GET1
             1Thank you for the tag. This's exactly what I asked about.
    Finally, I tried t open the hyperlink http://download.oracle.com/docgs/cd/B10501_01/server.920/a96521/privs.htm but it failed.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Not able to execute a procedure from Process

    Hi
    I have created a Tabular Form type region.
    And I have created a Database procedure to insert records into some other table.
    Inorder to execute this procedure I was trying to create a PL/SQL Page process.
    When I am trying to enter the procedure details it is giving below error.
    1 error has occurred
    ORA-06550: line 3, column 1: PLS-00201: identifier 'XXSURCHARGE_PKG.INSERT_INTO_MAIN' must be declared ORA-06550: line 3, column 1: PL/SQL: Statement ignored
    But I am able to create a page process with same procedure in another application.
    Is there any restrictions on Tabular Form type regions.
    Regards
    Kiran Akkiraju

    Hi
    I am able to find out the problem. Application was created on a particular Schema and procedure was created another schema. So, there was a permission issue.
    Regards
    Kiran Akkiraju

  • Executing stored procedure dynamically

    Hi Everybody,
    I am trying to execute one procedure in other procedure dynamically. I am not sure, how to do this. Please provide your responses and comments.
    Main Sp:
    CREATE OR REPLACE PROCEDURE R2D2.SP_UPDATE (
    V_ID IN RC_PENDING_TX.CS_ID%TYPE,
    S_ID IN RC_PENDING_TX_STATUS_VL.STATUS_ID%TYPE,
    A_ID IN VARCHAR2,
    V_NOTES IN VARCHAR2
    IS
    v_date DATE := SYSDATE;
    db_id varchar2(10);
    stmt varchar2(10000);
    stmt1 varchar2(10000);
    BEGIN
    db_ID := get_id(v_ID);
    IF S_ID = 1
    THEN
    stmt:= 'begin utl_pkg.set_v_id@'||db_id||'('||V_ID||','||'1'||'); end;';
    stmt1:= 'begin utl_pkg.set_t_id@'||db_id||'('||V_ID||','||'1,2,3,4'||','||'Y'||');end;';
    execute immediate stmt;
    execute immediate stmt1;
    END IF;
    END SP_UPDATE;
    1) GET_ID IS function to get db_id for v_id.
    2)utl_pkg.set_v_id,utl_pkg.set_t_id two sps i need to execute if s_id = 1.
    3) I have to execute both sps utl_pkg.set_v_id, utl_pkg.set_t_id , which take v_id as input parameter from main sp and these sps will execute in db with db link db_id (which we get from function for v_id we pass in main sp).
    Please let me know, how i can do this. DO i need to do it dynamically or i can do it in some ways.
    Please help me guys. I will really appreciate it.
    Thank you in advance.

    Try this.
    Please see closely commas and parameter passed in procedures.
    SQL> select name from v$database;
    NAME
    ORADB1
    SQL> create or replace package UTL_PKG is
      2   procedure set_v_id(v_id varchar2,any_value varchar2);
      3 
      4  end UTL_PKG;
      5  /
    Package created.
    SQL> create or replace package body UTL_PKG is
      2 
      3    Procedure set_v_id( v_id varchar2,any_value varchar2 )is
      4     
      5    begin
      6       
      7    dbms_output.put_line('Package from remote DB'||v_id ||' '||any_value);   
      8       
      9    end;
    10 
    11  end UTL_PKG;
    12  /
    Package body created.
    SQL> Now on another DB
    SQL> select name from v$database;
    NAME
    ORADB2
    SQL> select db_link,host from all_db_links;
    DB_LINK                HOST
    DB1_LINK              ORADB1  
    SQL> CREATE OR REPLACE PROCEDURE SP_UPDATE (
      2  V_ID IN emp.ename%TYPE, --This datatype is VARCAHR2
      3  S_ID IN emp.empno%TYPE, --This datatype is NUMBER
      4  A_ID IN VARCHAR2,
      5  V_NOTES IN VARCHAR2
      6  )
      7  IS
      8  v_date DATE := SYSDATE;
      9  db_id varchar2(100);
    10  stmt varchar2(1000);
    11  BEGIN
    12 
    13  select db_link into db_id from ALL_DB_LINKS   -- Assuming only DB link is present
    14 
    15 
    16  IF S_ID = 1 THEN
    17  
    18   stmt:= 'begin utl_pkg.set_v_id@'||db_id||'('||''''||v_id||''''||','||'''1'''||'); end;';
    19   dbms_output.put_line(stmt);
    20   execute immediate stmt;
    21  END IF;
    22 
    23  END SP_UPDATE;
    24  /
    Procedure created.
    SQL> show error;
    No errors.
    SQL>  begin
      2     SP_UPDATE('1',1,'a','sometext');
      3     end;
      4  /
    begin utl_pkg.set_v_id@ORADB1('1','1'); end;
    PL/SQL procedure successfully completed.
    SQL> show error
    No errors.
    SQL> Edited by: Azhar Husain on Jun 10, 2011 1:16 PM

  • Can you tell me how to execute the procedure?

    create or replace get_dob
    (ss_number varchar2,dob out date)
    as
    begin
    select birth_dae
    into dob
    from person
    where soc_sec_num=ss_num;
    exception when no_data_found
    error_notify(ss_num);
    end;
    the question is that when i want to execute this procedure,how can I use the command?
    I try to use the "execute get_dob('wang');"in the sql/plus,but the system give me wrong information.

    Errors:
    1. You left out the word PROCEDURE after CREATE OR REPLACE.
    2. You used ss_number in one place and ss_num in two others. These must be the same name.
    3. You left out the word THEN after WHEN NO_DATA_FOUND.
    Possible errors:
    1. Is birth_dae spelled correctly? Or, should it be birth_date?
    2. Is error_notify a user-defined procedure?
    Additional suggestions:
    1. It is better to use table_name.column_name%TYPE instead of specifying NUMBER, VARCHAR2, DATE, etc. for your parameters. That way if the column data types are changed in the future, you don't have to change your code.
    2. You will need to SET SERVEROUTPUT ON and use DBMS_OUTPUT.PUT_LINE to display the contents of the variable that holds the value of the out parameter.
    3. Please see suggested code for creation of procedure and execution of procedure below. I have included one row of test data so that some output will be displayed. I commented out the exception section, in order to test it, since I don't have your error_notify procedure.
    SQL> -- test data:
    SQL> CREATE TABLE person
      2    (birth_dae   DATE,
      3     soc_sec_num NUMBER)
      4  /
    Table created.
    SQL> INSERT INTO person
      2  VALUES (SYSDATE, '123456789')
      3  /
    1 row created.
    SQL> SELECT * FROM person
      2  /
    BIRTH_DAE SOC_SEC_NUM
    06-DEC-02   123456789
    SQL>
    SQL>
    SQL> -- create procedure:
    SQL> CREATE OR REPLACE PROCEDURE get_dob
      2    (ss_number IN  person.soc_sec_num%TYPE,
      3     dob       OUT person.birth_dae%TYPE)
      4  AS
      5  BEGIN
      6    SELECT birth_dae
      7    INTO      dob
      8    FROM      person
      9    WHERE  soc_sec_num = ss_number;
    10  -- EXCEPTION
    11  --  WHEN NO_DATA_FOUND THEN
    12  --    error_notify (ss_number);
    13  END get_dob;
    14  /
    Procedure created.
    SQL> SHOW ERRORS
    No errors.
    SQL>
    SQL>
    SQL> -- execute procedure:
    SQL> SET SERVEROUTPUT ON
    SQL> DECLARE
      2    v_dob DATE;
      3  BEGIN
      4    get_dob ('123456789', v_dob);
      5    DBMS_OUTPUT.PUT_LINE (v_dob);
      6  END;
      7  /
    06-DEC-02
    PL/SQL procedure successfully completed.

  • ORA-01722 when executing a procedure

    I am executing a procedure in a package thru a nightly database job. This job has been working fine for the last several months. However recently it started abending with a ORA-01722 error. No changes have been made to the code. The procedure code follows:
    PROCEDURE p_start_batch_merge_sites IS
    p_batch_site_id tf_batch_merge_sites.master_site_id%TYPE;
    p_batch_sub_site_id tf_batch_merge_sites.subordinate_site_id%TYPE;
    p_batch_sub_site_name tf_batch_merge_sites.subordinate_site_name%TYPE;
    v_error number;
    CURSOR batch_merge_sites_cur is
    Select master_site_id, subordinate_site_id, subordinate_site_name
    from tf_batch_merge_sites
    where merge_Date_time is null;
    BEGIN
    OPEN batch_merge_sites_cur;
    LOOP
    FETCH batch_merge_sites_cur into
    p_batch_site_id, p_batch_sub_site_id, p_batch_sub_site_name;
    EXIT WHEN batch_merge_sites_cur%NOTFOUND;
    pkg_tf_merge_sites.p_merge_sites(p_batch_site_id, p_batch_sub_site_id);
    select sql_err_no into v_error
    from tf_merge_log
    where id = (select max(id) from tf_merge_log);
    IF v_error <>0 then
    close batch_merge_sites_cur;
    update tf_batch_merge_sites
    set error_message_text = 'Error in Batch Merge'
    where master_site_id = p_batch_site_id
    and subordinate_site_id = p_batch_sub_site_id;
    ELSE
    update tf_batch_merge_sites
    set error_message_text = 'Batch Merge Sites Successfully Completed',
    merge_date_time = sysdate
    where master_site_id = p_batch_site_id
    and subordinate_site_id = p_batch_sub_site_id;
    pkg_tf_merge_sites.p_delete_subordinate (p_batch_site_id, p_batch_sub_site_id, p_batch_sub_site_name);
    END IF;
    END LOOP;
    CLOSE batch_merge_sites_cur;
    END;
    One call in this procedure passing 2 number fields works ok:
    pkg_tf_merge_sites.p_merge_sites(p_batch_site_id, p_batch_sub_site_id);
    The call that is abending is passing the same 2 number fields as the above call, plus a varchar2 name field.
    pkg_tf_merge_sites.p_delete_subordinate (p_batch_site_id, p_batch_sub_site_id, p_batch_sub_site_name);
    The table structure for the tf_batch_merge_sites is as follows:
    SQL> desc tf_batch_merge_sites
    Name Null? Type
    MASTER_SITE_ID NOT NULL NUMBER(12)
    MASTER_SITE_NAME NOT NULL VARCHAR2(60)
    SUBORDINATE_SITE_ID NOT NULL NUMBER(12)
    SUBORDINATE_SITE_NAME NOT NULL VARCHAR2(60)
    MERGE_DATE_TIME DATE
    ERROR_MESSAGE_TEXT VARCHAR2(100)
    REVISION_USER_NAME NOT NULL VARCHAR2(30)
    REVISION_DATE_TIME NOT NULL DATE
    p_delete_subordinate procedure:
    PROCEDURE p_delete_subordinate(
    p_site_id IN NUMBER,
    p_subordinate_site_id IN NUMBER,
    p_site_name IN VARCHAR2
    IS
    -- PROCEDURE: p_delete_subordinate
    -- NOTES: Deletes the subordinate site after merging with the master site.
    -- HISTORY:
    -- 05-01-2003 BSS Created.
    v_batchid NUMBER;
    CURSOR subordinate_site_cur(
    p_subordinate_site_id NUMBER
    IS
    SELECT rid
    FROM se_i_entities
    WHERE id = p_subordinate_site_id
    AND entity_type = 'SITE';
    BEGIN
    BEGIN
    INSERT INTO tf_merge_sites
    (site_id,
    merged_site_id,
    merged_site_name
    VALUES (p_site_id,
    p_subordinate_site_id,
    p_site_name
    EXCEPTION
    WHEN OTHERS THEN
    RAISE;
    END;
    DELETE FROM tf_site_aliases
    WHERE primary_site_id = p_subordinate_site_id;
    -- OR secondary_site_id = p_subordinate_site_id;
    DELETE FROM tf_former_site_names
    WHERE site_id = p_subordinate_site_id;
    FOR k IN subordinate_site_cur(p_subordinate_site_id)
    LOOP
    DELETE FROM se_i_entity_relationships
    WHERE entity_rid_2 = k.rid
    AND entity_type_2 = 'SITE';
    END LOOP;
    DELETE FROM se_i_entities
    WHERE id = p_subordinate_site_id
    AND entity_type = 'SITE';
    DELETE FROM tf_sites
    WHERE site_id = p_subordinate_site_id;
    DELETE FROM e_masters
    WHERE id = p_subordinate_site_id;
    COMMIT;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE;
    END;
    I've looked at the data and it looks fine. Does anyone have any idea why I would get this message after it has been running fine for several months?
    Thanks!!
    Shellie Bricker

    ORA-01722: invalid number
    Cause: The attempted conversion of a character string to a number failed because the character string was not a valid numeric literal. Only numeric fields or character fields containing numeric data may be used in arithmetic functions or expressions. Only numeric fields may be added to or subtracted from dates.
    Action: Check the character strings in the function or expression. Check that they contain only numbers, a sign, a decimal point, and the character "E" or "e" and retry the operation.
    Maybe you have bad data?

Maybe you are looking for

  • Since updating to Mavericks, my graphics card keeps crashing OSX and forcing a reboot. Anything I can do?

    Hello community! This is the first major problem I've had with my Macbook since I got it over a year ago. This is a 15" Macbook Pro with Retina Display (Mid-2012 - 2.2 GHz). Everything was fine until I upgraded to Mavericks, and ever since then, my e

  • Why does my export always seem to be Interlaced?

    I have tried many export combinations and all seem to produce the 'combing' effect. I want to export HD video for use on a blu-ray play hooked up to a HD TV. I shoot with a Sony SR7 in Full HD, import full and use the export settings as follows; AIC,

  • Chart Query and Failed to parse SQL query

    Hi, first of all, this is not a question. It is a reminder for me and maybe for someone with the same problem. I just fell over this for the 123124 time. I have a 3D Chart Query select sum(order_ok) value,       count(*) maximum_value from      v_dia

  • IPhone - Lotus Notes - Mac Outlook

    Here's the problem: I have an iPhone5s; I also have a MacBook Pro; I am running the latest OS on both. I also have a client who uses Lotus Notes for their email and calendars and I make extensive use of WebEx GoToMeeting. Everything is/was hunky-dory

  • How do I install existing indesign querys into InDesign CC 2014 on my mac?

    I received directions but cannot find the below location to add the querys Mac OS Users\[username]\Library\Preferences\Adobe InDesign\[Version]\[Language]\Find-Change Queries\[query type]