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.

Similar Messages

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to use the output result after executing SUBMIT

    Hi,
    We want to use a field value which should come from the result of running a standard Report in our own customer program.
    And if using SUBMIT command to run that report and then using 'LIST_FROM_MEMORY' to call the result, but it seems the result is in Unicode mode, we can't directly use that result in the called program.  What do we need to do? Is there other FM to convert the result?  Thanks in advance for your valuable input.
    Regards

    use of LIST_TO_ASCI?

  • An execute query Procedure

    Hi guys, I'm starting to work in PL/SQL. I've got some experience in ms
    sql server with T-SQL and I'm trying to understand some PL basis.
    What
    I want to do, is a stored procedure that returns the result of a given
    query. Thats a simple thing to do in T-SQL. The code would be:
    bq. create procedure runQuery(@someQuery varchar(200)) \\ *     as* \\ *     exec(@someQuery)* \\ *     return*
    and the use of it would be:
    bq. runQuery 'select 123' \\ *     -----------* \\ *     123*
    bq. *(1 row(s) affected)*
    Now, I'm trying to do the same thing in PL/SQL. What i've written by now is:
    bq. CREATE OR REPLACE PROCEDURE RunQuery(someQuery IN VARCHAR2) \\ IS \\ BEGIN \\ EXECUTE IMMEDIATE someQuery ; \\ END; \\ */*
    I got a messaje saying "procedure created", but when i try to use the procedure, it doesn't shows any results:
    bq. begin \\ RunQuery('select from myTable');* \\ end; \\ */*
    I just get a "Statement processed." message with out results.
    Any idea of what I'm doing wrong?
    thanks in advance
    D

    As Alex says, forget SQL Server, forget T-SQL as Oracle and PL/SQL are completely different.
    If you need a procedure to open a dynamic query and pass the results back, the most usual way for this would be to use a REF CURSOR.
    A ref cursor is simply a pointer to a query.
    In the following example, the query is passed in to the function as a string. The function then executes (opens) the query and passes back a pointer to the query (the ref cursor)..
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function exec_query(p_query in varchar2) return sys_refcursor is
      2    v_rc sys_refcursor;
      3  begin
      4    OPEN v_rc FOR p_query;
      5    RETURN v_rc;
      6* end;
    SQL> /
    Function created.Now, within SQL*Plus (Oracle's command line SQL interface) we can declare a local variable of REFCURSOR type..
    SQL> var x REFCURSOR;And then execute our function assigning the returned ref cursor back into our local variable..
    SQL> exec :x := exec_query('select * from emp');
    PL/SQL procedure successfully completed.Now, SQL*Plus has a local variable that points to the query, but no data has yet been fetched from it.
    In SQL*Plus, to fetch the data we can use the "print" command..
    SQL> print x
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    SQL>Et voila! our data is returned.
    As another example, we can open up and fetch the data within a procedure itself..
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure proc_exec_query(p_query in varchar2) is
      2    v_rc sys_refcursor;
      3    TYPE t_rec IS RECORD (id NUMBER, name VARCHAR2(50));
      4    v_rec t_rec;
      5  begin
      6    OPEN v_rc FOR p_query;
      7    LOOP
      8      FETCH v_rc INTO v_rec;
      9      EXIT WHEN v_rc%NOTFOUND;
    10      DBMS_OUTPUT.PUT_LINE('ID: '||v_rec.id||' NAME: '||v_rec.name);
    11    END LOOP;
    12    CLOSE v_rc;
    13* end;
    SQL> /
    Procedure created.Within this procedure, you will see that we have to provide a structure for the returned data to go into. This means we have to be aware of what data we expect to be returned from our cursor (there are methods for doing it completely dynamically using the DBMS_SQL package but that's a little more complex for you as a newbie). So, our procedure expects the query to return a number and a string. It then opens the cursor and loops through it, exiting the loop when no more records are found and then closing the cursor when done. For each row we find we can do what we like with the data; in my example it is outputting the information to the databases output buffer. It is then up to something else to read that buffer and display the contents.
    For this I will use SQL*Plus again.
    To tell SQL*Plus to output any contents that appear in the database output buffer, we issue the following command..
    SQL> set serveroutput onIf we don't do this then the output will seemingly disappear into oblivion.
    So, now we've switched on the output we can execute our procedure.
    Firstly, let's execute it to fetch the Employee numbers and names from the EMP table..
    SQL> exec proc_exec_query('select empno, ename from emp');
    ID: 7369 NAME: SMITH
    ID: 7499 NAME: ALLEN
    ID: 7521 NAME: WARD
    ID: 7566 NAME: JONES
    ID: 7654 NAME: MARTIN
    ID: 7698 NAME: BLAKE
    ID: 7782 NAME: CLARK
    ID: 7788 NAME: SCOTT
    ID: 7839 NAME: KING
    ID: 7844 NAME: TURNER
    ID: 7876 NAME: ADAMS
    ID: 7900 NAME: JAMES
    ID: 7902 NAME: FORD
    ID: 7934 NAME: MILLER
    PL/SQL procedure successfully completed.Now let's execute the same procedure to fetch the Department number and names from the DEPT table..
    SQL> exec proc_exec_query('select deptno, dname from dept');
    ID: 10 NAME: ACCOUNTING
    ID: 20 NAME: RESEARCH
    ID: 30 NAME: SALES
    ID: 40 NAME: OPERATIONS
    PL/SQL procedure successfully completed.
    SQL>So that's just a couple of ways of doing it, and should help to get you started.
    ;)

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • Why there is no output after running the procedure

    Hello everyone,
    SQL> set serveroutput on size 1000000
    SQL> set echo on
    SQL> set feedback on
    SQL> declare
      2     n number(19);
      3     v_startday varchar2(100) := '7/1/2013';
      4     v_owner varchar2(100) := 'SLIMSINTDM';
      5     v_audit_tab audit_var := audit_var();
      6     v_table_name varchar2(40);
      7     type cur_type is ref cursor;
      8     v_cur cur_type;
      9     v_first_name varchar2(100);
    10     v_last_name varchar2(100);
    11     v_out_tab varchar2(100);
    12     v_lab_code varchar2(10);
    13     v_sql varchar2(20000);
    14     v_sql_1 varchar2(10000) := q'[
    15     select distinct au.first_name, au.last_name,
    16     :v_table_name table_name, lab_code
    17     from laboratory l
    18     join app_user_security aus on AUS.owning_lab_id = l.lab_id
    19     join app_user au on AU.APP_USER_ID = AUS.APP_USER join ]';
    20     v_sql_2 varchar2(10000) := q'[ t on (t.ADDED_BY = AU.APP_USER_ID
    21     or t.last_modified_by = au.app_user_id)
    22     where lab_locale = 'en_AU'
    23     and (t.added_date > to_date(:v_startday, 'MM/DD/YYYY')
    24     or t.last_modified_date > to_date(:v_startday, 'MM/DD/YYYY'))
    25     order by last_name, first_name
    26     ]';
    27  begin
    28     n := 0;
    29     for i in (select table_name from all_tables where owner = v_owner order by table_name)
    30     loop
    31         v_table_name := substr(i.table_name, 1, instr(i.table_name, '_JN') - 1 );
    32  --  dbms_output.put_line('v_table_name: ' || v_table_name ||' ; i.table_name: ' ||i.table_name);
    33         v_sql := v_sql_1 || i.table_name || v_sql_2;
    34  --  dbms_output.put_line(v_sql);
    35         begin
    36            open v_cur for v_sql using v_table_name, v_startday, v_startday;
    37            loop
    38               fetch v_cur into v_first_name, v_last_name, v_out_tab, v_lab_code;
    39               exit when  v_cur%NOTFOUND;
    40               n := n + 1;
    41               v_audit_tab.extend;
    42               v_audit_tab(n) := audit_type(v_first_name, v_last_name, v_out_tab, v_lab_code);
    43            end loop;
    44            close v_cur;
    45         exception
    46           when others then
    47              if sqlcode = -1030 then -- insufficient privs
    48                 dbms_output.put_line('No privs for ' || USER || ' on ' || i.table_name);
    49  --                  exit;
    50              end if;
    51         end;
    52     end loop;
    53      for x in (select * from table(v_audit_tab))
    54      loop
    55        dbms_output.put_line (x.first_name ||','||x.last_name||','||x.table_name||','||x.lab_code);
    56      end loop;
    57  end;
    58  /
    PL/SQL procedure successfully completed.
    Question here ,  developer can't find any output (results) as expected after running this procedure, so is ther anything wrong?
    Thank you very much.

    There is a good chance that there is another error other than -1030 but it is  going into the bit bucket never to be seen.  Check out Oracle Magazine articles on PL/SQL (http://www.oracle.com/technetwork/issue-archive/index-087690.html) for some good coding practices. Part 6, PLSQL: Error Management is relevant to exception handling. 
    You could use a PRAGMA EXCEPTION INIT(InsufficientPriv,-1030); in the declaration section and then do the following:
    EXCEPTION
      WHEN InsufficientPrivs THEN
         dbms_output.put_line('No privs for ' || USER || ' on ' || i.table_name);
      WHEN OTHERS THEN
        dbms_output.put_line('Other Error: '||SQLERRM);
    END;
    or following your example
    exception
       when others then
           if sqlcode = -1030 then -- insufficient privs
               dbms_output.put_line('No privs for ' || USER || ' on ' || i.table_name);
               -- raise;if you want to exit this block and not continue.
            else
               dbms_output.put_line('Other Error: '||SQLERRM);
               -- raise;if you want to exit this block and not continue.
           end if;
    end;

  • Procedure not showing output

    Hi!
    The following procedure does not show the output.
    {create or replace procedure GET_USER
    (username_in IN VARCHAR2, password_in IN VARCHAR2, first_name OUT VARCHAR2, last_name OUT VARCHAR2)
    is
    begin
      declare cursor c_user(i_username IN users.username%TYPE, i_password IN users.password%TYPE) is
      select first_name, last_name
      from users
      where username_in = i_username
      and password_in = i_password;
      i_username users.username%TYPE;
      i_password users.password%TYPE;
      l_first_name users.first_name%TYPE;
      l_last_name users.last_name%TYPE;
      begin
       if c_user%isopen then
         close c_user;
       end if;
       open c_user(i_username, i_password);
        fetch c_user into l_first_name, l_last_name;
       close c_user;
       first_name := l_first_name;
       last_name := l_last_name;
      end;
    end GET_USER;}
    Output showing only:
    First_name =
    Last_name =
    Thanks for any help!

    First of all, you've nested an anonymous block inside your procedure - there is no need to do this.
    Second, you don't need to check if the cursor is already open before you open it; it will never be.
    So, your code could be rewritten:
    create or replace procedure GET_USER (username_in IN VARCHAR2,
                                          password_in IN VARCHAR2,
                                          first_name OUT VARCHAR2,
                                          last_name OUT VARCHAR2)
    is
      cursor c_user(i_username IN users.username%TYPE,
                    i_password IN users.password%TYPE)
      is
        select first_name, last_name
        from   users
        where  username_in = i_username
        and    password_in = i_password;
      l_first_name users.first_name%TYPE;
      l_last_name users.last_name%TYPE;
    begin
      open c_user(username_in, password_in);
      fetch c_user into l_first_name, l_last_name;
      close c_user;
      first_name := l_first_name;
      last_name := l_last_name;
    end GET_USER;
    /My guess is that nothing is being returned by your cursor for the specified parameters. Test it out by doing:
    create or replace procedure GET_USER (username_in IN VARCHAR2,
                                          password_in IN VARCHAR2,
                                          first_name OUT VARCHAR2,
                                          last_name OUT VARCHAR2)
    is
      cursor c_user(i_username IN users.username%TYPE,
                    i_password IN users.password%TYPE)
      is
        select first_name, last_name
        from   users
        where  username_in = i_username
        and    password_in = i_password;
      l_first_name users.first_name%TYPE;
      l_last_name users.last_name%TYPE;
    begin
      open c_user(username_in, password_in);
      fetch c_user into l_first_name, l_last_name;
      if c_cursor%notfound then
        raise no_data_found;
      end if;
      close c_user;
      first_name := l_first_name;
      last_name := l_last_name;
    end GET_USER;
    /That way, if you get a No Data Found error, you'll know there were no matching rows.
    Edited by: Boneist on 09-Jul-2009 12:26
    Amended as the cursor wasn't being called with the procedure parameters and it should have been.
    This is more likely to have been the cause of the error than no matching row in the cursor!

  • 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.

  • How to execute a procedure if out parameter is table type

    Hi,
    I need to execute a procedure, output parameter of the procedure is table type.
    Oracle version I am using is 9.2.0.8 . I am using SQL*Plus
    Procedure declaration
    PROCEDURE current_open_cycle (p_ban IN repl_cust2.billing_account.ban%TYPE,
    v_bill_seq_rec OUT bill_seq_table) ;
    Table type declaration
    TYPE bill_seq_table IS
    TABLE OF bill_seq_rectype INDEX BY BINARY_INTEGER ;
    TYPE bill_seq_rectype IS RECORD (v_cycle_run_year repl_cust2.bill.cycle_run_year%TYPE,
    v_cycle_run_month repl_cust2.bill.cycle_run_month%TYPE,
    v_cycle_code repl_cust2.bill.cycle_code%TYPE,
    v_open_cycle BOOLEAN, -- An open cycle
    v_billed_cycle BOOLEAN, --
    v_invoice_number VARCHAR2(13),
    v_start_date DATE,
    v_end_date DATE,
    v_root_ban repl_cust2.bill.root_ban%TYPE) ;
    I tried executing using this script, but it failed. When I execute this oracle lost connection to data base.
    declare
    r_bill_seq_rec ss_invoice_utilities.bill_seq_table;
    begin
    ss_invoice_utilities.current_open_cycle(934018003,r_bill_seq_rec);
    end;
    Please help me how I should write declare block to execute this procedure and also print output of the procedure.
    Regards
    Raghu

    I don't see anything wrong with the anonymous block, assuming ss_invoice_utilities is the correct package name. Perhaps a simplified test case would show up what's not working there.
    As for printing the contents of an associative array, you'll have to write some code to loop through it and construct a string per row to output via dbms_output, assuming the text will fit within dbms_output's size restrictions in 9i. dbms_output is a debugging tool though - is that the requirement?
    btw "pls_integer" is less to type than "binary_integer" ;)
    Edited by: William Robertson on Apr 16, 2009 8:35 AM

  • Problem in executing Stored Procedure from Trigger

    Hi,
    Case1.
    I am executing a stored procedure form a trigger. The stored procedure is not executing fully.
    Case 2.
    But when when I execute Stored Procedure alone it is executing.
    CREATE OR REPLACE TRIGGER mhubadmin.call_proc_ratesheet_new
    after INSERT OR delete ON mhubadmin.pvt_br_ratesheet
    FOR EACH ROW
    declare
    var_orgid number;
    begin
    if inserting then
    select org_child_id into var_orgid from business_relationship where br_id=:new.br_id;
    mhubadmin.proc_ratesheet_new(var_orgid);
    else
    select org_child_id into var_orgid from business_relationship where br_id=:old.br_id;
    mhubadmin.proc_ratesheet_new(var_orgid);
    end if;
    end;
    CREATE OR REPLACE PROCEDURE proc_ratesheet_new(var_orgid in number)
    IS
    cursor c3 is select distinct(purs.user_id) from hubuser hu
    inner join PVT_USER_RATESHEET purs on hu.USER_ID=purs.USER_ID
                   where hu.ORG_ID=var_orgid;
    cursor c1(varUser_id number) is select purs.user_id,purs.ratesheet_id from hubuser hu
    inner join PVT_USER_RATESHEET purs on hu.USER_ID=purs.USER_ID
                   where hu.ORG_ID=var_orgid and purs.USER_ID=varUser_id;
    cursor c2(varUser_id number) is select hu.user_id,pbr.ratesheet_id from HUBUSER hu
                             inner join BUSINESS_RELATIONSHIP br on hu.ORG_ID=br.ORG_CHILD_ID
                             inner join PVT_BR_RATESHEET pbr on br.BR_ID=pbr.BR_ID
                                  where hu.user_id in(select distinct(purs.USER_ID) from hubuser hu
                                       inner join PVT_USER_RATESHEET purs
                                                                     on hu.USER_ID=purs.USER_ID
                                                 where hu.ORG_ID=var_orgid) and hu.user_id=varUser_id;
    foundFlag boolean;
    incrFound integer;
    insertFound integer;
    deleteFound integer;
    str varchar2(4000);
    BEGIN
         incrFound:=0;
         insertFound:=0;
         for c3var in c3 loop
    for c2var in c2(c3var.user_id) loop
              insert into test values ('Step3:'||c2var.user_id);
              foundFlag:=false;
              for c1var in c1(c3var.user_id) loop
                   if c2var.ratesheet_id=c1var.ratesheet_id then
                        foundFlag:=true;
                             incrFound:=incrFound+1;
                             exit;
                        end if;
                   end loop;
                   if foundFlag=False then
                   --insert into pvt_user_ratesheet (username_ratesheet_id,user_id,ratesheet_id) values (SEQ_USER_RATESHEET.nextval,c3var.user_id,c2var.ratesheet_id);
                   dbms_output.put_line('Inserted for user :'||c3var.user_id||' is - ratesheet :'||c2var.ratesheet_id);
                   insertFound:=insertFound+1;
                   end if;
              end loop;
    end loop;
         commit;
         incrFound:=0;
         deleteFound:=0;
         for c3var in c3 loop
              for c1var in c1(c3var.user_id) loop
              foundFlag:=false;
              for c2var in c2(c3var.user_id) loop
                        if c1var.ratesheet_id=c2var.ratesheet_id then
                        foundFlag:=true;
                        incrFound:=incrFound+1;
                        exit;
                        end if;
                   end loop;
                   if foundFlag=False then
                   --delete from pvt_user_ratesheet where user_id=c3var.user_id and ratesheet_id=c1var.ratesheet_id;
                        --dbms_output.put_line('Deleted for userid:'||c3var.user_id||' for ratesheet :'||c1var.ratesheet_id);
                        deleteFound:=deleteFound+1;
                   end if;
              end loop;
    end loop;
         commit;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.put_line (SQLCODE||' '|| SQLERRM);
    END;
    Regards,
    Mathew

    In general, I would suggest that you only catch errors that you can handle reasonably. If you know that a SELECT INTO might return 0 rows for example, handle the NO_DATA_FOUND exception. Having a WHEN OTHERS, particularly without re-raising the exception, only serves to hide the source of the problem. I would much rather that my code fail quickly and explicitly than hope that I see an error message in the output and that other code doesn't start failing because the system wasn't left in an appropriate state.
    As Mark suggests, you may choose to implement a comprehensive logging framework using autonomous transactions, in which case a WHEN OTHERS would be reasonable, but you would still want to propagate exceptions you cannot handle.
    If you see a WHEN OTHERS clause and there is no RAISE, you probably have an error waiting to happen.
    Justin

  • No Results after executing Adaptive Web Service

    Hello experts,
    I develope Web Dynpro applications and currently try to consume a web service from our ERP system but I get no results from the service. When trying to consume the service with a soap-tool or with .NET, everything works fine.
    The Web Service was generated on an already available RFC.
    The service has one input parameter, which is a department name. The output should be all employees, which work in the consigned department.
    For consuming the service I created a Web Service Destination in the Visual Administrator ([see this blog|http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417100%29ID0139461950DB10406225565548708901End?blog=/pub/wlg/5186]).
    After creating the Destination I imported the service as an adaptive web service model in my web dynpro project.
    After binding the model to the component controller I implemented the following code in the controller:
    public void wdDoInit()
        model = new Z_WF_DEPARTMENT_OIC();
        Request_ZWfDepartmentOic requestMO = new Request_ZWfDepartmentOic(model);
        ZWfDepartmentOic departmentMO = new ZWfDepartmentOic(model);
        requestMO.setZWfDepartmentOic(departmentMO);
        wdContext.nodeRequest_ZWfDepartmentOic().bind(requestMO);
    public void executeRequest_ZWfDepartmentOic( )
      try{
        wdContext.currentRequest_ZWfDepartmentOicElement().modelObject().execute();
        wdContext.nodeResponse().invalidate();     
      } catch (Exception e) {
        wdComponentAPI.getMessageManager().reportException(e.toString(),false);
    I did the implementation as descibed in the following document:
    [http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/900bbf94-a7a8-2910-e298-a651b4706c1e&overridelayout=true]
    On the UI I have one input field for the department name and a table which should show the result and one table which shows messages which are returned by the web service.
    After executing the code, I get no result from the service. In my table with the messages I get one entry which just shows zeros in the fields "LogMsgNo" and "Number".
    Does anybody have a hint, what could be wrong with my proceeding?
    Edited by: Dennis Isaak on Oct 16, 2009 10:37 AM

    Check this blog post:
    http://www.drflex.eu/2008/06/dynamically-populate-dropdown-lists-using-webservices/
    This comfirms that after you execute a web service, the Drop-Down List fields will become empty due to remerge operation. Well, I have to issue a remerge, otherwise, the PDF will not be populated properly.
    Tarek.

  • How will be outbound data structure in sap xi after executing the stored pr

    Hi All
    can any one please tell me how will be outbound data structure in sap xi after executing the stored procedure by sender JDBC adapter?
    Thanks in advance
    regards
    Rams

    Hi..
    My stored procedure is select and it will be OUTBOUND in PI.
    is it will be same as following
    <resultset>
    <row>
    <column-name1>column-value</ column-name1>
    <column-name2></column-name2>
    <column-name3>column-value</ column-name3>
    <column-name4></column-name4>
    </row>
    <row>
    <column-name1>column-value</ column-name1>
    <column-name2></ column-name2>
    </row>
    </resultset>
    Regards
    Rams
    Edited by: Rameshkumar Varanganti on Oct 15, 2008 12:04 PM

  • How to show mandatory icon after the Label text?

    Hi ,
    I am using JDeveloper 11.1.1.4.
    My Scenario is I have  <af:inputtext>  with Property required="true".
    Label look like ,
    "*Name but I want to show like Name* .I want to show the * icon after the label text .
    How to achieve this in ADF ? ..
    Thanks ...

    Hi rfh,
    Thanks for the updates ,
    I tried with ,
    .AFRequiredIconStyle
      float:right;
    this CSS moving the * icon to right side but not after the label ,It's moveing infront of the InputText Value the output looks like,
    Label   *Value
    I tried with ,
    AFRequiredIcon:alias
        content:inhibit;
    It's diabled * icon entire application .This solution is ok ...But I want to diable * icon for only particular places.
    How to hide * icon for particular fields ? ......
    Thanks......

  • Found a bug in "Execute Stored Procedure..." command

    Hi...I've found one interesting "feature": if I do click "Execute Stored Procedure"on SP, which contains an XML parameter (doesn't matter if it's input or output), Management Studio generates script without declaring datatype of that
    parameter. But if I click "Generate Script" everything works fine. This situation can be observed in SQL Server 2005-2012.

    Hello,
    Please submit a product feedback on Microsoft Connect:
    https://connect.microsoft.com/sqlServer/
    Thank you for sharing what you have discovered.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • Execute a procedure with a list of array in sql server 2008

    HI all,
    I have a procedure which has a list of values passed as an array . How can i execute my procedure with array list? how to implement this?Please help me.
    Thanks in advance
    Deepa

    Hi Deepa,
    basically Microsoft SQL Server does not support arrays as data types for procedures. What you can do is creating a type which represents a table definition. This type can than be used in a procedure as the following demo will show:
    The first script creates the environment which will be used for the execution
    -- 1. create the table as a type in the database
    CREATE TYPE OrderItems AS TABLE
    ItemId int PRIMARY KEY CLUSTERED
    GO
    -- 2. demo table for demonstration of results
    CREATE TABLE dbo.CustomerOrders
    Id int NOT NULL IDENTITY (1, 1) PRIMARY KEY CLUSTERED,
    CustomerId int NOT NULL,
    ItemId int
    GO
    -- 3. Insert a few records in demo table
    INSERT INTO dbo.CustomerOrders
    (CustomerId, ItemId)
    VALUES
    (1, 1),
    (2, 1),
    (3, 3),
    (1, 3);
    GO
    -- 4. Create the procedure which accepts the table variable
    CREATE PROC dbo.OrderedItemsList
    @Orders AS OrderItems READONLY
    AS
    SET NOCOUNT ON;
    SELECT o.*
    FROM dbo.CustomerOrders AS O INNER JOIN @Orders AS T_O
    ON (o.ItemId = T_O.ItemId);
    SET NOCOUNT OFF;
    GO
    The above script creates the table data type and a demo table with a few demo data. The procedure will accept the table data type as parameter. Keep in mind that table variable parameters have to be READONLY as parameter for procedures!
    The second script demonstrates the usage of the above scenario
    When the environment has been created the usage is a very simple one as you can see from the next script...
    -- 1. Fill the variable table with item ids
    DECLARE @o AS OrderItems;
    INSERT INTO @o (ItemId)
    VALUES
    (1), (3);
    -- 2. Get the list of customers who bought these items
    EXEC dbo.OrderedItemsList @Orders = @o;
    MCM - SQL Server 2008
    MCSE - SQL Server 2012
    db Berater GmbH
    SQL Server Blog (german only)

Maybe you are looking for

  • Windows 8.1 itunes 11.1.5

    Installed Windows 8.1 on new Intel NUC and trying to install iTunes 11.1.5.  Install stalls and after awhile, it stated that Installer has failed.  Any suggestions?

  • Automatic payment block for purchase orders with no GR

    Hi all, we have this issue. We would have an automatic payment block for all the PO's that have the 2-way match (no GR set) All these PO's in our company have an account assignement (that could be a cost center or a WBS element). The important is tha

  • How to change the source module version

    Hi All, In the OWB i created a source module and during those steps i clicked on version 10.1, but during deployment in the deployment managaer when i tried to register the location, its giving me an error as "Source verison 10.1 is not matching with

  • Parameter into SQL stored procedure

    Post Author: ashleyt CA Forum: Formula I have a stored procedure that has 16 parameters being passed from the report into the stored procedure. Is there a way to code the values for 2 of the parameters.  They will always be the same value, so I would

  • How to find if a message is hung in XI when you have BPM implementation

    Hi , I have got a scenario where in i have flat file as sender and IDOCs at the Receiver. We have got BPM implemented to direct to different IDOCs. But how would i know and how to track if a flat file comes into XI and doesnt post as IDOC and if the