[Oracle 8i] Handling null in case statement

The following bit of my query is causing the error 'inconsistent datatypes':
CASE
     WHEN b.days_diff < 0
     THEN plan_start
     ELSE plan_start + b.days_diff
ENDThe problem is that b.days_diff can be null.
I've tried to work around this, by using the NVL statement and by nesting 2 case statements to try to deal with the null, but can't seem to work around it.
Does anyone have anything else I can try?

Apologies...internet server went down yesterday...
I've had this issue before with my database. When I look at user_tab_columns, it says plan_start is a date. However, I have had to use TO_DATE in the past with it to get some things to work. It's very odd, and I have no idea why it's like that.
Anyway, below, I have provided some sample data, and the full query I'm trying to run:
CREATE TABLE     ord (
ord_nbr          char(10)
ord_stat     char(2)
INSERT INTO     ord
VALUES          ('0000012345', 'OP');
INSERT INTO     ord
VALUES          ('0000012346', 'OP');
INSERT INTO     ord
VALUES          ('0000012347', 'CL');
INSERT INTO     ord
VALUES          ('0000012348', 'OP');
CREATE TABLE     op (
ord_nbr          char(10)
operation     char(4)
op_status     char(2)
plan_start     date
pln_due          date
dt_complete     date
INSERT INTO     op
VALUES          ('0000012345', '0001', 'CL', {ts '2009-01-01 00:00:00'}, {ts '2009-01-02 00:00:00'}, {ts '2009-01-04 00:00:00'});
INSERT INTO     op
VALUES          ('0000012345', '0002', 'CL', {ts '2009-01-02 00:00:00'}, {ts '2009-01-03 00:00:00'}, {ts '2009-01-06 00:00:00'});
INSERT INTO     op
VALUES          ('0000012345', '0003', 'CL', {ts '2009-01-03 00:00:00'}, {ts '2009-01-04 00:00:00'}, {ts '2009-01-09 00:00:00'});
INSERT INTO     op
VALUES          ('0000012345', '0004', 'WK', {ts '2009-01-04 00:00:00'}, {ts '2009-01-05 00:00:00'}, {ts '1900-12-31 00:00:00'});
INSERT INTO     op
VALUES          ('0000012345', '0005', 'OP', {ts '2009-01-05 00:00:00'}, {ts '2009-01-06 00:00:00'}, {ts '2009-01-02 00:00:00'});
INSERT INTO     op
VALUES          ('0000012346', '0001', 'CL', {ts '2009-01-01 00:00:00'}, {ts '2009-01-02 00:00:00'}, {ts '2009-01-01 00:00:00'});
INSERT INTO     op
VALUES          ('0000012346', '0002', 'OP', {ts '2009-01-02 00:00:00'}, {ts '2009-01-04 00:00:00'}, {ts '1900-12-31 00:00:00'});
INSERT INTO     op
VALUES          ('0000012346', '0003', 'OP', {ts '2009-01-04 00:00:00'}, {ts '2009-01-06 00:00:00'}, {ts '1900-12-31 00:00:00'});
INSERT INTO     op
VALUES          ('0000012347', '0001', 'CL', {ts '2009-01-01 00:00:00'}, {ts '2009-01-02 00:00:00'}, {ts '2009-01-03 00:00:00'});
INSERT INTO     op
VALUES          ('0000012347', '0002', 'CL', {ts '2009-01-02 00:00:00'}, {ts '2009-01-05 00:00:00'}, {ts '2009-01-06 00:00:00'});
INSERT INTO     op
VALUES          ('0000012348', '0001', 'OP', {ts '2009-01-15 00:00:00'}, {ts '2009-01-17 00:00:00'}, {ts '1900-12-31 00:00:00'});
INSERT INTO     op
VALUES          ('0000012348', '0002', 'OP', {ts '2009-01-17 00:00:00'}, {ts '2009-01-20 00:00:00'}, {ts '1900-12-31 00:00:00'});Full query:
SELECT     ord.ord_nbr
,     ord.ord_stat
,     op.operation
,     op.op_status
,     op.plan_start
,     //where I want to return plan_start + days_diff if days_diff is not null or negative
     //otherwise, I want to return just plan_start
     AS adjusted_start
,     op.dt_complete
,     b.max_cl_op
,     b.pln_due
,     b.dt_complete
,     b.days_diff
FROM     ord
,     op
     SELECT     a.ord_nbr
     ,     a.max_cl_op
     ,     op.pln_due
     ,     op.dt_complete
     ,     (op.dt_complete-op.pln_due)     AS days_diff
     FROM     (
          SELECT          op.ord_nbr
          ,          MAX(TO_NUMBER(op.operation))     AS max_cl_op
          FROM          ord
          ,          op
          WHERE          ord.ord_nbr     = op.ord_nbr
          AND          ord.ord_stat     != 'CL'
          AND          op.op_status     ='CL'
          GROUP BY     op.ord_nbr
          ) a
     WHERE     op.ord_nbr     = a.ord_nbr
     AND     op.operation     = a.max_cl_op
     ) b
WHERE     ord.ord_nbr     = op.ord_nbr
AND     op.ord_nbr     = b.ord_nbr (+)
AND     ord.ord_stat     != 'CL'
AND     op.op_status     != 'CL'
AND     op.plan_start     <= ADD_MONTHS(sysdate, 12)The results I want to get:
ord.ord_nbr     ord.ord_stat     op.operation     op.op_status     op.plan_start     adjusted_start     op.dt_complete     b.max_cl_op     b.pln_due     b.dt_complete     b.days_diff
'0000012345'     'OP'          '0004'          'WK'          1/4/2009     1/9/2009     12/31/1900     '0003'          1/4/2009     1/9/2009     5     
'0000012345'     'OP'          '0005'          'OP'          1/5/2009     1/10/2009     12/31/1900     '0003'          1/4/2009     1/9/2009     5
'0000012346'     'OP'          '0002'          'OP'          1/2/2009     1/2/2009     12/31/1900     '0001'          1/2/2009     1/1/2009     -1
'0000012346'     'OP'          '0003'          'OP'          1/4/2009     1/4/2009     12/31/1900     '0001'          1/2/2009     1/1/2009     -1
'0000012348'     'OP'          '0001'          'OP'          1/15/2009     1/15/2009     12/31/1900                                   
'0000012348'     'OP'          '0002'          'OP'          1/17/2009     1/17/2009     12/31/1900     

Similar Messages

  • Using null in CASE statements

    Hi,
    I have query with a case statement as follows:
    SELECT * FROM table
    WHERE
    CASE WHEN :variable like 'A' THEN column END is null
    WHEN :variable like 'B' THEN column END is not null;
    This works fine when returning "column is null" but not when "column is not null".
    Can I use a CASE statement like this?
    Thanks
    Lucy

    My data is too complicated to show, but depending on the value of the bind variable in the statement I want to return all the rows in a query where the data in a particular column is either null or not null.For example, looking at the EMP table, if my bind variable is whether I want to show the top manager or not, if set to 'Yes' I would like to return all rows of the EMP table where mgr is null (i.e. the one row where ename is 'KING'), if it were set to 'No' I would like to return all the rows where mgr is not null (i.e. all the other rows). The difference with my query is that the column contains strings, not numerics.
    I've used a CASE statement before where I equate the column to a particular value and that works fine, but I'm not sure how they deal with nulls. I've also tried DECODE and didn't get anywhere with that.
    Thanks
    Lucy

  • Handling Exceptions with case statement - convert Exception to int value

    Hi,
    I'm developing a web app, with servlets.
    I'm catching Exceptions in my servlets, for example I would like a user to insert data into a form. If the data cannot be converted into a integer value a java.lang.NumberormatException is thrown.
    I would like to catch this and then create a message giving a more specific clue to what happened. Unfortunatly it's possible that other exceptions could be caught, so I want to be able to check which type of Exception has been caught.
    I started writing a getErrorMessage(int Code) class. The method has a case statement which just checks the code and return the appropriate message.
    This worked well for SQL exceptions as they provide a getErrorCode method. But I was wondering is there any way to convert other Exceptions such as
    java.lang.NumberormatException into an integer value?
    Cheers

    Exceptions have their types (classes) and messages (and maybe an embedded exception). That is, they have much richer internal status then an integer.
    Why should they be "converted" to integers?
    FLAME on
    Gone are the days of good old errno.
    FLAME off

  • Using a comparison to NULL in a CASE statement

    Hi, please could anybody advise me if it is OK to use comparison to NULL in a CASE statement. Alternatively, will a NULL be accepted in a to_number function giving a result of a NULL in the number variable?
    I have a list of varchar2 values which will either be a number, be equal to '95%' or be NULL. I need to translate that to a number column, removing the % from 95%.
    I would like to know if the syntax below is allowed:
    CASE vPurity
    WHEN NULL THEN
    nPurity = '';
    WHEN '95%' THEN
    nPurity := 95;
    ELSE
    nPurity := TO_NUMBER(vPurity);
    END CASE;
    Many thanks.

    robust
    adj.
    1. Full of health and strength; vigorous.
    2. Powerfully built; sturdy. See Synonyms at healthy.
    3. Requiring or suited to physical strength or endurance: robust labor.
    4. Rough or crude; boisterous: a robust tale.
    5. Marked by richness and fullness; full-bodied: a robust wine.
    By saying "Robust" you are saying that DECODE is somehow stronger or better than CASE. This is not the case (scuse the pun) as CASE is more flexible than DECODE and can be easier to read in the code. CASE also handles non-equality comparisons far easier than can be done in DECODE.

  • Case statement with having null gives default result

    Hello,
    When we write a case statement with a not equal condition <> on a column and if that columns has null value the it gives the else value.
    eg
    Select Column_Name, Case when Column_Name <>Condition then 0 else 1 end as case_test from Table_Name.
    Ideally null is not equal to the condition so the case should return 0 but it returns 1. Can anyone tell me why?

    In addition to the other posts:
    NULL is an unknown value, when you say
      col <> 1
    and col is NULL, we don't know whether col is 1 or something else. Thus the condition evaluates to UNKNOWN. How UNKNOWN is handled depends on the context. In WHEN clauses as well as the IF statments, the effect that the code bracketed by IF/WHEN is not
    entered. That is, UNKNOWN and FALSE yields the same result. In CHECK constraints, it's the other way round. If you have
     CHECK (WHEN col <> 0)
    rows where col is NULL are accepted.
    When you work with SQL, no matter the database product, it's imperative to master three-valued logic, because it comes up all the time.
    As I said, NULL is the unknown value. In practice, NULL has a distinct interpreation depending on the database column. For instance, NULL in a column called EndDate, usually means that the period (or whatever it is) is still open. So often when you work
    with NULL values you use isnull to replace it with some value that fits the context, and finding that value takes some consideration. Blindly doing isnull(col, '') can lead to serious bugs, particularly if col is not a string column.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Case statement problems in oracle forms 6i

    Hello,
    Any one can help me that how to use case statment in Oracle forms 6i.
    i have read one thread and there was no proper solution so could any one please let me know to use case statement.
    Please also let me know which category i should search for FORMS 6i.
    when i'm using below code with cursor then i'm getting error 103
    database:=11g
    application := forms 6i
    operating system:= win Xp
    code is given below :-
    cursor c1 is
    select nc.nomenclature_id,
    nvl(nc.category_value, 0) master,
    nvl(nc2.category_value, 0) case,
    nvl(nc3.category_value, 0) bundle,
    case
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) > 0 then
    'A' --All packouts Master, Case, Bundle
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) = 0 then
    'B' --Both Master and Case
    when nvl(nc2.category_value, 0) = 0 and
    nvl(nc3.category_value, 0) = 0 then
    'C' --Master Case Only
    else
    'N'
    end code
    from nomn_category nc, --master case
    (select nc2.nomenclature_id,
    nc2.category_value
    from nomn_category nc2
    where nc2.category_id = '230732') nc2,
    (select nc3.nomenclature_id,
    nc3.category_value
    from nomn_category nc3
    where nc3.category_id = '236566') nc3
    Edited by: Rahul on Feb 3, 2012 7:18 PM
    Edited by: Rahul on Feb 3, 2012 7:20 PM

    hello Andreas,
    It is ok but i dont have to use view there.
    i need to use without view, because this code has to be use in FORMS6i.
    But Forms6i doesn't support to case function. i'm newbie in Forms.
    If you can convert to below bold one portion(case) into decode then please help me or
    if you have any idea about Forms6i then please send me any link where is given explanation about excel report that how to make excel report through Forms6i step by step and that excel report should be generate on any dynamic path which is given by user:-
    cursor c1 is
    select nc.nomenclature_id,
    nvl(nc.category_value, 0) master,
    nvl(nc2.category_value, 0) case,
    nvl(nc3.category_value, 0) bundle,
    case
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) > 0 then
    *'A'*
    when nvl(nc.category_value, 0) > 0 and
    nvl(nc2.category_value, 0) > 0 and
    nvl(nc3.category_value, 0) = 0 then
    *'B' --Both Master and Case*
    when nvl(nc2.category_value, 0) = 0 and
    nvl(nc3.category_value, 0) = 0 then
    *'C'*
    else
    *'N'*
    end "code"
    from nomn_category nc,
    (select nc2.nomenclature_id,
    nc2.category_value
    from nomn_category nc2
    where nc2.category_id = '230732') nc2,
    (select nc3.nomenclature_id,
    nc3.category_value
    from nomn_category nc3
    where nc3.category_id = '236566') nc3
    thanks

  • Case Statement in Oracle Query.

    Hello Oracle Gurus,
    I need suggestion on whether I should use Case statement in Oracle queries.
    I have a sql statement which inserts the data by selecting data from other table. While selecting the data I have put a logic in the select statement for one column which is something like this and there are some more similar statements in the same query.
    CASE
                   WHEN (b.ACCOUNT = 'FIN' or b.ACCOUNT ='FIN ACC' or b.ACCOUNT like '%Global Eq%' or b.ACCOUNT like '%Flexible Bond%')
                   THEN
                        'MTM'
                             WHEN (substr(a.CTC,-3)='MTM')
                   THEN
                        'MTM'
                             WHEN (substr(a.CTC,-3)='AFS' or substr(a.CTC,-3)='HTM' OR substr(a.CTC,-3)='ACC' OR substr(a.CTC,-3)='HFI' )
                   THEN
                        'ACC'
                   ELSE
                                  'OTH'
              END,
    I wanted to get an suggestion about how much performance issue can I have due to this in my insert statement.
    Let me know if you need any other information.All comments are really appreciated.

    Hi,
    It's depends on the joins how you have performed with source table, stats and existing of indexes. If the volume of data is high - in case of any performance issue - why can't you perform the required things of logical conditions of data and popualte in one cluster so - that you can fetch out the chunks of required information with better way and in support with indexes.
    Let us know the ful query your working on
    Oracle version
    Explain plans - get it from dbms_xplan.
    - Pavan Kumar N
    - ORACLE - 9i/10g - OCP
    RHCE - Enterprize Linux 5.4

  • CASE statement in Oracle 8i PL/SQL

    I'm in the process of doing an upgrade from 8i to 10g and have the necessary instructions in performing it. however, after running the pre upgrade tasks (run utlu102i.sql) to show the preupgrade information, i found out that there are some INVALID objects.
    Miscellaneous Warnings
    WARNING: --> Database contains INVALID objects prior to upgrade.
    .... USER INGITRN has 1 INVALID objects.
    .... USER INGIUAT has 3 INVALID objects.
    .... USER OEMMON has 7 INVALID objects.
    .... USER RE_ITF_USER has 11 INVALID objects.
    .... USER SYS has 1 INVALID objects.
    Would it be ok to proceed with the upgrade and ignore the warnings?
    Also, as i checked the invalid object for SYS, it shows:
    OWNER OBJECT_NAME OBJECT_TYPE STATUS
    SYS UTL_RECOMP PACKAGE VALID
    SYS UTL_RECOMP PACKAGE BODY INVALID
    Further more, i tried to do a fix by invoking utlirp.sql and the same objects are showing up. Same thing shows when invoking utlrp.sql or even doing a manual compile for the affected objects. I later found out that CASE statements are not accepted in PL/SQL for Oracle 8i.
    Can you help me fixed the issue on the invalid object?
    Thanks

    Hi,
    Try first to (re)compile ll invalid objects. then
    you can run:
    select owner,type,count(*) from all_errors
    group by owner,typeif you still have uncompiled objects, then report the different errors:
    select * from all_errors...

  • Got error when use case statement in oracle stored procedure

    Hi,
    I have a query like:
    select merchant_id,
    case
    when product_type='K' then 'Production'
    when product_carrier='UC' THEN 'Shipping'
    end the_type
    from product_tbl
    where merchant_id=10114
    It works fine. But as soon as I put it into a stored procedure, I got error like:
    Encountered the symbol "CASE" when expecting one of the following:
    ( - + mod null <an identifier>
    Please help!

    Oracle 8i doesn't support CASE into PL/SQL, so as Kamal said, create a view with the CASE, and use this view into your PL/SQL.
    Nicolas.
    And an example here :
    Re: Execute Immediate doesnot work in 8i (8.1.7) and Ref Cursor not exec qu
    Sorry Kamal.
    Message was edited by:
    N. Gasparotto

  • Handling NULL in Oracle Function

    I try to handle NULL with IS NULL in side the Function. But I some how can't do it. Control always goes to NO_DATA_FOUND Exception block.
    In BEGIN block, if I try to handle with IS NULL condition but it doesn't work. But if I use DBMS_OUTPUT.PUTLINE and display the variable with NVL, it tells me it is NULL.
    My code is like;
    <code>
    FUNCTION F_GetProductKey (p_CompanyCod varchar2, p_ProductCod varchar2) return number;
    as
    vi_ProductKey Number;
    BEGIN
    DBMS_OUTPUT.PUT_LINE( NVL(p_ProductCod,'abc') <----- This displays 'abc'
    IF p_ProductCod IS NULL THEN
    SELECT PRODUCT_KEY in vi_ProductKey from DIM_PRODUCT WHERE Product_Cod=-2;
    ELSE <---- Control Always Goes to ELSE even p_ProductCod is NULL & then it goes to NO_DATA_FOUND Exception
    SELECT PRODUCT_KEY in vi_ProductKey from DIM_PRODUCT WHERE Product_Cod=p_ProductCod AND COMPANY_COD = p_CompanyCod ;
    END IF;
    return vi_Product_Key;
    EXCEPTION
         WHEN NO_DATA_FOUND THEN
         return -20060;
    WHEN OTHERS THEN
    return -20001;
    END;
    </code>
    I've a hard coded value in table for Product_Cod=-2, so I should never get No_Data_Found exception if ProductCod is NULL. I checked, for CompanyCod and it is NOT NULL when I call function.
    I Googled to look at what I'm doing wrong. I find that NULL values can be handled by ISNULL but some how it doesn't work in my case.
    Is there any other way to handle NULL inside function??

    I've a hard coded value in table for Product_Cod=-2, so I should
    never get No_Data_Found exception if ProductCod is NULL.Are you sure? It seems to me the behaviour you describe could equally well be explained by the control going down the IF ... IS NULL branch and then not finding the PRODUCT_COD in question.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/
    P.S. Having read your subsequent message, specifically this
    Product_cod is varchar2. It is actually comparing to
    'UNK' not -2 in side the code.I am even more certain that the problem lies in your data. Larry Ellison did not become a multi-billionnaire on the basis of code which behaved in an unpredictable fashion.
    Message was edited by:
    APC

  • If I have floating values such as 6.3, 6.7, 6.9, 7.1, 7.2 how do I write a case statement to handle that

    How do I write a case statement If I want a case for x < 1.5;   a case for 1.5 <= x <= 3.7;  case for  3.7 < x < 7.2.....etc.   My input is a floating number.
    Thank you.
    Solved!
    Go to Solution.

    smercurio_fc wrote:
    Nice method with the Threshold function. I was not aware of the limitation with -Inf. Odd.
    Actually, my code operates correctly as long as the first element is smaller than all other elements in the array. We don't need any special handling.
    Maybe NaN is not a bug if the array starts with -Inf, because the interpolated index for any number between the second element and -inf will be infinitely close to 1, thus a result of zero can never be obtained (try a first element of -1e50 and you'll always get 1 unless you go to very huge negative numbers).
    The way threshold array is defined, the behavior should be obvious, the problem is assigning a fractional index.
    It is unexpected that an input equal to the second element also results in NaN. That might be a bug. (see image).
    I probably won't post an idea, maybe a bug report after some more thinking...
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    IdeaThresholdArray.png ‏19 KB

  • Case Statement in Select Statement - Oracle 8.0.6

    I am trying to do the following, but am getting error -
    "FROM keyword not found where expected"
    select s.item, s.dest, s.qty ,
    case when s.dest = 'x'
    then (sales - returns)
    else 0
    end
    from table1 s
    Is this an error or is it because of the version of Oracle?

    As I recall, CASe was not supported until 8.1. So, you need to use decode instead.
    SELECT s.item, s.dest, s.qty ,
           DECODE(s.dest,'x',s.sales - s.returns,0)
    from table1 sTTFN
    John

  • Just a FYI regarding Case statements in ORacle 8i in pl/sql

    Well..I saw numerous posts in this forum regarding not being able to do case statement within pl/sql. Well..you can do
    that using dynamic SQL. IT works like a champ.

    Hi,
    Try first to (re)compile ll invalid objects. then
    you can run:
    select owner,type,count(*) from all_errors
    group by owner,typeif you still have uncompiled objects, then report the different errors:
    select * from all_errors...

  • Oracle CASE statement logic

    Hi all,
    I have to compare the value of a varchar variable using a CASE statement and display the corresponding output.
    But when the following code is being executed, and i gave the value of dayrange as anything other than number, i am getting the error;
    The daysrange variable can be a number or a string (Hence i declared it as a varcahr2)
    Error report:
    ORA-06502: PL/SQL: numeric or value error: character to number conversion error
    ORA-06512: at line 5
    06502. 00000 - "PL/SQL: numeric or value error%s"
    *Cause:   
    *Action:
    declare
    daysrange varchar2(10):='abc';
    x varchar2(100);
    begin
    CASE WHEN DAYSRANGE = 1 THEN x := 'LD';
              WHEN DAYSRANGE BETWEEN 2 AND 7 THEN x := 'LW';
              WHEN DAYSRANGE BETWEEN 8 AND 30 THEN x:= 'LM';
              WHEN DAYSRANGE BETWEEN 31 AND 90 THEN x:= 'L3M';
              WHEN DAYSRANGE BETWEEN 91 AND 180 THEN x:= 'L6M';
              WHEN DAYSRANGE BETWEEN 181 AND 365 THEN x:= 'LY';
              WHEN DAYSRANGE BETWEEN 366 AND 730 THEN x:= 'L2Y';
              WHEN DAYSRANGE > 730 THEN x:= 'O2Y';
         ELSE x:='x:= x';
         END case;--DATERANGE
    exception
    when case_not_found then
    x:='something';
    dbms_output.put_line(x);
    end;
    Edited by: Chaitanya on Nov 25, 2010 1:25 AM

    Hi,
    Chaitanya wrote:
    ... The daysrange variable can be a number or a string (Hence i declared it as a varcahr2)That's usually not a good design. It would be better to have two variables (or columns) if necessary, a VARCHAR2 and a NUMBER.
    If you can't change the design, then test daysrange, and then do different things depending on whether it is a number or not.
    For example:
    declare
         daysrange      varchar2(10)     := '17';
         daysrange_n     NUMBER;
         x           varchar2(100);
    begin
         IF  REGEXP_LIKE (daysrange, '^\d+$')
         THEN
              daysrange_n := TO_NUMBER (daysrange);
              x := CASE 
                   WHEN daysrange_n > 730     THEN 'O2Y'
                   WHEN daysrange_n > 365     THEN 'L2Y'
                   WHEN daysrange_n > 180     THEN 'L1Y'
                   WHEN daysrange_n >  90     THEN 'L6M'
                   WHEN daysrange_n >  30     THEN 'L3M'
                   WHEN daysrange_n >   7     THEN 'LM'
                   WHEN daysrange_n >   1     THEN 'LW'
                   WHEN daysrange_n =   1     THEN 'LD'
                                  ELSE  x          -- If necessary
                   END;
         END IF;
    ...The tests in a CASE expression are done in order. The n-th WHEN condition is tried only after conditions 1 through n have failed. That's why we can saY, for example,
    "daysrange_n > 365" instead of
    "daysrange_n BETWEEN 366 AND 730". If the 2nd test is even being performed, we know that the 1st test failed, and that daysrnage_n is not > 730.
    I'm not saying that you have to write CASE expressions like this, or that it's necessarily better. You should know that it's possible, then choose whichever way makes the most sense in this situation.

  • Oracle Error Handling in Shell Scripts

    I need to manage 2 diferente class of errors :
    Oracle Errors(produced in compilation time) and
    Operating Syste Error(e.g. No Datbase conection ORA-1017,etc) my shell its KSH.
    Please can you help me how can I manage then?
    this my alternative but is not correct ;
    #creating conexion with sql
    exit | sqlplus -s $USERPV_DB/$PWDPV_DB @$VORDSQLPATH/ord.extractor_porven.sql $VFDESDE $VFHASTA > $VORDDATOS_PATH/ord.extractor_porven$VDATE.dat 2>> $VLOG
         #Evaluating last sentence (sqlplus . . . . )
         VERROR=$?
         #Si VERROR=0 should stop process execution and alert with echo ".."Oracle error handling before compilation time
         if [ $VERROR  != 0 ]
         then
         echo "value of VERROR are:$VERROR"
         echo "`date +"$V_FORMATDATE"` DATA EXTRACTION WAS NOT SUCESSFUL ERROR BEFORE COMPILATION TIME" >> $VLOG 2> /dev/null
         " Here show VERROR
         else #Oracle error handling in compilation time
         echo "`date +"$V_FORMATDATE"` DATA EXTRACTION WAS NOT SUCESSFUL ERROR BEFORE COMPILATION TIME " >> $VLOG
         " Here show VERROR
    else if [ $VERROR  = 0 ]
    " DATA EXTRACTION WAS SUCESSFUL"
    fi
    Would apreciate your help its very urgent.
    Best Regards
    Antonio

    user5647282 wrote:
    I need to manage 2 diferente class of errors :
    Oracle Errors(produced in compilation time) and
    Operating Syste Error(e.g. No Datbase conection ORA-1017,etc) my shell its KSH.
    Please can you help me how can I manage then?
    this my alternative but is not correct ;
    #creating conexion with sql
    exit | sqlplus -s $USERPV_DB/$PWDPV_DB @$VORDSQLPATH/ord.extractor_porven.sql $VFDESDE $VFHASTA > $VORDDATOS_PATH/ord.extractor_porven$VDATE.dat 2>> $VLOG
    Piping the output of 'exit' to sqlplus????????? what do you expect from this?
         #Evaluating last sentence (sqlplus . . . . )
         VERROR=$?any error returned by sqlplus as $? would be a fatal error of sqlplus itself, not any error returned by processing a sql statement. If your script ord.extractor_porven.sql were to generate, say, an ORA-00001, that is NOT an error in sqlplus and so does not return to the OS as an error of sqlplus.
         #Si VERROR=0 should stop process execution and alert with echo ".."Oracle error handling before compilation time
         if [ $VERROR  != 0 ]
         then
         echo "value of VERROR are:$VERROR"
         echo "`date +"$V_FORMATDATE"` DATA EXTRACTION WAS NOT SUCESSFUL ERROR BEFORE COMPILATION TIME" >> $VLOG 2> /dev/null
         " Here show VERROR
         else #Oracle error handling in compilation time
         echo "`date +"$V_FORMATDATE"` DATA EXTRACTION WAS NOT SUCESSFUL ERROR BEFORE COMPILATION TIME " >> $VLOG
         " Here show VERROR
    else if [ $VERROR  = 0 ]
    " DATA EXTRACTION WAS SUCESSFUL"
    fi
    Would apreciate your help its very urgent.
    there is no "urgent" here.
    "Urgent" means one of two things -
    1) people are dying, or
    2) you have a customer-facing, revenue-producing production system that is down.
    (And to get some perspective on the second case, keep the first in mind.)
    For the first, you call whatever civil emergency service seems appropriate.
    For the second, you open an SR with Oracle - which requires a paid-up support contract. For them to consider your problem "urgent", you will need to demonstrate that your problem falls under item #2. I seriously doubt your problem fits that criteria.
    Best Regards
    Antonio

Maybe you are looking for

  • How to fhide fields in Pa customized infotype

    Hi I am creating one PA related It, out of which i have 11 fields , but in Ovwer view screen i need to display only 6 fields. how it will be done. Please respond to this ASAP. Thanks, Kalyan

  • Windows 8.1 installation on pentium 4

    Hi, please show me how to install windows 8.1 on p4 pc win Xp isnt good any more :P

  • How do I get rid of an overlay on the Galaxy s5 phone

    All of a sudden an overlay appeared on my phone and I cannot figure out how to get rid of it. Any help would be appreciated.                   Thanks,                      Mike Lane

  • EBRS on Reference level Clearing

    Dear Expert, I configured Electronic Bank Reconciliation and it's clearing on amount level. The problem is that if there are more than one entry of same amount is there system doesn't clear any amount and we have to go t.code FEBAN and there select l

  • Compressor AC3 encoding error!

    When I encoded my 2Hour,53Minutes 6 Channel Wave file in compressor 2, the length of the final 5.1 AC3 file (448 Kbps)for DVD is 28 Minutes only! Why ? Is there any length limit in compressor? Any one faced this problem before? Please advice me! Than