WHENEVER SQLERROR Problem

Below is my sql saved as testing.sql
SET PAGESIZE 0
WHENEVER SQLERROR EXIT SQL.SQLCODE;
WHENEVER OSERROR EXIT SQL.OSCODE;
SPOOL /u021/idaho/load_scripts/ebiz_ctgry_prodfam/build_ebiz_ctgry_prodfam_1.og
select
productid,
categoryid,
sequence,
inherit
from site.categoryproduct@TO_EBIZ_DBLINK1
SPOOL OFF
exit
The issue is that code is working as expected on AIX but not on SUN Solaris, here the DBLINK used is invalid one and the select should fail.
AIX Server output:*
sqlplus -s userid/password @testing.sql
from site.categoryproduct@TO_EBIZ_DBLINK1
ERROR at line 13:
ORA-02019: connection description for remote database not found
113620 spss7a04:/u021/idaho/load_scripts/ebiz_ctgry_prodfam> echo $?
*227*
Solarix Server output:*
from site.categoryproduct@TO_EBIZ_DBLINK1
ERROR at line 13:
ORA-02019: connection description for remote database not found
4143 v08k44:/u021/idaho/load_scripts/ebiz_ctgry_prodfam> echo $?
*0*
The question is why in solaris $? returning 0. I have also tried WHENEVER SQLERROR EXIT FAILURE ; option but even that is not working. Also any help in fixing this would be appreciated.

It doesn't have to be 'EOF', it can be any token (I know that doesn't help you here).
I don't know if there's any other option for you here, I've always found it good practice to use a terminating token regardless of the particular shell. It seems you are going to have to make a change to get this to port properly in any case, so you may have no choice, however laborious that might be.
Edit you may be better asking this question in a shell scripting forum, for example: [http://www.unix.com/shell-programming-scripting/], and in which case you can close this one off.

Similar Messages

  • Problems with WHENEVER SQLERROR

    I'm creating a PRO C application, and I'm having problems with the use of WHENEVER SQLERROR DO <function>.
    I've got this function: void mensajeDeError(int error); defined in a static library, and compiles perfectly, but when I try to call it from a program, I get this warning message:
    warning: improper pointer/integer combination: arg #1
    I've checked the call to the function a lot of times, but I haven't got any solution, because it's right.
    I've realized, that this funcion (if you put in into a structure of WHENEVER SQLERROR DO), only works if you pass a char* as a parameter too, but not with the rest of stardard types of variables (f.e. ints, floats, etc.,)
    I hope you give me a solution.
    Thank you.
    Juan Carlos.

    EXEC SQL WHENEVER SQLERROR DO sql_error();
    void sql_error()
    char msg[512];
    size_t buf_len, msg_len;
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    buf_len = sizeof(msg);
    sqlglm(msg, &buf_len, &msg_len);
    printf("\nOracle error detected:");
    printf("\n%.*s \n", msg_len, msg);
    EXEC SQL ROLLBACK WORK RELEASE;
    exit(1);
    }Hope this help.
    Thomas Devalli.
    KSI Int'l
    [mailto][email protected][mailto]
    www.ksi.be
    null

  • Whenever sqlerror exit failure rollback in IDE's

    Hi all,
    Sorry to cross-post, but there is a tendancy for people who have a bunch of Expertise in SQL/PL/SQL to not check other forums all that often so I am hoping for more results here.
    I've started a thread over here:
    deployment scripts with "exit failure rollback"
    The basic problem is that when I have a SQLplus script with
    whenever sqlerror exit failure rollbackBut when this is executed through an IDE like toad or SQL developer the IDE appears to ignore the exit command and continues executing the script regardless of any errors.
    Has anyone encountered this problem previously and have a solution? or must I beat my deployment manager over the head to convince him to always use SQLPlus for database deployments?

    WhiteHat wrote:
    Hi all,
    Sorry to cross-post, but there is a tendancy for people who have a bunch of Expertise in SQL/PL/SQL to not check other forums all that often so I am hoping for more results here.
    I've started a thread over here:
    deployment scripts with "exit failure rollback"
    The basic problem is that when I have a SQLplus script with
    whenever sqlerror exit failure rollbackBut when this is executed through an IDE like toad or SQL developer the IDE appears to ignore the exit command and continues executing the script regardless of any errors.
    Has anyone encountered this problem previously and have a solution? or must I beat my deployment manager over the head to convince him to always use SQLPlus for database deployments?"WHENEVER" is sqlplus (only) syntax.
    Either only code to work with any/every client or only use sqlplus

  • WHENEVER SQLERROR does not work for remote db?

    Hi,
    I've encountered a problem that an error on a remote db (called via db link) does not force SQL*PLUS to exit and report the error.
    Local machine: Sun Solaris
    Local db: 8.1.7.2
    Remote machine: Windows NT, 2000 or XP (I don't know).
    Remote db: 9.2.0.5
    Call to SQL*PLUS: sqlplus /NOLOG @$BASE_DIR/tools/bin/xxx.sql
    Relevant piece of code in xxx.sql:
    connect cemis/cemis@loc9280
    whenever sqlerror exit SQL.SQLCODE
    set heading off
    set trimspool on
    SET PAGES 0
    SET LINESI 250
    SET ECHO OFF
    SET VERIFY OFF
    set termout off
    set feedb off
    set recsep off
    rem *** Do the work ***
    whenever sqlerror exit SQL.SQLCODE
    rem Get rid of old data
    TRUNCATE TABLE local_table;
    rem fill table via db-link
    INSERT INTO local_table
    col1,
    col2
    SELECT
    rem_col1,
    rem_col2
    FROM rem_user.rem_table@dbl_name
    COMMIT;
    spool file.csv
    SELECT 'Spalte1' || chr(9) || 'Spalte2'
    FROM dual;
    SELECT col1, col2 FROM local_table;
    spool off
    exit 0
    In our environment the script runs through without any error. After execution the file.csv is not there. No errors in the log file.
    I tried to select data from the remote db manually and ran into this:
    'ORA-01017: invalid username/password; logon denied' followed by
    'ORA-02063: preceding line from dbl_name'.
    Do you have any idea why this error does not cause sql*plus to exit?
    Does the WHENEVER... only work properly with local errors?
    I would be grateful for any information regarding this.
    Regards,
    Guido

    I believe this is a limitation in SP3, but tell me, are you running with a simple producer or a complex producer?

  • How to use the WHENEVER SQLERROR EXIT statement in a PL/SQL block.

    Hi,
    I am getting the following error when trying to add the following statement in an PL/SQL block.
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    [exec] ERROR at line 23:
    [exec] ORA-06550: line 23, column 12:
    [exec] PLS-00103: Encountered the symbol "SQLERROR" when expecting one of the
    [exec] following:
    [exec] := . ( @ % ;
    How can i use the above statement in the PL/SQL Block? I have only IF statement in that block( between BEGIN and END).
    Thanks

    Hi,
    Usually there's always more than one solution.
    Can you post an example of what you're trying to accomplish?
    That would be useful.
    (Place the tag before and after your example to maintain formatting en spacing, see the [fac|http://forums.oracle.com/forums/help.jspa] regarding available tags)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • WHENEVER SQLERROR EXIT SQL.SQLCODE||SQLERRM  & Relate ORA-ERRNO & SQLCODE

    Hi,
    Is there any way to pass both the SQL.SQLCODE & SQLERRM to the os back ??
    When I tried WHENEVER SQLERROR EXIT SQL.SQLCODE
    The actual oracle error code (ORA-00942) and the error code (174 ) returned by SQL.SQLCODE are different . So how can I get the info. that is related to SQL.SQLCODE
    eg :
    For this test program
    rm -f /home/etladm/test/test.log
    sqlplus -S <<EOF >> /home/etladm/test/test.log
    ranjeeshk/ics
    set verify on time on timing on term on echo on feedback on serveroutput on
    WHENEVER SQLERROR EXIT SQL.SQLCODE
    -- WHENEVER SQLERROR EXIT SQLERRM
    select sysdate sdate from dua;
    exit 1
    EOF
    echo "Number of rows are: $?" >> /home/etladm/test/test.log
    echo " -------- Log file -------- \n"
    cat /home/etladm/test/test.log
    The output was
    etladm@stdwdev2:/home/etladm/test>. ./test.ksh
    -------- Log file --------
    select sysdate sdate from dua
    ERROR at line 1:
    ORA-00942: table or view does not exist
    Number of rows are: 174
    etladm@stdwdev2:/home/etladm/test>
    So how can I link ORA-00942 and SQLCODE 174 ?
    with thanks in advance
    Ranjeesh K R

    From the Oracle documentation:
    <quote>
    The range of operating system return codes is also restricted on some operating systems. This limits the portability of EXIT n and EXIT variable between platforms. For example, on UNIX there is only one byte of storage for return codes; therefore, the range for return codes is limited to zero to 255.
    </quote>

  • Where should I put WHENEVER SQLERROR CONTINUE clause?

    Hi all,
    this is my situation:
    I have 2 compiled packages and one compiled procedure which uses the 2 packages. I want to start the procedure with sql*plus.
    To do this, I wrote a script and start the script from sql*plus:
    SQL> @start_proc.sqlThe start_proc.sql script looks like this:
    SET SERVEROUTPUT ON
    SET ECHO OFF
    SET TERMOUT OFF
    WHENEVER SQLERROR CONTINUE
    SPOOL /home/scott/proc_out.txt
    BEGIN
      SCHEMA1.TEST_PR;
      COMMIT;
    END;
    SPOOL OFFThe question is, where should i put the statement WHENEVER SQLERROR CONTINUE ?
    In the current position, the procedure does not start at all. If I remove the statement completely, then I get error on the first record and the procedure does not go on with the rest of the records...

    Thanks for your follow-up, Frank.
    The bigger picture (imo, hence the "-ism") is still:
    When it comes down to error-handling, the world suddenly gets very complicated and turns into all shades of grey, for many years.
    (But actually it should be simple: quit when unexpected things happen)
    The Developer has done his/her best, based on inputs
    The DBA has done his/her best, based on inputs
    The Architect/Designer has done his/her best, based on inputs
    The Manager has done his/her best, based on inputs
    The Client/CST has done his/her best, based on being client/CST
    Funny thing is: whenever I mail/call CST asking for additional input, usually things make sense...
    I dare say: when things go wrong, let them go wrong.
    Propagate the message to another human, who probably didn't think of that/expected it to happen.

  • WHENEVER SQLERROR and 11.2.0.2.0 client

    Hi,
    Facing one issue which am not to understand further.
    One of the file say 'config.tmp' has a variable defined as follows:
    define termout = 'on';
    define SQLErrorHandling = 'continue none';In another sql file say 'myfile.sql' I read the above file as @config.tmp and then try to fetch the variable value as follows:
    @config.tmp
    execute DBMS_OUTPUT.PUT_LINE('&SQLErrorHandling');
    whenever sqlerror &SQLErrorHandling;
    set termout &termout;But am getting following error
    SQL> @myfile;
    continue none
    Usage: WHENEVER SQLERROR
         { CONTINUE  [ COMMIT | ROLLBACK | NONE ]
         | EXIT  [ SUCCESS | FAILURE | WARNING | n | <variable> | :<bindvariable> ]
                 [ COMMIT | ROLLBACK ] }
    SQL>Looks like it fails to replace the variable '&SQLErrorHandling' value. However value of '&termout' variable gets fetched.
    This issue is not seen when 11.1.0.6.0 client is used. Only when the client version is 11.2.0.2.0 am facing this issue.
    Any suggestions?
    Regards,
    Neuron
    p.s.: earlier asked this question under PL/SQL section but no helpful responses.

    Thanks guys for your replies, please find my comments so far.
    I don't understand why you have a call to execute DBMS_OUTPUT ... this is not the place for it. Write to a log file or echo to the terminal window.Thanks 'damorgan', however DBMS_OUTPUT was added from debugging perspective, to check if the value is being fetched or not. Btw that's not the intent of my post and business logic too, what am trying to figure out is why if throws 'Usage: WHENEVER SQLERROR' error only when am connected with 11.2.0.2.0 client. If you help to provide some pointers here, that will be really great.
    if you GOOGLE "SQLErrorHandling" you get a number of hits for TSQL & none for Oracle.Thanks 'SB' but sorry I did not understand your comments. Not sure why you want to GOOGLE 'SQLErrorHandling' but you can check this [url http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12052.htm]link.
    Any suggestions for usage errors?
    Regards,
    Neuron
    Edited by: Neuron on Jan 24, 2013 12:30 PM
    Edited by: Neuron on Jan 24, 2013 12:34 PM

  • Whenever sqlerror exit failure - what value is failure ?

    I have a sql*plus script file that is run from a batch file on windows. The script file starts with whenever sqlerror exit failure; But what error value is returned for failure on windows ?
    SQL*Plus documentation simply says it's "operating-system dependent values", but I can't find any other documentation saying what these values are!
    By trial & error it seems to return 1 on windows, so sets the ERRORLEVEL to 1 within the batch file.
    But are the values that SQL*Plus will return actually documented anywhere ?

    I don't remember ever seeing them documented, but they are the standard error codes for whatever OS you're using. At one time, windows help listed the error codes: 0=good, 1=failure, 2=warning; but I can't find that anymore either. and since the values are different by OS, another option is to exit with a specific value
    whenever sqlerror exit 4
    then you script becomes more portable, and you don't need to worry about changing errorcodes.

  • WHENEVER SQLERROR question

    I want a script to exit when it executes successfully and to stop when there is a error, so instead of WHENEVER SQLERROR EXIT, I want something like WHENEVER SQLERROR CONTINUE, ELSE EXIT.
    How can it be done?

    "whenever sqlerror continue" does exist and works.
    If you want to exit after the whole script is done, just add "exit"
    as the last line.
    Exiting after one successfull statement when others are following is not possible.

  • Problems With Data Alignment when spooling to a CSV file

    Dear members,
    I am spooling data to a csv file. My data contains 3 columns
    For example :
    col1 col2 col3
    USD,10000033020000000000000,-1144206.34
    The 2nd column is alphanumeric, it contains some rows which have only numbers and some which have numbers and alphabets.
    The 3rd column contains only numbers with positive or negative values.
    I am facing problem with alignment. when i open the spooled csv file then i find that the 3rd column is aligned to right .
    In the 2nd column, rows which have only numbers are right justified and rows which have alpha numeric data are left justified.
    I tried using the JUSTIFY function in sql plus but still it is not working for me.
    Can any body give your opinion on how to control the alignment in spooled csv files.
    Your responce is highly appreciated.
    Here is my code :
    WHENEVER SQLERROR CONTINUE
    SET TIMING off
    set feedback off
    set heading off
    set termout OFF
    set pagesize 0
    set linesize 200
    set verify off
    set trimspool ON
    SET NEWPAGE NONE
    col to_char(glcd.segment1||glcd.segment2||glcd.segment3||glcd.segment4||glcd.segment5||glcd.segment6) ALIAS CONCATENATED_SEGMENTS
    col CONCATENATED_SEGMENTS justify left
    col to_char(decode(glbal.currency_code,glsob.currency_code,
    (begin_balance_dr - begin_balance_cr) + (period_net_dr -period_net_cr),
    (begin_balance_dr_beq - begin_balance_cr_beq) + (period_net_dr_beq -period_net_cr_beq))) alias Total_Functional_Currency
    col Total_Functional_Currency justify left
    COlUMN V_INSTANCE NEW_VALUE V_inst noprint
    select trim(lower(instance_name)) V_INSTANCE
    from v$instance;
    column clogname new_value logname
    select '/d01/oracle/'|| '&&V_inst' ||'out/outbound/KEMET_BALANCE_FILE_EXTRACT' clogname from dual;
    spool &&logname..csv
    SELECT glsob.currency_code ||','||
    to_char(glcd.segment1||glcd.segment2||glcd.segment3||glcd.segment4||glcd.segment5||glcd.segment6) ||','||
    to_char(decode(glbal.currency_code,glsob.currency_code,
    (begin_balance_dr - begin_balance_cr) + (period_net_dr -period_net_cr),
    (begin_balance_dr_beq - begin_balance_cr_beq) + (period_net_dr_beq -period_net_cr_beq)))
    from gl_balances glbal , gl_code_combinations glcd , gl_sets_of_books glsob
    where      period_name = '&1' /* Period Name */
    and      glbal.translated_flag IS NULL
    and      glbal.code_combination_id = glcd.code_combination_id
    and      glbal.set_of_books_id = glsob.set_of_books_id
    and      glbal.actual_flag = 'A'
    and      glsob.short_name in ('KEC-BOOKS' , 'KUE' , 'KEU','KEMS', 'KEAL' , 'KEAL-TW' , 'KEAL-SZ' , 'KEAM')
    and glcd.segment1 != '05'
    and decode(glbal.currency_code , glsob.currency_code , (begin_balance_dr - begin_balance_cr) + (period_net_dr -period_net_cr) ,
    (begin_balance_dr_beq - begin_balance_cr_beq) + (period_net_dr_beq -period_net_cr_beq)) != 0
    and glbal.template_id IS NULL
    ORDER BY glcd.segment1 || glcd.segment2 || glcd.segment3 || glcd.segment4 || glcd.segment5 || glcd.segment6
    spool off
    SET TIMING on
    set termout on
    set feedback on
    set heading on
    set pagesize 35
    set linesize 100
    set echo on
    set verify on
    Thanks
    Sandeep

    i think you do not have to worry about your code when you say that the plain texts created are ok when opened on the notepad. it is on the excel that you will need some adjustments. not sure about this but you might want to read about the applying styles in the excel by going through it's help menu.

  • Problem with Pro*C Precompiler in 10gR2

    To test whether my pro*c precompiler was working, I copied a sample program and tried running it through the precompiler. I am running Fedora 6 on Linux X86-64
    This was what I got.
    proc iname=sample1.pc ltype=long
    Pro*C/C++: Release 10.2.0.1.0 - Production on Sat Aug 18 01:53:49 2007
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    System default option values taken from: /u01/app/oracle/product/10.2.0/db_1/precomp/admin/pcscfg.cfg
    Syntax error at line 72, column 26, file /usr/include/gconv.h:
    Error at line 72, column 26 in file /usr/include/gconv.h
    unsigned char **, size_t *, int, int);
    .........................1
    PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following
    ... auto, char, const, double, enum, float, int, long,
    ulong_varchar, OCIBFileLocator OCIBlobLocator,
    OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
    OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
    short, signed, sql_context, sql_cursor, static, struct,
    union, unsigned, utext, uvarchar, varchar, void, volatile,
    a typedef name, exec oracle, exec oracle begin, exec,
    exec sql, exec sql begin, exec sql type, exec sql var,
    The symbol "enum," was substituted for "size_t" to continue.
    Syntax error at line 88, column 7, file /usr/include/gconv.h:
    Error at line 88, column 7 in file /usr/include/gconv.h
    size_t *);
    ......1
    PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following
    ... auto, char, const, double, enum, float, int, long,
    ulong_varchar, OCIBFileLocator OCIBlobLocator,
    OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
    OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
    short, signed, sql_context, sql_cursor, static, struct,
    union, unsigned, utext, uvarchar, varchar, void, volatile,
    a typedef name, exec oracle, exec oracle begin, exec,
    exec sql, exec sql begin, exec sql type, exec sql var,
    The symbol "enum," was substituted for "size_t" to continue.
    Syntax error at line 97, column 6, file /usr/include/gconv.h:
    Error at line 97, column 6 in file /usr/include/gconv.h
    size_t *);
    .....1
    PCC-S-02201, Encountered the symbol "size_t" when expecting one of the following
    ... auto, char, const, double, enum, float, int, long,
    ulong_varchar, OCIBFileLocator OCIBlobLocator,
    OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
    OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
    short, signed, sql_context, sql_cursor, static, struct,
    union, unsigned, utext, uvarchar, varchar, void, volatile,
    a typedef name, exec oracle, exec oracle begin, exec,
    exec sql, exec sql begin, exec sql type, exec sql var,
    The symbol "enum," was substituted for "size_t" to continue.
    Syntax error at line 106, column 3, file /usr/include/gconv.h:
    Error at line 106, column 3 in file /usr/include/gconv.h
    __gconv_trans_fct __trans_fct;
    ..1
    PCC-S-02201, Encountered the symbol "__gconv_trans_fct" when expecting one of th
    e following:
    char, const, double, enum, float, int, long, ulong_varchar,
    OCIBFileLocator OCIBlobLocator, OCIClobLocator, OCIDateTime,
    OCIExtProcContext, OCIInterval, OCIRowid, OCIDate, OCINumber,
    OCIRaw, OCIString, short, signed, sql_context, sql_cursor,
    struct, union, unsigned, utext, uvarchar, varchar, void,
    volatile, a typedef name,
    Syntax error at line 0, column 0, file sample1.pc:
    Error at line 0, column 0 in file sample1.pc
    PCC-S-02201, Encountered the symbol "<eof>" when expecting one of the following:
    ; : an identifier, end-exec, random_terminal
    Error at line 0, column 0 in file sample1.pc
    PCC-F-02102, Fatal error while doing C preprocessing
    This is what I have in pcsfg.cfg
    sys_include=(/build/s630/precomp/public,/usr/include,/opt/gcc33/lib64/gcc-lib/x86_64-suse-linux/3.3/include,/usr/lib/gcc-lib/x86_64-redhat-linux/3.2.3/include,/usr/lib64/gcc-lib/x86_64-suse-linux/3.3.3/include,/usr/include/linux,/usr/lib/gcc/x86_64-redhat-linux/4.1.1/include)
    ltype=short
    define=__x86_64__
    include=(/u01/app/oracle/product/10.2.0/db_1/precomp/public)
    include=/u01/app/oracle/product/10.2.0/db_1/precomp/hdrs
    I would be very grateful for any help.
    Thanks

    Thanks very much for your help. With code=CPP the size_t error disappears. But will that produce Pro C code in C format ?
    I ran into another problem.
    [oracle@Falcon source]$ proc iname=sample1.pc ltype=long code=CPP
    Pro*C/C++: Release 10.2.0.1.0 - Production on Sun Aug 19 08:33:31 2007
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    System default option values taken from: /u01/app/oracle/product/10.2.0/db_1/precomp/admin/pcscfg.cfg
    Semantic error at line 19, column 22, file sample1.pc:
    EXEC SQL CONNECT :userid;
    .....................1
    PCC-S-02322, found undefined identifier
    Semantic error at line 25, column 23, file sample1.pc:
    WHERE deptno = :dept_number;
    ......................1
    PCC-S-02322, found undefined identifier
    Semantic error at line 38, column 39, file sample1.pc:
    EXEC SQL FETCH emp_cursor INTO :emp_name;
    ......................................1
    PCC-S-02322, found undefined identifier
    [oracle@Falcon source]$ vi sample1.pc
    Where this is the code.
    [oracle@Falcon source]$ cat sample1.pc
    #include <stdio.h>
    /* declare host variables */
    char userid[18] = "PRODUSER/PRODUSER";
    char emp_name[10];
    int emp_number;
    int dept_number;
    char temp[32];
    void sql_error();
    /* include the SQL Communications Area */
    #include <sqlca.h>
    main()
    { emp_number = 7499;
    /* handle errors */
    EXEC SQL WHENEVER SQLERROR do sql_error("Oracle error");
    /* connect to Oracle */
    EXEC SQL CONNECT :userid;
    printf("Connected.\n");
    /* declare a cursor */
    EXEC SQL DECLARE emp_cursor CURSOR FOR
    SELECT ename
    FROM emp
    WHERE deptno = :dept_number;
    printf("Department number? ");
    gets(temp);
    dept_number = atoi(temp);
    /* open the cursor and identify the active set */
    EXEC SQL OPEN emp_cursor;
    printf("Employee Name\n");
    printf("-------------\n");
    /* fetch and process data in a loop
    exit when no more data */
    EXEC SQL WHENEVER NOT FOUND DO break;
    while (1)
    EXEC SQL FETCH emp_cursor INTO :emp_name;
    printf("%s\n", emp_name);
    EXEC SQL CLOSE emp_cursor;
    EXEC SQL COMMIT WORK RELEASE;
    exit(0);
    void sql_error(msg)
    char *msg;
    char buf[500];
    int buflen, msglen;
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    EXEC SQL ROLLBACK WORK RELEASE;
    buflen = sizeof (buf);
    sqlglm(buf, &buflen, &msglen);
    printf("%s\n", msg);
    printf("%*.s\n", msglen, buf);
    exit(1);
    Why won't it recognize userid ? And that is a valid login/password.

  • Problem with alter table in execute immediate

    We have PL/SQL scripts which modify the data structure, add data etc to en existing database. These scripts basically ensure that the db is compatible with what the software expects.
    The reason for doing it in PL/SQL rather than SQL script is A) The scripts are launched using GUI so that they are more user friendly. sqlplus is launched as a background process which executes these scripts. All the scripts have EXIT FAILURE WHENEVER SQLERROR as first line to ensure that the control does not hang in the sqlplus background process.
    Going from one version to other, we have added a few tables to the database and also modified a few tables. since (i think) DDL is not allowed in PL/SQL block, we had to resort to putting them in EXECUTE IMMEDIATE enclosures.
    Now for the real question,
    If I create a table using EXECUTE IMMEDIATE clause, I can immediately have insert as a next statement to insert data in this table. but, if I alter the table and add a column to the existing table, I cannot immediately add data to that column, it throws an error saying 'invalid identifier'
    At code level, the following is allowed :
    EXECUTE IMMEDIATE 'CREATE TABLE SP_TEST_TABLE
                             ID     NUMBER,
                             NAME     Varchar2(40)
    INSERT INTO SP_TEST_TABLE(ID, NAME) Values(1, 'SP');
    but I get error for the following :
    EXECUTE IMMEDIATE 'ALTER TABLE SP_TEST_TWO ADD
                        ANOTHER_COLUMN     number
    UPDATE     SP_TEST_TWO SET          ANOTHER_COLUMN = 1;
    In this case, it says ANOTHER_COLUMN invalid identifier
    Does anybody know why?
    any workaround will be greatly appreciated.
    --SP                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Friends,
    Thanks to all of you for your help. The spelling mistakes might have occurred becuase i changed the actual script to something 'short and complete' to show the problem.
    I could solve the problem by having more than one PL/SQL block within my file. something like :
    BEGIN
    --alter table statements here
    END;
    BEGIN
    --insert the values in column here.
    END;
    I am still not sure why the error is presented only on alter table statement and not for create table statement. Probably somebody with the knowledge of oracle internals will be able to throw more light on it. I am trying to get the naswers, if I get the answer, I'll surely post it here.
    Regards,
    --Saurabh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Problem viewing files that were saved as Attachments using PSoft functions

    Hello,
    I am trying to apply the code delivered in FILE_ATTACH_WRK to send an attachment to our server, and also to retrieve (view) the file. I am able to save the attachments and also to retrieve them for viewing. But something is happening to the files when I return them from the server to view them. For example, I saved a text file, but when I pull the file back for viewing it appears that all the carriage returns have been removed. A file saved like this....
    -- Script : delete_bad_referral.sql
    --+
    -- 01/10/2011 rjm
    --+
    -- Return failure code when program does not complete successfully
    whenever sqlerror exit failure;
    whenever oserror exit failure;
    Comes back looking like this:
    +-- Script : delete_bad_referral.sql -- -- 01/10/2011 rjm -- -- Return failure code when program does not complete successfully whenever sqlerror exit failure; whenever oserror exit failure; set echo on set feedback on set head off set linesize 500 --select select * FROM sysadm+
    Has anyone seen this before? Know how to correct it?

    Apologies if I switch gears here. Your last post was helpful and may have helped to resolve the problem with .txt files. But I just returned from a meeting and the customers have refined their requirement so that users can only attach files within the Office suite - ie Word, Excel, PowerPoint, etc.... So .txt files will not be a problem.
    However, I just encountered a problem working with an Excel file as an attachment. I have no problem returning a .docx file - it opens just fine in Word. I can also save a .pdf file and have it open fine using View. But when I attach a .xlsx file, viewing it returns a .zip file! If I click Open, it breaks the file into several directories including _rels, docProps, xl, etc.... and several .xml files.  Nothing in the unzipped structure is viewable as an Excel file.
    What would be causing this to happen?
    Edited by: rjmerryman on Dec 6, 2011 12:28 PM

  • Problem with ksh script

    Hi
    This is for scripting gurus,
    I am on "SunOs"
    I have created below ksh script to fetch table space info; problem is that I can not have any out put in my variable (TS_DATA);; I don't want to use utl file in my pl/sql can any one tell what went wrong with my script. Thanks in advance
    temp() {
    GET_DB_PASS
    TS_DATA=`sqlplus -s /nolog <<EOSQL
    whenever sqlerror exit failure
    set serveroutput on
    set feedback off
    set pause off
    set echo off
    set heading off
    set verify off
    connect ${l_connect_string}
    DECLARE
    TYPE t_task_tab IS TABLE OF VARCHAR2 (1000)
    INDEX BY BINARY_INTEGER;
    t_tab_space_name t_task_tab;
    t_tot_byte t_task_tab;
    t_fr_byte t_task_tab;
    t_max_chunk t_task_tab;
    t_rpt_txt t_task_tab;
    t_rpt_num t_task_tab;
    l_count number :=0;
    BEGIN
    SELECT tablespace_name,NVL(SUM(bytes),1),1,1
    BULK COLLECT INTO t_tab_space_name,t_tot_byte,t_fr_byte,t_max_chunk
    FROM dba_data_files
    GROUP BY tablespace_name;
    FOR i IN t_tab_space_name.FIRST..t_tab_space_name.LAST
    LOOP
    SELECT NVL(SUM(b.bytes), 1) INTO t_fr_byte(i)
    FROM dba_free_space b
    WHERE t_tab_space_name(i) = b.tablespace_name;
    IF (95 < 100-(t_fr_byte(i)*100/t_tot_byte(i))) THEN
    l_count := l_count + 1;
    SELECT t_tab_space_name(i),TO_CHAR(ROUND(100-(t_fr_byte(i)*100/t_tot_byte(i)), 2))
    INTO t_rpt_txt(i),t_rpt_num(i) FROM dual
    WHERE 95 < 100-(t_fr_byte(i)*100/t_tot_byte(i));
    dbms_output.put_line(t_rpt_txt(i));
    dbms_output.put_line(l_count);
    END IF;
    END LOOP;
    END;
    EOSQL`
    echo $TS_DATA
    temp

    if this is SunOS specifice, is the wrong mailing list..
    what about someting simple:
    cat y.sh#!/usr/bin/ksh
    temp() {
    TS_DATA=`sqlplus -s /nolog <<EOSQL
    connect scott/tiger
    select count(*) from emp;
    exit
    EOSQL`
    echo "${TS_DATA}"
    temp
    ./y.shConnected.
    COUNT(*)
    15
    >
    so works fine on Linux......
    not sure what you are up to, but
    #!/usr/bin/ksh
    temp() {
    sqlplus -s /nolog <<EOSQL
    connect scott/tiger
    select count(*) from emp;
    exit
    EOSQL
    temp
    also should write the output to the stdout; not really sure why you need to use variables to store the results
    guido

Maybe you are looking for

  • Email Submit Button doesn't use default email software

    When I click the Email Submit button, the form does not use my default email program (Eudora). Instead it uses an old hotmail account which I don't even use anymore. All other web pages bring up Eudora when I click on a mail link. Only Live Cycle doc

  • Can extends keyword be used with respect to interfaces?

    can extends keyword be used with respect to interfaces?

  • At selection-screen when user presses back button

    Experts, I have two radio buttons and two relative checkboxes ( one checkbox related to other ). Now when user selects one radio button and executes teh program, there is a summary page. When user presses back button from there, I return to the selec

  • Aperture and/or RAW files on a iPad?

    I use Aperture as my primary photo editng program, and do the editing on my MacPro.  While traveling, as a backup to my memory cards, I have been importing the RAW files from my Nikon DSLR into Aperture on my laptop (MacBook).  When I get home I then

  • Cisco IP 7960 and Cisco Router 2611....

    Greetings, I currently have 2 IP phones and a 2611 series router running 2600-ik902s2-mz.122-15.t5 IOS... Can anyone point me in the right direction on where/or how to start building a mini voice network? Any links, tutorials, info, advice would be g