Commit after PL/SQL procedure successfully completed?

Hello. I have a question, it may be stupid but here goes:
When I run a script like this do I have to commit after it is completed?
SQL> @merge_candidates_INC933736.sql
PL/SQL procedure successfully completed.

XerXi wrote:
Hello. I have a question, it may be stupid but here goes:
When I run a script like this do I have to commit after it is completed?
SQL> @merge_candidates_INC933736.sql
PL/SQL procedure successfully completed.
How would anyone know? You didn't post what the script does.
If the script contains nothing but DDL to create objects then you do NOT need to add a COMMIT since Oracle wil implictily commit DDL statements.
A COMMIT should be performed at the END of a transaction. Since we don't know what, if any DML is contained in your script we have no idea how many transactions might be represented.
So for scripts that contain DML you should add a COMMIT to the script after each transaction has been completed.

Similar Messages

  • SQL*PLUS - remove output 'PL/SQL procedure successfully completed.'

    Hi,
    When I use SQL*PLUS to call a PLSQL procedure, it will always output text: 'PL/SQL procedure successfully completed.' when the PLSQL procedure completes.
    I have a requirement to not display this message output. In SQL*PLUS how do you turn this off?

    how to disable procedure successfully completed message in SQL*Plus

  • Suppressing "PL/SQL procedure completed successfully" message?

    I use anonymous blocks in some of my SQL*Plus scripts, to do things SQL*Plus can't handle.
    However, I'd like to suppress the "PL/SQL procedure completed successfully" message at the end. I've tried several SET values, but without success.
    Can anyone tell me what I'm missing? Thanks.

    set feedback off
    SQL> set echo off
    SQL> exec test2
    PL/SQL procedure successfully completed.
    SQL> set feedback off
    SQL> exec test2
    SQL>
    SQL>

  • How to make pl/sql procedure not auto-commit?

    I wish to be able to execute a create statement, and then rollback if there is a problem with any sql that follows. It seems that you cannot rollback? Why is this?
    (My problem is that I wish to execute a series of sql statements and run a rollback if anything before it fails, including the creation of the table)
    set serveroutput on;
    declare
      rcount INTEGER;
    PRAGMA AUTONOMOUS_TRANSACTION;
    begin
      execute immediate 'create table bsdconv_s1stc_code (id number)';
      dbms_output.put_line('Table created successfully');
      rollback;
    exception
      when others then dbms_output.put_line('Error while creating table. Probably already exists.');
    end;

    Ni hao, Dong Yage!
    I think using procedure and handling on call you might be able to do it.
    SQL> create table test (i int);
    Table created.
    SQL> insert into test values (1);
    1 row created.
    SQL> select * from test;
             I
             1
    SQL> set serveroutput on;
    SQL> declare
      2    rcount INTEGER;
      3  PRAGMA AUTONOMOUS_TRANSACTION;
      4  begin
      5    execute immediate 'create table bsdconv_s1stc_code (id number)';
      6    dbms_output.put_line('Table created successfully');
      7  --  rollback;
      8  exception
      9    when others then
    10       dbms_output.put_line('Error while creating table. Probably already exists.');
    11    rollback;
    12  end;
    13  /
    Table created successfully
    PL/SQL procedure successfully completed.
    SQL> desc bsdconv_s1stc_code
    Name                                      Null?    Type
    ID                                                 NUMBER
    SQL> select * from test;
             I
             1
    SQL> insert into test values (2);
    1 row created.
    SQL> set serveroutput on;
    SQL> declare
      2    rcount INTEGER;
      3  PRAGMA AUTONOMOUS_TRANSACTION;
      4  begin
      5    execute immediate 'create table bsdconv_s1stc_code (id number)';
      6    dbms_output.put_line('Table created successfully');
      7  --  rollback;
      8  exception
      9    when others then
    10       dbms_output.put_line('Error while creating table. Probably already exists.');
    11       rollback;
    12       execute immediate 'drop table bsdconv_s1stc_code';
    13  end;
    14  /
    Error while creating table. Probably already exists.
    PL/SQL procedure successfully completed.
    SQL> select * from test;
             I
             1
             2
    SQL> rollback;
    Rollback complete.
    SQL> select * from test;
    no rows selected
    SQL> desc bsdconv_s1stc_code;
    ERROR:
    ORA-04043: object bsdconv_s1stc_code does not exist
    On executing PL/SQL block secondly,
    it raises exception, displays error messages and drops table
    but main transaction is not rolled back.
    This is because rollback belongs to only inseide of
    AUTONOMOUS_TRANSACTION PL/SQL block.
    Now, let us try using procedure.
    SQL> grant create table to ushi;
    SQL> create or replace
      2  procedure create_table
      3  is
      4   PRAGMA AUTONOMOUS_TRANSACTION;
      5   begin
      6     execute immediate 'create table bsdconv_s1stc_code (id number)';
      7     dbms_output.put_line('Table created successfully');
      8  exception
      9    when others then
    10       dbms_output.put_line('Error while creating table. Probably already exists.');
    11       execute immediate 'drop table bsdconv_s1stc_code';
    12       raise;
    13  end;
    14  /
    Procedure created.
    SQL> select * from test;
    no rows selected
    SQL> begin
      2    insert into test values (1);
      3    create_table;
      4  exception
      5    when others then
      6      dbms_output.put_line('Error on Creating table or Transaction');
      7      rollback;
      8  end;
      9  /
    Table created successfully
    PL/SQL procedure successfully completed.
    SQL> select * from test;
             I
             1
    SQL> commit;
    Commit complete.
    SQL> desc bsdconv_s1stc_code
    Name                                      Null?    Type
    ID                                                 NUMBER
    SQL> begin
      2    insert into test values (2);
      3    create_table;
      4  exception
      5    when others then
      6      dbms_output.put_line('Error on Creating table or Transaction');
      7      rollback;
      8  end;
      9  /
    Error while creating table. Probably already exists.
    Error on Creating table or Transaction
    PL/SQL procedure successfully completed.
    SQL> select * from test;
             I
             1
    SQL> desc bsdconv_s1stc_code
    ERROR:
    ORA-04043: object bsdconv_s1stc_code does not exist

  • Pl/sql Procedure is Not Creating With the CLOB data Type

    Hi,
    I am Using Oracle 10g Express Edition Release2.... My Doubt is While creating a table With CLOB Data Type the table is created successfully,but while Creating a Procedure With the CLOB Data type i am getting an Error Message
    2667/5 PL/SQL: Statement ignored
    2667/24 PLS-00382: expression is of wrong type
    then i tried With the Varchar2(30000) the Procedure is Created Successfully note i have not changed any thing in my code except the data type.
    I am Just Confused ......Why the Procedure is not Created with CLOB Data type?
    Please advice ...
    Thank U
    SHAN

    hi,
    Thanks for reply....Another Example
    CREATE TABLE USER_MAS (USER_ID     VARCHAR2 (20 Byte),MAIL_ID     VARCHAR2 (255 Byte));
    set serveroutput on
    declare
    atable varchar2(64) := 'USER_MAS';
    acolumn varchar2(64) := 'MAIL_ID';
    avalue varchar2(64) := 'NEWYORK' ;
    dyn_sql clob;
    begin
    dyn_sql := 'update '||atable||' set '||acolumn||' = '''||avalue|| '''' ;
    dbms_output.put_line(dyn_sql);
    execute immediate dyn_sql;
    end;
    commit ;
    Error at line 2
    ORA-06550: line 9, column 23:
    PLS-00382: expression is of wrong type
    ORA-06550: line 9, column 5:
    PL/SQL: Statement ignored
    When i Changed the Data type to varchar2(64)
    update USER_MAS set MAIL_ID = 'NEWYORK'
    PL/SQL procedure successfully completed.
    Commit complete.
    I like to Know the Reason Why the Procedure is Not Created in Oracle 10g XE DB
    Note :the Same Script i used in 11g DB the Procedure is Created Successfully....
    Why you need use CLOB or VARCHAR2 in your temp_num variable as you sending parameters as number?
    In the Procedure we are create some run time queries while executing the procedure. There are around 10 run time queries created.
    The size of each query is more than 4000 characters . We then add all the queries using union all after each query  to the clob variable as the normal varchar will not support.
    Please Advice
    Thank U
    SHAN

  • COMMIT after every 10000 rows

    I'm getting probelms with the following procedure. Is there any that I can do to commit after every 10,000 rows of deletion? Or is there any other alternative! The DBAs are not willing to increase the undo tablespace value!
    create or replace procedure delete_rows(v_days number)
    is
    l_sql_stmt varchar2(32767) := 'DELETE TABLE_NAME WHERE ROWID IN (SELECT ROWID FROM TABLE_NAME W
    where_cond VARCHAR2(32767);
    begin
       where_cond := 'DATE_THRESHOLD < (sysdate - '|| v_days ||' )) ';
       l_sql_stmt := l_sql_stmt ||where_cond;
       IF v_days IS NOT NULL THEN
           EXECUTE IMMEDIATE l_sql_stmt;
       END IF;
    end;I think I can use cursors and for every 10,000 %ROWCOUNT, I can commit, but even before posting the thread, I feel i will get bounces! ;-)
    Please help me out in this!
    Cheers
    Sarma!

    Hello
    In the event that you can't persuede the DBA to configure the database properly, Why not just use rownum?
    SQL> CREATE TABLE dt_test_delete AS SELECT object_id, object_name, last_ddl_time FROM dba_objects;
    Table created.
    SQL>
    SQL> select count(*) from dt_test_delete WHERE last_ddl_time < SYSDATE - 100;
      COUNT(*)
         35726
    SQL>
    SQL> DECLARE
      2
      3     ln_DelSize                      NUMBER := 10000;
      4     ln_DelCount                     NUMBER;
      5
      6  BEGIN
      7
      8     LOOP
      9
    10             DELETE
    11             FROM
    12                     dt_test_delete
    13             WHERE
    14                     last_ddl_time < SYSDATE - 100
    15             AND
    16                     rownum <= ln_DelSize;
    17
    18             ln_DelCount := SQL%ROWCOUNT;
    19
    20             dbms_output.put_line(ln_DelCount);
    21
    22             EXIT WHEN ln_DelCount = 0;
    23
    24             COMMIT;
    25
    26     END LOOP;
    27
    28  END;
    29  /
    10000
    10000
    10000
    5726
    0
    PL/SQL procedure successfully completed.
    SQL>HTH
    David
    Message was edited by:
    david_tyler

  • How to execute commit statement in a procedure optionally?

    We have a procedure which has DML operations and at the end there is a commit statement.
    I want to execute commit statement optionally.
    Like, when procedure runs directly it must execute commit statement, but when this procedure is called from a trigger don't run commit.
    As you know commit operation is not allowed in triggers.
    How can I understant the code is triggered from a trigger or any other (manuel exec or from another procedure).
    I am looking for the reserved word that solve my problem. Like INSERTING, DELETING ....
    Serkan
    Thanks.

    Hi oraserkan,
    You do of course know it's dangerous to have a commit inside a procedure?
    Consider this:
    SQL> create table t (text varchar2(25))
    Table created.
    SQL> create or replace procedure p
    as
    begin
       insert into t(text)
           values ('Insert PROCEDURE');
       commit;
    end p;
    Procedure created.
    SQL> insert into t(text)
        values ('Insert SQL')
    1 row created.
    SQL> exec p
    PL/SQL procedure successfully completed.
    SQL> rollback
    Rollback complete.
    SQL> select * from t
    TEXT                    
    Insert SQL              
    Insert PROCEDURE        
    2 rows selected.You should instead clearly state the procedure has a commit by making it autonomous, and then have two procedures, one that commits, and one that don't
    SQL> drop procedure p
    Procedure dropped.
    SQL> drop table t purge
    Table dropped.
    SQL> create table t (text varchar2(25))
    Table created.
    SQL> create or replace procedure p_transactional
    as
    begin
       insert into t(text)
           values ('Insert PROCEDURE');
    end p_transactional;
    Procedure created.
    SQL> create or replace procedure p_autonomous
    as
       pragma autonomous_transaction;
    begin
       p_transactional;
       commit;
    end p_autonomous;
    Procedure created.
    SQL> insert into t(text)
        values ('Insert SQL')
    1 row created.
    SQL> exec p_autonomous
    PL/SQL procedure successfully completed.
    SQL> rollback
    Rollback complete.
    SQL> select * from t
    TEXT                    
    Insert PROCEDURE        
    1 row selected.
    SQL> drop procedure p_transactional
    Procedure dropped.
    SQL> drop procedure p_autonomous
    Procedure dropped.
    SQL> drop table t purge
    Table dropped.Regards
    Peter

  • PL/SQL Procedure Calling Java Host Command Problem

    This is my first post to this forum so I hope I have chosen the correct one for my problem. I have copied a java procedure to call Unix OS commands from within a PL/SQL procedure. This java works well for some OS commands (Eg ls -la) however it fails when I call others (eg env). Can anyone please give me some help or pointers?
    The java is owned by sys and it looks like this
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "ExecCmd" AS
    //ExecCmd.java
    import java.io.*;
    import java.util.*;
    //import java.util.ArrayList;
    public class ExecCmd {
    static public String[] runCommand(String cmd)
    throws IOException {
    // set up list to capture command output lines
    ArrayList list = new ArrayList();
    // start command running
    System.out.println("OS Command is: "+cmd);
    Process proc = Runtime.getRuntime().exec(cmd);
    // get command's output stream and
    // put a buffered reader input stream on it
    InputStream istr = proc.getInputStream();
    BufferedReader br = new BufferedReader(new InputStreamReader(istr));
    // read output lines from command
    String str;
    while ((str = br.readLine()) != null)
    list.add(str);
    // wait for command to terminate
    try {
    proc.waitFor();
    catch (InterruptedException e) {
    System.err.println("process was interrupted");
    // check its exit value
    if (proc.exitValue() != 0)
    System.err.println("exit value was non-zero: "+proc.exitValue());
    // close stream
    br.close();
    // return list of strings to caller
    return (String[])list.toArray(new String[0]);
    public static void main(String args[]) throws IOException {
    try {
    // run a command
    String outlist[] = runCommand(args[0]);
    for (int i = 0; i < outlist.length; i++)
    System.out.println(outlist);
    catch (IOException e) {
    System.err.println(e);
    The PL/SQL looks like so:
    CREATE or REPLACE PROCEDURE RunExecCmd(Command IN STRING) AS
    LANGUAGE JAVA NAME 'ExecCmd.main(java.lang.String[])';
    I have granted the following permissions to a user who wishes to run the code:
    drop public synonym RunExecCmd
    create public synonym RunExecCmd for RunExecCmd
    grant execute on RunExecCmd to FRED
    grant javasyspriv to FRED;
    Execute dbms_java.grant_permission('FRED','java.io.FilePermission','/bin/env','execute');
    commit
    Execute dbms_java.grant_permission('FRED','java.io.FilePermission','/opt/oracle/live/9.0.1/dbs/*','read, write, execute');
    commit
    The following test harness has been used:
    Set Serverout On size 1000000;
    call dbms_java.set_output(1000000);
    execute RunExecCmd('/bin/ls -la');
    execute RunExecCmd('/bin/env');
    The output is as follows:
    SQL> Set Serverout On size 1000000;
    SQL> call dbms_java.set_output(1000000);
    Call completed.
    SQL> execute RunExecCmd('/bin/ls -la');
    OS Command is: /bin/ls -la
    total 16522
    drwxrwxr-x 2 ora9sys dba 1024 Oct 18 09:46 .
    drwxrwxr-x 53 ora9sys dba 1024 Aug 13 09:09 ..
    -rw-r--r-- 1 ora9sys dba 40 Sep 3 11:35 afiedt.buf
    -rw-r--r-- 1 ora9sys dba 51 Sep 3 09:52 bern1.sql
    PL/SQL procedure successfully completed.
    SQL> execute RunExecCmd('/bin/env');
    OS Command is: /bin/env
    exit value was non-zero: 127
    PL/SQL procedure successfully completed.
    Both commands do work when called from the OS command line.
    Any help or assistance would be really appreciated.
    Regards,
    Bernard.

    Kamal,
    Thanks for that. I have tried to use getErrorStream and it does give me more info. It appears that some of the commands cannot be found. I suspected that this was the case but I am not sure about how this can be as they all appear to reside in the same directory with the same permissions.
    What is more confusing is output like so:
    SQL> Set Serverout On size 1000000;
    SQL> call dbms_java.set_output(1000000);
    Call completed.
    SQL> execute RunExecCmd('/usr/bin/id');
    OS Command is: /usr/bin/id
    exit value was non-zero: 1
    id: invalid user name: ""
    PL/SQL procedure successfully completed.
    SQL> execute RunExecCmd('/usr/bin/which id');
    OS Command is: /usr/bin/which id
    /usr/bin/id
    PL/SQL procedure successfully completed.
    Regards,
    Bernard

  • List of values to PL/SQL procedure

    I want to execute a query of the form
    UPDATE myTable
    SET myField = someValue
    WHERE myTablePK IN (1, 3, 5, 7, 9)
    Through HTML, I have a form field that is a comma-delimited list of values. I want to be able to pass this to a stored proc. What I'm not understanding is how to pass a list of values.
    In other words, the form should be:
    UPDATE myTable
    SET myField = someValue
    WHERE myTablePK IN (someList)
    What data type should "someList" be? How do I pass it? The number of values in the list is variable and cannot be determined at design-time.

    Here is an example how to pass a list of values as an input to a stored procedure using dynamiv SQL:
    TAPAS>create or replace procedure create_my_view( dept_list IN VARCHAR2)
    2 authid CURRENT_USER
    3 AS
    4 sql_stmt VARCHAR2(1000);
    5 begin
    6 sql_stmt := 'create or replace view my_view as select deptno from emp where deptno in ('&#0124; &#0124; dept_list&#0124; &#0124;')';
    7 execute immediate sql_stmt;
    8 exception
    9 when others then
    10 dbms_output.put_line(SQLERRM);
    11 end;
    12 /
    Procedure created.
    TAPAS>exec create_my_view('10,20');
    PL/SQL procedure successfully completed.
    TAPAS>select * from my_view;
    DEPTNO
    10
    10
    10
    10
    10
    20
    20
    20
    20
    20
    20
    20
    20
    20
    14 rows selected.

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

  • After executing sql from batch, its disconnecting

    Hello All,
    I have written a batch program to execute a pl/sql procedure. But after execution, it disconnects.
    But i want to continue in the same session
    echo exec tracer.trace_pck.start_('alter session set sql_trace=true') | sqlplus hr/hr
    Output:
    Press any key to Enable Tracing
    SQL*Plus: Release 11.2.0.2.0 Production on Thu Oct 10 15:59:56 2013
    Copyright (c) 1982, 2010, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
    SQL>
    PL/SQL procedure successfully completed.
    SQL> Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 -
    Production
    Trace Enabled Successfully. Press any key to input you sql

    If you are using a batch file I assume you are using the windows OS.
    Essentially what you need to do is to call a sql file from the batch file and then get the sql file to call all the other files.
    Batchfile test.bat  calls sql file test.sql
    sqlplus  <username>/password @test.sql
    test.sql calls test1.sql and test2.sql and then exits
    @test1.sql;
    @test2.sql;
    exit;
    test1.sql shows the current sid, and serial# fro our session and our filename
    select 'test1',sid,serial# from v$session
    where audsid=userenv('sessionid');
    test2.sql shows the current sid, and serial# for our session and our filename
    select 'test2',sid,serial# from v$session
    where audsid=userenv('sessionid');
    When you run this you get t output similar to the following: (Your SID and Serial# will be different )
    'TEST        SID    SERIAL#
    test1        771         97
    'TEST        SID    SERIAL#
    test2        771         97
    This shows that two separate sql files were called but are still in the same session

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

  • Passing arrays through multiple PL/SQL procedures and functions

    I am maintaining a large PL/SQL application. There is a main procedure that is initially called which subsequently passes information to other PL/SQL functions and procedures. In the end an error code and string is passed to PUT_LINE so it can be displayed. What I would like to be able to do is have an array that stores an error code and string for each error that it comes upon during going through each of the procedures and functions. This would involve passing these codes and strings from function to function within the pl/sql application. What would be the best way to implement this and is it possible to pass arrrays or records to other PL/SQL functions? Thanks.

    Here is one simulation ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.20
    satyaki>
    satyaki>
    satyaki>create or replace type n_array is table of number;
      2  /
    Type created.
    Elapsed: 00:00:07.10
    satyaki>
    satyaki>CREATE OR REPLACE PROCEDURE Get_Array(array_in IN n_array,
      2                                        array_out OUT n_array)  
      3  IS
      4  BEGIN 
      5    array_out := n_array(); 
      6    FOR i IN 1..array_in.count 
      7    LOOP 
      8      array_out.extend; 
      9      array_out(i) := array_in(i) * 2; 
    10    END LOOP;
    11  END Get_Array;
    12  /
    Procedure created.
    Elapsed: 00:00:00.89
    satyaki>
    satyaki>
    satyaki>Create or Replace Procedure Set_Array(myArray IN n_array)
      2  is  
      3    i   number(10);  
      4    rec emp%rowtype;  
      5    w n_array:=n_array(1200,3200);
      6    bucket n_array := n_array();
      7  Begin
      8    Get_Array(w,bucket);  
      9   
    10    for i in 1..myArray.count  
    11    loop 
    12      select *  
    13      into rec 
    14      from emp 
    15      where empno = myArray(i); 
    16      dbms_output.put_line('Employee No:'||rec.empno||' Name:'||rec.ename);
    17      for j in 1..bucket.count
    18      loop
    19        dbms_output.put_line('Commission Sub Type: '||bucket(j));
    20      end loop;
    21    end loop; 
    22  End Set_Array;
    23  /
    Procedure created.
    Elapsed: 00:00:01.33
    satyaki>
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          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       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:00.28
    satyaki>
    satyaki>declare
      2    v n_array:=n_array(9999,7777);  
      3  begin  
      4    Set_Array(v);  
      5  end;
      6  /
    Employee No:9999 Name:SATYAKI
    Commission Sub Type: 2400
    Commission Sub Type: 6400
    Employee No:7777 Name:SOURAV
    Commission Sub Type: 2400
    Commission Sub Type: 6400
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.15
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • Subscriber PL/SQL procedure runs as SYS instead of user

    I am trying to figure out why the PL/SQL procedures ran via the AQ subscription are running as user SYS instead of the user that created the subscriber and registered the procedure. Following is the script I used to add the subscriber and register the procedure. All this happens under user SCOTT. The creation of the queues happened under SCOTT as well. The enqueing of the message happens via a procedure in SCOTT, initiated by SCOTT. Scott also has
    GRANT execute ON dbms_aq to SCOTT;
    GRANT execute on dbms_aqadm to SCOTT;
    --ADD SUBSCRIBERS AND REGISTER THE QUEUES
    begin
    dbms_aqadm.add_subscriber
    (queue_name => 'in_drv_queue',
    subscriber => sys.aq$_agent('XML_drv', null, null),
    rule => 'tab.user_data.queue_type = ''XML''' );
    dbms_aqadm.add_subscriber
    (queue_name => 'in_drv_queue',
    subscriber => sys.aq$_agent('nonXML_drv', null, null),
    rule => 'tab.user_data.queue_type = ''NON XML''' );
    end;
    begin
    dbms_aq.register
    (sys.aq$_reg_info_list
    (sys.aq$_reg_info('in_drv_queue:XML_drv',
    DBMS_AQ.NAMESPACE_AQ,
    'plsql://scott.dequeue_xml',
    HEXTORAW('FF')) ),
    1);
    dbms_aq.register
    (sys.aq$_reg_info_list
    (sys.aq$_reg_info('in_drv_queue:nonXML_drv',
    DBMS_AQ.NAMESPACE_AQ,
    'plsql://scott.dequeue_nonxml',
    HEXTORAW('FF')) ),
    1);
    commit;
    end;
    Can anyone provide any suggestions as to why the two dequeue_ procedures run as SYS instead of SCOTT? I'm not sure what I am missing from the various examples I have read.
    Thanks
    Jason

    I'm not familiar with the Audit Trail you refer to, but the following is one possible option to know what user the session is "running as"
    SQL> select sys_context('userenv','client_info') from dual;
    SYS_CONTEXT('USERENV','CLIENT_
    SQL>
    SQL> begin
      2     dbms_application_info.set_client_info('Testing');
      3  end;
      4  /
    PL/SQL procedure successfully completed
    SQL> select sys_context('userenv','client_info') from dual;
    SYS_CONTEXT('USERENV','CLIENT_
    Testing

  • Can some selection conditions as PL/SQL procedure input parameters

    Dear All,
    I need to write a PL/SQL procedure so as to compute the different query only by changing the input parameters. But those input parameters need to be like a PL/SQL table selection conditions. Like:
    one of the query I need two conditions:
    customers.zip = 60606
    customers.zip = employees.zipMy procedure can compute the query like:
    select customers.cno, cname, employees.eno, ename
    from customers, orders, employees
    where customers.cno = orders.cno and
          employees.eno = orders.eno and
          C; 
    where C is the conjunction of the conditions in the input parameter.
    Please help and thanks in advance!

    Well, it's easy enough to do what you want....
    SQL> conn scott/tiger
    Connected.
    SQL> CREATE OR REPLACE FUNCTION flexi_q (pn_deptno IN NUMBER, pv_string IN VARCHAR2 := NULL)
      2  RETURN sys_refcursor AS
      3    return_value sys_refcursor;
      4  BEGIN
      5    IF pv_string IS NULL THEN
      6          OPEN return_value FOR SELECT * FROM emp WHERE deptno = pn_deptno;
      7    ELSE
      8          OPEN return_value FOR 'SELECT * FROM emp WHERE deptno = :1 AND '
      9          ||pv_string USING pn_deptno; 
    10    END IF;
    11    RETURN return_value;
    12  END;
    13  /
    Function created.
    SQL> var rc refcursor
    SQL> exec :rc := flexi_q(30)
    PL/SQL procedure successfully completed.
    SQL> print rc
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM
        DEPTNO
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300
            30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850
            30
          7900 JAMES      CLERK           7698 03-DEC-81        950
            30
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400
            30
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0
            30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500
            30
    6 rows selected.
    SQL> exec :rc := flexi_q(30, 'SAL > 1400')
    PL/SQL procedure successfully completed.
    SQL> print rc
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM
        DEPTNO
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300
            30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850
            30
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0
            30
    SQL> The real question is: do you really want to do this? Fundamentally you are handing over control of your app to any nimrod who thinks they know how to write SQL. It's just about allowable for them to add simple restrictions but they could add in anything - correlated sub-queries, extravagant sorts, etc. Even if they don't deliberately exploit this hole you still have a fundamentally untunable part of your app.
    It would be much better to have some additional parameters that allows the users to choose from several off-the-peg queries. If you have a user demanding the ability to write "any report I need" I recommend talking to them. The chances are they simply have a pet query, probably embodied in an Excel spreadsheet, they run once every month. Give them a view to meet that need and they'll be happy.
    Cheers, APC

Maybe you are looking for

  • How to programmatically add rectangle to a pdf file ?

    How to programmatically add rectangle to a pdf file ? There is several page pdfs, non-vector, black and white. Users are color blind and have disabilities. To train them, one adds a rectangle at a certain lower-left point and width,height specified f

  • PDF file will not print out Special Characters

    I am currently a technician for a college and, and the customer that I am attending currently has the following Problem: I am using Adobe PRO 9 to convert my Word files to pdfs for [a New York Printing Company].... The Greek letters used in Word are

  • Max Number of items for an FI document (999) has been exceded

    Dear Guru's I hav production Bom For A ( Truck) , and now when i declare the production it gives me an ERROR :- Max Number of items for an FI document (999) has been exceded. How i can overcome this error!! Please help Regards Rahul Bhardwaj

  • 7.01 & videos downloaded from iTunes

    I had to go back down from 7.04 to 7.01 in order to import footage to FCE. So, does that mean I can't watch videos purchased from iTunes? I tried watching videos - I can see the video but can't hear the sound. Is this a case of damned if you do and d

  • Can we install premiere pro Transition 3rd party plug-ins in Elements ?

    Trying to figure out if we can installed 3rd party transitions plug-ins in Premiere elements 13 Mac. Like these from FXFactory Plugins for Final Cut Pro, Premiere Pro, After Effects and Motion