Executing in sqlplus

Hi all,
I have the following problem:
When I use sqlplus to execute a script that calls a procedure in a stored package, I get the following error:
ORA-04068: existing state of packages has been discarded
ORA-04065: not executed, altered or dropped stored procedure "my_schema.pkg_A"
ORA-06508: PL/SQL: could not find program unit being called
ORA-06512: at "my_schema.pkg_B", line 886
ORA-06512: at line 6
The procedure being called in the script is from pkg_B.
So I call another script, which invokes some procedure in pkg_A. After calling that, I can call my first script successfully. (Assuming if A was really invalid, it would've been recompiled upon being called. Thus, B, which depends on A, can now run successfully)
However, after I logout from sqlplus, and then login again and call pkg_B procedure, I get exactly the same error.
From my best knowledge, pkg_A wasn't recompiled or invalidated in between the sqlplus sessions.
Any help will be appreciated.
Thanks,
Gloria

Package A has no DDL statement, or any execute immediate statements. It has a function that is being used in the function-based indexes. It also has select statements that select from a table where the function-based index is built on.
In Package B, there are some procedures that call Package A in the where clause of a sql. Those can execute properly. However, there's one method that calls Package A directly. Something like
pkg_A.proc_1( l_var1, l_var2, l_var3 );
Thanks for the help!
Gloria

Similar Messages

  • Where is localize source file executed when sqlplus start?

    Hi,
    I need to add some parameters to my sqlplus when it start, but I don't remember where is located file executed during start sql console.
    I try find in internet, but without result..
    Furthermore, is there any file which are execute when sqlplus is closed?
    Best.

    tutus wrote:
    Yes, of course you have right - there aren't any reason. But I wonder if file won't be empty after incorrectly end spool command..
    Despite, thank you for help.What's keeping you from testing it for yourself? You could have done that in 1/4 the time you have spent on this thread. What you really need to consider is the effect of SPOOL commands that are issued by the user or scripts the user runs in the session.

  • Execute a SQLPlus command in a ksh script

    I have developped a SAP CPS  KSH script to be executed in a job chain. This script includes a command line like : sqlplus -s <user>/<password> \@<sql_file_to_be_execute>
    When I execute the script I have the error :
    ERROR: ORA-01017: invalid username/password; logon denied
    But when I logon the server with the user I used to execute the job in SAP CPS and execute exactly the same command line as below I have no error !
    What's the matter ? (The user is declared in SAP CPS security, Identification information.
    Please help. Thanks.

    Hello,
    I post here the content of the file "Redwood.lsb" : I dont' think there are specific environement variables....
    #!/bin/sh
    (C) Copyright 1993-2008 Redwood Technology B.V., Houten, The Netherlands
    $Id: redwood.lsb,v 1.17.2.1 2008-10-09 09:41:44 nils Exp $
    Redwood Scheduler startup & shutdown script
    Basic support for IRIX style chkconfig
    chkconfig: 2345 19 08
    description: Redwood Startup script
    Basic support for the Linux Standard Base Specification 1.3
    Used by insserv and other LSB compliant tools.
    BEGIN INIT INFO
    Provides: redwood
    Required-Start: $local_fs $autofs $remote_fs $network
    Required-Stop:
    Default-Start: 2 3 5
    Default-Stop: 0 6
    Short-Description: Start & Stop Scheduler
    Description: Script to start and stop the Redwood Scheduler.
    END INIT INFO
    User Definable parameters  ###########################################
    If you want to change the location where RWTAB lives you should do it here.
    RWTAB=/sapcps/704/admin/rwtab.jcs
    LOGFILE=
    if [ -z "$LOGFILE" ]
    then
      if [ -d /var/log -a -w /var/log ]
      then
        LOGFILE="/var/log/redwood.log"
      elif [ -n "$JCS_HOME" ]
      then
        LOGFILE="$JCS_HOME/redwood.log"
      else
        LOGFILE="$HOME/redwood.log"
      fi
    fi
    exec 2>> $
    Dependencies
    This script assumes that the file specified above exists.
    If it cannot find rwtab it will give an error message and quit.
    rwtab contains the following fields:
    #1          #2          #3        #4        #5       #6        #7
    <partition>:<scheduler>:<jcshome>:<orahome>:<orasid>:<twotask>:<automatic>
    You can set <twotask> to "LOCAL" or leave it blank when the orasid is a local database
    ****************************** SHELL FUNCTIONS *****************************
    OUR_NAME=`basename $0`
    findexec ()
      FINDEXEC_PROG=$1
      for d in `echo $PATH | tr : ' '`
      do
        test -x $d/$FINDEXEC_PROG && echo $d/$FINDEXEC_PROG && return 0
      done
      return 1
    checkexec()
      VAR=$1
      eval EXE="$`echo $VAR`"
    Locate posix or xpg4 binaries
    Solaris: /usr/xpg4/bin
    SCO:     /bin/posix
      if [ -x /usr/xpg4/bin/$EXE ]
      then
        EXE=/usr/xpg4/bin/$EXE
        eval $VAR=$EXE
      elif [ -x /bin/posix/$EXE ]
      then
        EXE=/bin/posix/$EXE
        eval $VAR=$EXE
      fi
      [ "`dirname $EXE`" != "" -a -x "$EXE" ] && return
      x=`findexec $EXE`
      if [ -n "$x" ]
      then
        eval $VAR=$x
       eval echo $EXE is \$$VAR >&2
        return 0
      fi
      echo "$0: Cannot locate needed executable file $EXE" >&2
      exit 1
    addOraclePath()
    Put new ORACLE_HOME in path and remove old one
    case "$OLDORA_HOME" in
        "") OLDORA_HOME=$PATH ;;    # This makes it so that null OLDORA_HOME can't match
    esac                            # anything in next case statement
    case "$PATH" in
        $OLDORA_HOME/bin)     PATH=`echo $PATH | \
                                $L_SED "s;$OLDORA_HOME/bin;$ORACLE_HOME/bin;g"` ;;
        $ORACLE_HOME/bin) ;;
        *:)                     PATH=${PATH}$ORACLE_HOME/bin: ;;
        "")                     PATH=$ORACLE_HOME/bin ;;
        *)                      PATH=$PATH:$ORACLE_HOME/bin ;;
    esac
    addJCSPath()
    Put new JCS_HOME in path and remove old one
    case "$OLDJCS_HOME" in
        "") OLDJCS_HOME=$PATH ;;    # This makes it so that null OLDJCS_HOME can't match
    esac                            # anything in next case statement
    case "$PATH" in
        $OLDJCS_HOME/bin)     PATH=`echo $PATH | \
                                $L_SED "s;$OLDORA_HOME/bin;$JCS_HOME/bin;g"` ;;
        $JCS_HOME/bin) ;;
        *:)                     PATH=${PATH}$JCS_HOME/bin: ;;
        "")                     PATH=$JCS_HOME/bin ;;
        *)                      PATH=$PATH:$JCS_HOME/bin ;;
    esac
    addpath()
    Add $1 to the path if it is not there
      DIR=$1
      [ ! -d $DIR ] && return
      case "$PATH" in
        ${DIR}:*)    return;;
        :$)    return;;
        *:$:)  return;;
        *:)          PATH=$$
                     return;;
      esac
      PATH=$PATH:$DIR
    wait_for_database()
    Wait 60 seconds until connect to database succeeds
      t=0
      while [ $t -lt 60 ]
      do
        if $JCS_HOME/bin/rs internal </dev/null >/tmp/$$.err 2>&1
        then
          $L_RM /tmp/$$.err
          return
        elif grep ORA /tmp/$$.err > /dev/null
        then
          echo "`grep ORA- /tmp/$$.err`"
          $L_RM /tmp/$$.err
          exit $?
        elif grep "JCS-00190" "/tmp/$$.err" > /dev/null
        then
          echo "Creating Scheduler: $SCHEDULER_PARTITION.$SCHEDULER_NAME"
          $JCS_HOME/bin/rs internal << EOD
    create scheduler "$SCHEDULER_PARTITION"."$SCHEDULER_NAME" serves SYSTEM;
    exit
    EOD
          $L_RM /tmp/$$.err
          return
        elif grep "JCS-" "/tmp/$$.err" > /dev/null
        then
          echo "`grep JCS- /tmp/$$.err`"
          exit $?
        fi
        sleep 1
        t=`expr $t + 1`
      done
    verify_env()
      if [ ! -f "$RWTAB" ]
      then
        echo ""
        echo "FATAL ERROR: Could not find configuration file $RWTAB!"
        echo ""
        exit 1
      fi
      addpath /bin
      addpath /usr/bin
      addpath /usr/local/bin
      addpath /opt/bin
      addpath /usr/lbin
      if [ "$JCS_HOME" != "" ]
      then
        addJCSPath $JCS_HOME/bin
      fi
      if [ "$ORACLE_HOME" != "" ]
      then
        addOraclePath $ORACLE_HOME/bin
      fi
      L_AWK=awk
      L_SED=sed
      L_HOSTNAME=hostname
      L_RM=rm
      checkexec L_AWK
      checkexec L_SED
      checkexec L_HOSTNAME
      checkexec L_RM
      export PATH
    scheduler_actions()
      verify_env
      OPERATION=$1
      cat $RWTAB | while read LINE
      do
        case $LINE in
          \#*) ;;           # Commentline in rwtab
    Proceed if 7th field is Y
            if [ "`echo $LINE | $L_AWK -F: '{print $7}' -`" = "Y" ]
            then
              SCHEDULER_PARTITION=`echo $LINE | $L_AWK -F: '{print $1}' -`
              if [ -z "$SCHEDULER_PARTITION" ]
              then
                SCHEDULER_PARTITION="SYSJCS"
              fi
              export SCHEDULER_PARTITION
              SCHEDULER_NAME=`echo $LINE | $L_AWK -F: '{print $2}' -`
              JCS_HOME=`echo $LINE | $L_AWK -F: '{print $3}' -`
              export JCS_HOME
              addJCSPath $JCS_HOME/bin
              ORACLE_HOME=`echo $LINE | $L_AWK -F: '{print $4}' -`
              export ORACLE_HOME
              addOraclePath $ORACLE_HOME/bin
              ORACLE_SID=`echo $LINE | $L_AWK -F: '{print $5}' -`
              export ORACLE_SID
              TWO_TASK=`echo $LINE | $L_AWK -F: '{print $6}' -`
              if [ "$TWO_TASK" = "LOCAL" -o -z "$TWO_TASK" ]
              then
                unset TWO_TASK
              else
                export TWO_TASK
              fi
              if [ "$SCHEDULER_NAME" = "*" ]
              then
                if [ -n "$ORACLE_SID" -o -n "$TWO_TASK" ]
                then
                  SCHEDULER_NAME=`echo \`uname -n\`_$ | tr '[a-z]' '[A-Z]'`
                else
                  SCHEDULER_NAME=`echo \`uname -n\` | tr '[a-z]' '[A-Z]'`
                fi
              fi
              export SCHEDULER_NAME
              case $OPERATION in
                "startup")
                  echo "Starting "$SCHEDULER_PARTITION"."$SCHEDULER_NAME" on `$L_HOSTNAME`"
                  wait_for_database
                  $JCS_HOME/bin/rs internal <<EOD
    startup "$SCHEDULER_PARTITION"."$SCHEDULER_NAME"
    exit
    EOD
                "shutdown")
                  echo "Stopping $SCHEDULER_PARTITION"."$SCHEDULER_NAME on `$L_HOSTNAME`"
                  $JCS_HOME/bin/rs internal <<EOD
    shutdown "$SCHEDULER_PARTITION"."$SCHEDULER_NAME"
    exit
    EOD
                "status")
                  $JCS_HOME/bin/rs internal | grep -v "JCS-00147" > /tmp/$$.tmp
                  if grep JCS- /tmp/$$.tmp
                  then
                    rm /tmp/$$.tmp
                    exit 1
                  fi
                  echo "connect internal
    set heading off
    set feedback off
    select status from rs_schedulers
    where  name      = '$SCHEDULER_NAME'
    and    partition = '$SCHEDULER_PARTITION';
    exit" > /tmp/$$.sql
                SCHEDULER_STATUS=`$JCS_HOME/bin/rs -s @/tmp/$$.sql | tail -1`
                if [ "$SCHEDULER_STATUS" = "Connected." ]
                then
                  echo "Scheduler \"$SCHEDULER_NAME\" does not exist in partition $SCHEDULER_PARTITION, check your $JCS_HOME/admin/rwtab.
    jcs"
                elif echo "$SCHEDULER_STATUS" | grep JCS- 1>/dev/null
                then
                  echo "An error occured: $SCHEDULER_STATUS"
                else
                  echo "Scheduler $SCHEDULER_PARTITION.$SCHEDULER_NAME has status: $SCHEDULER_STATUS"
                fi
                $L_RM /tmp/$$.sql
              esac
              OLDJCS_HOME=$JCS_HOME
              OLDORA_HOME=$ORACLE_HOME
              export OLDJCS_HOME
              export OLDORA_HOME
            fi
        esac
      done
    **************************** CODE STARTS HERE ******************************
    Some systems not only call us with "start" and "stop", but also with
    "start_msg" and "stop_msg"... (notably, HP-UX)
    case "$1" in
      "start_msg")
        echo "Starting Redwood (async)..."
        exit 0;;
      "stop_msg")
        echo "Stopping Redwood..."
        exit 0;;
      "start")
        echo "Starting Redwood..."
        scheduler_actions "startup"
        echo "For details see $LOGFILE..."
      "stop")
        echo "Stopping Redwood..."
        scheduler_actions "shutdown"
        echo "For details see $LOGFILE..."
      "status")
        scheduler_actions "status"
        echo "$0: Usage:
              $0 start
              $0 stop
              $0 status"
        exit 1;;
    esac

  • Execute Procedure sqlplus vs TOAD

    Hi!
    What's the reason to a procedure runs fast in TOAD but doesn't run in sqlplus?
    Thanks.

    You will have to define "doesn't run". Error message? Seems to hang?

  • Need Help: Urgent:(sqlplus: cannot execute)

    Hi,
    This is the content in my .profile on a unix server,
    MAIL=/usr/mail/${LOGNAME:?}
    umask 027 #added by enRole Agent
    PATH=${PATH}:/opt/app/p1crm1c3/informatica/oracle/product/10.2.0
    export PATH
    PATH=$PATH:/opt/app/p1crm1c3/informatica/oracle/product/10.2.0/network/admin/sqlnet.ora;export PATH
    ORACLE_HOME=/opt/app/p1crm1c3/informatica/oracle/product/10.2.0
    export ORACLE_HOME
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/bin
    The paths are set correctly, however when i try to login to the server through the below line,
    sqlplus username/password@oracleservername
    ksh: sqlplus: cannot execute
    It says, sqlplus cannot execute.. Please help me out with this! :( :(

    please execute: which sqlplus to see if you can reach sqlplus. probably you can, because otherwise the shell can not determine it can not execute.
    execute: id to determine your current user and groups.
    execute: ls -ls $(which sqlplus) to determine security settings of sqlplus.
    my guess would be you are not allowed to execute sqlplus.

  • Executing SQLPLUS command from Stored Procedure

    Hi,
    I am trying to execute the SQLPLUS command (CONNECT) from the stored procedure.
    It is throwing below error message.
    Stored Procedure:
    SQL> select user from dual
    2 ;
    USER
    SYS
    SQL> create or replace
    2 PROCEDURE PROCEDURE1 AS
    3 BEGIN
    4 sqlplus sys/sys@D as sysdba;
    5 --execute immediate 'create user 'kkk' identified by 'kkk';
    6 END PROCEDURE1;
    7 /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE PROCEDURE1:
    LINE/COL ERROR
    3/9 PLS-00103: Encountered the symbol "SYS" when expecting one of the
    following:
    := . ( @ % ;
    The symbol ":=" was substituted for "SYS" to continue.
    3/22 PLS-00103: Encountered the symbol "AS" when expecting one of the
    following:
    . ( * @ & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
    LIKE4_ LIKEC_ between || member SUBMULTISET_
    The symbol ". was inserted before "AS" to continue.
    Please let me know whether it is possible to do or not.
    If there is possiblility how can does this be done?
    Edited by: NGK246 on Aug 28, 2012 2:21 AM

    NGK246 wrote:
    Hi,
    I am trying to execute the SQLPLUS command (CONNECT) from the stored procedure.
    It is throwing below error message.
    It would not. It will always throw an error. SQLPLUS is a Utility and not a Command/Construct, that it would be available for a Stored Procedure
    >
    SQL> select user from dual
    2 ;
    USER
    SYSWhich Database are you onto? Is it DMIP?
    SQL> create or replace
    2 PROCEDURE PROCEDURE1 AS
    3 BEGIN
    4 sqlplus sys/sys@DMIP as sysdba;
    5 --execute immediate 'create user 'kkk' identified by 'kkk';
    6 END PROCEDURE1;
    7 /
    Warning: Procedure created with compilation errors.
    SQL> show err
    Errors for PROCEDURE PROCEDURE1:
    LINE/COL ERROR
    3/9 PLS-00103: Encountered the symbol "SYS" when expecting one of the
    following:
    := . ( @ % ;
    The symbol ":=" was substituted for "SYS" to continue.
    3/22 PLS-00103: Encountered the symbol "AS" when expecting one of the
    following:
    . ( * @ & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
    LIKE4_ LIKEC_ between || member SUBMULTISET_
    The symbol ". was inserted before "AS" to continue.
    Please let me know whether it is possible to do or not.
    If there is possiblility how can does this be done?If you are at DMIP, you need not Login again. You can Login Manually to the Database and Execute the Procedure (in which you intend to create a User 'kkk').
    However, if you are trying to Create a User in a Different Database, You will first require a DB Link to exist to connect to the Remote Database. You will also require Explicit privileges to create any user (Although I am not sure if you can create User onto a different Database.)
    I would like to ask you, why are you creating a User on a Remote database? Can you not execute the same procedure on the Remote database and create User? Also, you are using SYS login to perform the activity. Ideally it should not be allowed. You must create a user and grant DBA rights to perform such activities.

  • Execute *.bat in pl/sql

    is this possible.
    say i have a.sql which will be executing by SQLPLUS
    content of a.sql
         SELECT count(id)
         INTO CTR
         FROM table
         WHERE_condition;
         WHILE CTR>0 LOOP
              SELECT paymtnum
              INTO PYMT_NO
              FROM table2
              WHERE id=CTR;
              EXEC :='C:\B.BAT ' || PYMT_NO ;
              CTR := CTR - 1;
         END LOOP;
    summary, i wanna call B.bat in a.sql.
    please help.

    Hi,
    you have to use
    htp.p('<SCRIPT LANGUAGE="Javascript1.1">
    document.all("FORMNAME.DEFAULT.ATTRIBUTENAME.01").value="'||DNAME1||'";
    document.all("FORMNAME.DEFAULT.ATTRIBUTENAME.01").value="'||LOC1||'";
    </SCRIPT>
    instead of
    DBMS_OUTPUT.PUT_LINE (DNAME1);
    DBMS_OUTPUT.PUT_LINE (LOC1);
    where formname is your form name and attribute name is the field name on the page.

  • Mapping a logical path to a real unix path in sqlplus.

    hi everyone
    Please, I trying to run a windows application that uses an oracle ex db over wine in a linux box .
    The scenario is:
    Linux -> wine -> win App -> Oracle xe(linux version)! So the win app will be dealing with a native linux version of oracle xe.
    At certain point some sql script need to be executed by sqlplus.
    The command is: sqlplus /NOLOG @F:\some\path\script.sql.
    The problem is that I have F:/ mapped in wine to /some/path but it is not mapped in sqlplus, so sqlplus cannot find the script. My question is, is that a way (by using an environment variable or by any other way) to create a
    map like that F:\ -> /some/path, so every time sqlplus try to execute a script in F:\ it looks at /some/path?
    Great regards
    Guilherme Longo

    Hi,
    I do not have answer.
    I just like know why you run database with Wine ? You can install Linux native one
    Regards,
    Jari

  • Running process flow from sqlplus

    hi everyone,
    using sqlplus_exec_template.sql to run process flow.
    but message keeps appearing that task is not found
    I have an oracle workflow repository on another server.
    what should I use as parameters?
    for example location name?
    thank you
    owen veeneman

    Hi
    If you can create the Process Flow code, you can deploy and execute from SQLPLUS as follows.
    1. First you have to compile the package from SQLPLUS into you target get schema. For example. SQL>@c:\package.pls.
    2. Then find out the prarmeter from function main of the package. Write a simple code as follows and run it from SQL. Just substitute whatever applicable to you.
    declare
    V_PROCESS_CODE           VARCHAR2(10);
    V_FREQUENCY_CODE     VARCHAR2(1);
    V_RETCODE                NUMBER(10);
    V_WB_RT                WB_RT_MAPAUDIT.WB_RT_NAME_VALUES;
    begin
    V_PROCESS_CODE := 'CF_SUMM’;
    V_FREQUENCY_CODE := 'D';
    v_retcode := DM_CASHFLOW_SUMM_MAP.main(V_PROCESS_CODE, V_FREQUENCY_CODE, V_WB_RT);
    dbms_output.put_line(v_retcode || ' Retcode.');
    end;

  • Log all SQLPLUS.EXE queries into a table

    Hi,
    I want to trace all SQLPLUS activities executed by any user , I tried using V$Session and V$SQLAREA but not much helpful as V$Session is a dynamic view.
    I need to capture all sql commands executed from sqlplus.exe prompt.
    Need your expert advice for same .
    Regards,

    Hi,
    My Database size is around 2 TB , moreover i dont want to trace the application activities .
    As direct access to SQLPLUS is limited , only requirement is to trace SQL commands run on SQLPLUS prompt .
    Auditing will audit all activities including application .Lookng for some solution which will provide SQL_TEXT of progam SQLPLUS only.
    Regards,

  • Aix Os User On Sqlplus

    Hi
    I have this command i execute in sqlplus (command for trace analyser) :
    exec trca$i.trace_analyzer('aquest01_ora_852076.trc','aquest01_ora_852076.html');
    This command analyse my trace file and generated the html file.
    When i execute this command with my Os Oracle User, it works perfectly.
    When i execute this command with Os Root User, it doesn't work.
    I have this error :
    ORA-22288 : file or LOB operation FILEEXISTS failed
    Permission denied
    I asked myself why and then i try to see when i am connected on sqlplus, which osuser is in the v$session.
    So i run the command :
    select osuser from v$session where audsid = userenv('SESSIONID');
    When i am with Oracle Os user, the osuser returns Oracle.
    When i am with Root Os user, the osuser returns daemon.
    So, it seems that daemon user cannot handle the fact he has to write a new file (the html one), i don't understand why !!!
    And i don't understand why the os user is daemon and not root.
    If someone has an explanation, i take it.
    Thanks

    Hi
    First, in both cases, i use : sqlplus "myuser/mypwd".
    And of course, same user when i test for Oracle or Root.
    I totally agree with the fact that Root as no right to connect via "sqlplus /nolog" and we do the same thing as u said : a simple su - Oracle to run a sql command.
    I have an history for this problem. The command i launch "trca$i.ana ...." is in a package. This package is called by .net program. And when i execute it with the .net, this error comes.
    That's why now i test directly on aix with this simple test.
    And yes, the end of error is :
    Cannot determine if trace file aquest01_ora_852076.trc exists on /Ora_log/aquest01/udump
    Thanks.

  • Sqlplus sqlprompt

    Does anyone know how to change the sqlplus sqlprompt to display the db_name or the SID? I use both NT and Unix environments.
    Thanks
    SGilbert

    For UNIX, in the ORACLE_HOME/sqlplus/admin
    directory, there is a file - glogin.sql that
    executes for a sqlplus session initiated on UNIX.
    As, sys, grant your users select on
    v_$database (table) and insert "select name from v$database" (v$database being the view)
    and this will execute for each session.
    You can do this for v_$session, etc. I believe there is a similiar script that executes for sqlplus clients on NT and UNIX,
    but I do not know offhand where/what it is. I would be interested in knowing.

  • Getting return value from sqlplus script while running a unix job

    I am trying to run a unix script that calls sqlplus. The following code outlines the unix/sql code that I trying to execute:
    return_count=`sqlplus $ORACLE_ID/$ORACLE_PWD@$ORACLE_SID <<EOF | grep '^RETURN_VAL' | sed 's/^RETURN_VAL//'
    SET SERVEROUTPUT ON
    VARIABLE ReturnValue NUMBER
    EXEC :ReturnValue := 1
    BEGIN
    UPDATE seq_control_nbr
    SET table_seq_nbr = table_seq_nbr + 1,
    last_updt_dttmstp = systimestamp,
    last_updt_user_id = 'ECVMSONS'
    WHERE table_key = 'ONSTAR';
    IF SQL%ROWCOUNT = 1 THEN
    COMMIT;
    :ReturnValue := 0;
    ELSE
    ROLLBACK;
    :ReturnValue := 99;
    END IF;
    DBMS_OUTPUT.PUT_LINE ('RETURN_VAL '||:ReturnValue);
    END;
    EXIT
    EOF`
    The above outlined sqlplus script does run because the values on the table are updated. However, I cannot get the value of ReturnValue to be displayed, so it can be returned to the unix script.
    Any ideas?

    ok do the following:-
    return_count=`sqlplus $ORACLE_ID/$ORACLE_PWD@$ORACLE_SID <<EOF
    SET SERVEROUTPUT ON
    whenever OSERROR exit 1
    whenever SQLERROR exit 2
    UPDATE seq_control_nbr
    SET table_seq_nbr = table_seq_nbr + 1,
    last_updt_dttmstp = systimestamp,
    last_updt_user_id = 'ECVMSONS'
    WHERE table_key = 'ONSTAR';
    EXIT
    EOF`
    rowsupdated=`echo $return_count|cut -f1 -d' '`
    echo "Rows updated =" $rowsupdated
    retcode=`echo $?`
    case "$retcode" in
    0) echo "Update executed successfully on " ;;
    1) echo "Update failed OSERROR ";;
    2) echo "Update failed SQLError " ;;
    *) echo "Update failed - Unknown Error ";;
    esac

  • Oracle sqlplus default setting

    Hi,
    Is there any way to have a particular setting by defult in oracle sqlplus. I am giving you the example of the problem:-
    SQL> select 1234567891011111 from dual;
    1234567891011111
    1.2346E+15
    SQL> column a format 9999999999999999999999999
    SQL> select 1234567891011111 a from dual;
    A
    1234567891011111
    From the above queries by default when I'm executing the query then E is coming for large values. Now I've formatted the column and got the actual value. Now my question is, can I set this by default the specific value or always I'll have to do it explicitly from sqlplus prompt.
    Thanks & Regards,
    Sudipta

    You can add this entry to glogin.sql file which is executed when sqlplus is started
    column a format 9999999999999999999999999
    This file is located on $ORACLE_HOME/sqlplus/admin/
    Best Regards
    Krystian Zieja / mob

  • Exec SQLPLUS command from PL/SQL Block

    Good Morning:
    How I can execute a SQLPLUS command (like SPOOL or DESCRIBE) from PL/SQL Block Procedure?:
    DECLARE
    BEGIN
    ls_command = 'DESCRIBE '||ls_table_name;
    EXECUTE SQLPLUS(ls_command);
    END;
    Thanks a lot for any idea.

    That's correct.
    However, in the case of the given example we can use DBMS_DESCRIBE package to get table descriptions. And we can use UTL_FILE to spool PL/SQL stuff to a file.
    Cheers, APC

Maybe you are looking for