Using NVL function in subselect of an update

Hi,
nvl is not working in my situation
Here is my select
SELECT nvl(a.id, 'WAS NULL') FROM table_1 a, table_2 b
WHERE a.id=b.id;
Now here I get NULL instead of 'WAS NULL' as I accepted.
Table a and table b do not have any identical ids, still I need to be a value returned.
Is there a way?
Thanks

Well this works for me:
SQL> CREATE TABLE table_1 (id INT NOT NULL, val VARCHAR2(10) NOT NULL);
Table created.
SQL> CREATE TABLE table_2 (id INT NOT NULL, val VARCHAR2(10) NOT NULL);
Table created.
SQL> INSERT INTO table_1 VALUES (1, 'A');
1 row created.
SQL> INSERT INTO table_2 VALUES (2, 'B');
1 row created.
SQL> UPDATE table_1 t1
  2  SET    val =
  3         ( SELECT NVL(t2.val,'Was NULL') FROM table_2 t2
  4           WHERE  t2.id = t1.id );
SET    val =
ERROR at line 2:
ORA-01407: cannot update ("WILLIAM"."TABLE_1"."VAL") to NULL
SQL> UPDATE table_1 t1
  2  SET    val =
  3         NVL
  4         ( ( SELECT t2.val
  5             FROM   table_2 t2
  6             WHERE  t2.id = t1.id )
  7         , 'Was NULL');
1 row updated.
SQL> SELECT * FROM table_1;
        ID VAL
         1 Was NULL
1 row selected.

Similar Messages

  • How to use NVL Function

    hi,
    i want to use nvl Function in that Quary
    select f_words(SUM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    i am using NVL in that Quary Like This
    select f_words*(nvl(S*UM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    I want to use NVL Function In BOLD
    How Can I use NVL Functiion.
    Thanks
    Edited by: Manoj Kaushik on Mar 25, 2010 5:55 AM

    hi,
    select f_wordsl(SUM(a.AMOUNT)+sum(a.vat_amount) +
    nvl( (select sum(b.LABOUR_AMT)+sum(b.service_tax_amt)
    from LAB_WORK_DTL b
    where a.bill_no =b.bill_no), 0)
    )) as t
    from TRANSACTION_DETAILS a
    where a.bill_no =:P42_bill_no
    group by a.BILL_NO;
    i have two tables Bill no is comman field in both tables if i have not enter value in any one of the table .
    so how can i show Total amount in words if Bill NO are not in any one table.
    Thanks

  • Compilation problems using NVL function in Pro*C subselect

    I have come across a weird oracle problem. When I execute the following query in SQLPlus it works but when
    I include it in Pro*C code in a EXEC SQL statement it gives syntax errors and fails to compile. Any idea what I am doing wrong.
    SELECT DISTINCT
         A.ID_PERSON,
         C.ID_STAGE_PERSON_LINK ,
         A.NM_PERSON_FULL,
         A.NBR_PERSON_AGE,
         A.ADDR_PERSON_ST_LN_1,
         A.ADDR_PERSON_CITY,
         A.ADDR_PERSON_ZIP,
         A.CD_PERSON_STATE,
         A.CD_PERSON_COUNTY,
         A.NBR_PERSON_PHONE,
         C.CD_STAGE_PERS_REL_INT
         FROM
              PERSON A,
              STAGE_PERSON_LINK C
         WHERE
         C.ID_CASE = 88776721
         AND          A.IND_INVALID_PERS IS NULL
         AND          C.CD_STAGE_PERS_TYPE = 'PRN'
         AND          C.ID_PERSON = A.ID_PERSON
         AND C.ID_STAGE_PERSON_LINK =
    NVL (
                   (SELECT MAX(F.ID_STAGE_PERSON_LINK)
                   FROM STAGE_PERSON_LINK F
                   WHERE F.ID_PERSON=C.ID_PERSON
                   AND F.ID_CASE = C.ID_CASE
                        AND F.CD_STAGE_PERS_TYPE = 'PRN'
                        AND F.CD_STAGE_PERS_REL_INT IS NOT NULL)
                   (SELECT MAX(G.ID_STAGE_PERSON_LINK)
                   FROM STAGE_PERSON_LINK G
                   WHERE G.ID_PERSON=C.ID_PERSON
                   AND G.ID_CASE = C.ID_CASE
                        AND G.CD_STAGE_PERS_TYPE = 'PRN')
    AND A.ID_PERSON NOT IN
    SELECT S.ID_PERSON
    FROM STAGE_PERSON_LINK S,STAGE T
    WHERE S.ID_CASE = C.ID_CASE
    AND S.ID_CASE = T.ID_CASE
    AND S.ID_STAGE = T.ID_STAGE
    AND T.CD_STAGE <> 'INT'
    MINUS
    SELECT H.ID_PERSON
    FROM STAGE_PERSON_LINK H, STAGE F
    WHERE H.ID_CASE = F.ID_CASE
    AND H.ID_STAGE = F.ID_STAGE
    AND H.ID_CASE = C.ID_CASE
    AND H.CD_STAGE_PERS_ROLE <> 'XE'
    AND F.CD_STAGE <> 'INT'
    This query returns data when run in sqlplus.When used in a Pro*C C program and compiled the precompiler complains with syntax errors when used with EXEC SQL DECLARE CLSS82D_CURSOR CURSOR FOR < query above >.However removing the NVL function and retaining the subselect clause compiles but that is not what I want to do.
    Syntax error at line 262, column 20, file clss82d.pc:
    Error at line 262, column 20 in file clss82d.pc
    SELECT MAX( F.ID_STAGE_PERSON_LINK )
    ...................1
    PCC-S-02201, Encountered the symbol "MAX" when expecting one of the following:
    ( ) * + - / . @ | at, day, hour, minute, month, second, year,
    The symbol "(" was substituted for "MAX" to continue.
    Syntax error at line 263, column 10, file clss82d.pc:
    Error at line 263, column 10 in file clss82d.pc
    FROM STAGE_PERSON_LINK F
    .........1
    PCC-S-02201, Encountered the symbol "FROM" when expecting one of the following:
    , ) * + - / | at, day, hour, minute, month, second, year,

    Pro*C works bit differently tha sqlplus. try removing the blank line after
    SELECT MAX(G.ID_STAGE_PERSON_LINK)
    FROM STAGE_PERSON_LINK G
    WHERE G.ID_PERSON=C.ID_PERSON
    AND G.ID_CASE = C.ID_CASE
    AND G.CD_STAGE_PERS_TYPE = 'PRN')
    good luck,
    Gauranga

  • Problem Using NVL Function

    I ran across a problem with the format of an ASCI output file of an SQL script. The problem I have is with handling a particular column that contains account numbers. The column is defined with 8 characters. However not every entry has data. I have several fields that don't have any information.
    Originally in my script I had the following line that made the script fail:
    LPAD(TO_CHAR(TO_NUMBER(konten_nr)),8,'0'),
    I then changed the line to the following: (The script ran but now I notice that the formatting is wrong)
    LPAD(TO_NUMBER(LTRIM(konten_nr)),8,'0'),
    I attempted to use the NVL function that will return a value when there is nothing in the column field but it doesn't work. Does anyone know what I'm doing wrong?
    LPAD(NVL(TO_CHAR(TO_NUMBER(konten_nr),'FM999999999'),'0'),8,'0'),

    what is exactly your problem ?
    you want to translater " 1234" in "00001234" ? then simply use to_char(konten_nr,'FM00000000') .
    You want to translate " 1 1 1 1" in "01010101", then use replace(konten_nr,' ','0')
    Give us some samples

  • Binding problem when using NVL function

    Hello.
    I have a problem with my ADF application (11.1.2.1).
    I use VO with a query (database view) - pivot table.
    If i use where clause like table.attr = :p_attr, everything works ok.
    If i use where clause like table.attr = NVL (:p_attr, table.attr) and put a value in :p_attr (executeWithParam) , query executes as if there is a null value.
    Debug console shows:
    Binding null of type 12 for "p_attr".
    Query with NVL works ok in sqldeveloper.
    But in jdev, as if the table attribute isn't bind to bind variable.
    If a just remove NVL function, it works.
    Any idea?
    Thanks.
    Regards
    Edited by: DejanH on Oct 6, 2011 1:32 PM

    Hello.
    I enter 50 in p_depart parameter and click "ExecuteWithParams". Query is executed and shows records (pivot table).
    But if i look at the log window i see that an empty query was executed first.
    <OracleSQLBuilderImpl> <bindParamValue> [427] Binding null of type 12 for "p_depart"
    <OracleSQLBuilderImpl> <bindParamValue> [428] Binding null of type 12 for "p_job"
    <OracleSQLBuilderImpl> <bindParamValue> [429] Binding null of type 12 for "p_hire_od"
    <OracleSQLBuilderImpl> <bindParamValue> [430] Binding null of type 12 for "p_hire_do"
    Then, it is autoexecuted for the second time with parameter set to the value i inserted.
    <OracleSQLBuilderImpl> <bindParamValue> [470] Binding param "p_depart": 50
    <OracleSQLBuilderImpl> <bindParamValue> [471] Binding null of type 12 for "p_job"
    <OracleSQLBuilderImpl> <bindParamValue> [472] Binding null of type 12 for "p_hire_od"
    <OracleSQLBuilderImpl> <bindParamValue> [473] Binding null of type 12 for "p_hire_do"
    The same happens in our query. But ours is much more complex and it takes a lot of time to first execute "empty" query and then with inserted parameter.
    We cannot use it.
    It looks like bug.
    Regards
    Edited by: DejanH on Oct 11, 2011 6:52 AM

  • How to use nvl() function in SQL Loader

    I am trying to use nvl() funtion in my SQL Loader control file and I keep geting errors. Would someone please tell me where I can find the syntax reference to this?
    Thanks a lot!

    I just answered a similar question like this last Thursday.
    SQL*LOADER how to load blanks when data is null

  • Using NVL function in Dynamic SQL

    Hi ,
    I have created a procedure using the Dynamic SqL and while using the NVL() getting the following error . ORA-00936: missing expression.
    The query I have written as
    SQL_Txt:=' INSERT INTO VF.tblCData (A, B, C, D, E, F,G,H,I,J)
         SELECT '||l_A||',
         '||l_B||',
         '||l_C||',
              '||l_D||',
              NULL ,
              '||L_F||',
              NVL('||Param1||',''''),
              NVL('||Param2||',''''),
              NVL('||Param3||',''''),
              NULL
              FROM '||ParamTbl1||' WHERE ' ;
    and so on.
    For Param1 I have data for one execution and Param2 and Param3 is null for that execution.
    While executing the same I am getting below
    INSERT INTO VF.tblCData (A, B, C, D, E, F,G,H,I,J)
    SELECT 25,
         1,
         7,
              6,
              NULL ,
              5,
              NVL(PurchaseDate,''),
              NVL(,''),
              NVL(,''),
              NULL
              FROM xyz.PBuyer@pocdb WHERE
    and error ORA-00936: missing expression is popping up for Param2 and Param3 NVL(,'')
    Any suggestion to resolve this issue is highly appreciable.
    Thanks
    Sudipta

    NVL(,''),Where's the first argument to NVL? That's the obvious problem. Empty strings are NULL in Oracle anyway, so just lose the NVL and insert the values...
    C:\>                                                                        
    C:\>sqlplus hr/hr                                                           
    SQL*Plus: Release 11.2.0.3.0 Production on Wed May 8 10:08:53 2013          
    Copyright (c) 1982, 2011, Oracle.  All rights reserved.                     
    Connected to:                                                               
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> set NULL I_AM_NULL                                                     
    SQL> create table x(y varchar2(20));                                        
    Table created.                                                              
    SQL> insert into x values ('');                                             
    1 row created.                                                              
    SQL> select * from x;                                                       
    Y                                                                           
    I_AM_NULL                                                                   
    SQL>                                                                        

  • Decode statement using nvl function

    I have inherited some code that using a decode and nvl. I'm unsure the purpose of it and want confirmation that it is flawed logic and a mistake. The situation can be recreated by setting up the following.
    CREATE TABLE XX_TEST
    (ID NUMBER,
    FIELD VARCHAR2(255)
    INSERT INTO XX_TEST(ID,FIELD) VALUES (1,'Yes')
    INSERT INTO XX_TEST(ID,FIELD) VALUES (2,'No')
    INSERT INTO XX_TEST(ID,FIELD) VALUES (3,NULL)
    commit
    SELECT ID,
    FIELD,
    DECODE(FIELD,'Yes','Yes Result do this', NVL(FIELD,'No'),'No result do this','catch all result do this')
    FROM XX_TEST
    I'm unsure of the NVL(FIELD,'No') I think the creator maybe thought this would catch the nulls but it doesn't.
    The values Null is not converted to No and instead drops into the catch all. Can anyone help with an explaination of of how oracle is interpretting the select statement. Any ideas on why NVL would be used like this? Seems a mistake?

    Hi,
    What about this -
    SQL>
    SQL>
    SQL>
    SQL> SELECT ID,
      2  FIELD,
      3  DECODE(nvl(FIELD,'No'),'Yes','Yes Result do this','No','No result do this','catch all result do this')
      4  FROM XX_TEST;
            ID FIELD                                              DECODE(NVL(FIELD,'NO'),'
             1 Yes                                                Yes Result do this
             2 No                                                 No result do this
             3                                                    No result do this
    Elapsed: 00:00:00.00
    SQL>
    SQL>

  • Commit changes after CALL FUNCTION ... IN UPDATE TASK

    Hi ABAPers,
    I'm a bit confused about the behaviour of Update Function Modules.
    Following scenario:
    In our transaction (Modulpool with dynpros) the user clicks a butto to change some data:
    1. PAI-Modul performs FORM_A
    2. FORM_A calls FM_A several times in a LOOP
    3. FM_A does some business logic and calls FM_B IN UPDATE TASK
    4. FM_B modifies database tables
    5. After the LOOP FORM_A does COMMIT WORK AND WAIT
    Then the changes are not in the db immediately, the user will see the old data for a short time.
    Why does the COMMIT-statement not start the Update-process?
    Thanks,
    Markus

    Hi,
    This executes all high-priority update function modules registered using CALL FUNCTION ... IN UPDATE TASK in the order of their registration and in a common database LUW. If you do not specify the addition AND WAIT, the program does not wait until the update work process has executed it (asynchronous updating). If you specify the addition AND WAIT, however, program processing after COMMIT WORK will not continue until the update work process has executed the high-priority update function modules (synchronous updating).
    If all high-priority update function modules are completed successfully, the statement executes the low-priority update function modules together in a common database LUW.
    here high priority function moudles are function module with V1 task.
    Regards,
    Siva chalasani.

  • Difference between join conditions using NVL and not using NVL

    Hi,
    I have a join condition in one of the applications as follows.
    NVL(RQ.out_mesg_id,0) = NVL(RS.out_mesg_id,0)How is it different without using NVL function. What is the internal execution difference.
    RQ.out_mesg_id = RS.out_mesg_idWill there be any difference in Performance and also in the query output.
    Regards,
    Pabolu

    Pabolu wrote:
    Hi,
    I have a join condition in one of the applications as follows.
    NVL(RQ.out_mesg_id,0) = NVL(RS.out_mesg_id,0)How is it different without using NVL function. What is the internal execution difference.
    RQ.out_mesg_id = RS.out_mesg_idWill there be any difference in Performance and also in the query output.
    Regards,
    PaboluI suppose that's a bit of a trick question (or could be).
    If the column is allowed to be NULL, then your 2 queries are NOT equivalent, so comparing isn't useful since presumably you can only have one correct result :)
    However, if RQ and RS (no idea what the table names are) are both defined as having a NOT NULL constraint on the column out_mesg_id (ignoring the possibility of column level masking possible with the use of VPD here) then the optimizer could do better if you rewrote the query without the use of NVL (this would of course depend on your tables, indexes, etc ... i am merely showing you that it COULD make a difference).
    SQL> select * from v$version;
    BANNER                                                                         
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product               
    PL/SQL Release 10.2.0.1.0 - Production                                         
    CORE     10.2.0.1.0     Production                                                     
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production                        
    NLSRTL Version 10.2.0.1.0 - Production                                         
    SQL>
    SQL> create table t1 as
      2  select level as col1, case when mod(level, 10) = 0 then null else mod(level, 10) end as col2
      3  from dual connect by level <= 1000;
    Table created.
    SQL>
    SQL> alter table t1 add constraint t1_pk primary key (col1);
    Table altered.
    SQL>
    SQL> create index t1_i_001 on t1 (col2);
    Index created.
    SQL>
    SQL> exec dbms_stats.gather_table_stats(user, 'T1', cascade => true);
    PL/SQL procedure successfully completed.
    SQL>
    SQL> create table t2 as
      2  select level as col1, case when mod(level, 100) = 0 then null else mod(level, 100) end as col2
      3  from dual connect by level <= 1000;
    Table created.
    SQL>
    SQL> alter table t2 add constraint t2_pk primary key (col1);
    Table altered.
    SQL>
    SQL> create index t2_i_001 on t2 (col2);
    Index created.
    SQL>
    SQL> exec dbms_stats.gather_table_stats(user, 'T2', cascade => true);
    PL/SQL procedure successfully completed.
    SQL>
    SQL> --query using NVL
    SQL> explain plan for
      2  select count(*)
      3  from t1, t2
      4  where nvl(t1.col1, 0) = nvl(t2.col1, 0)
      5  /
    Explained.
    SQL>
    SQL> SELECT * FROM table(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT                                                              
    Plan hash value: 663667122                                                     
    | Id  | Operation              | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT       |       |     1 |     8 |     5  (20)| 00:00:01 |
    |   1 |  SORT AGGREGATE        |       |     1 |     8 |            |          |
    |*  2 |   HASH JOIN            |       |  1000 |  8000 |     5  (20)| 00:00:01 |
    |   3 |    INDEX FAST FULL SCAN| T1_PK |  1000 |  4000 |     2   (0)| 00:00:01 |
    |   4 |    INDEX FAST FULL SCAN| T2_PK |  1000 |  4000 |     2   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT                                                              
    Predicate Information (identified by operation id):                            
       2 - access(NVL("T1"."COL1",0)=NVL("T2"."COL1",0))                           
    16 rows selected.
    SQL>
    SQL> --verbose version of NVL
    SQL> explain plan for
      2  select count(*)
      3  from t1, t2
      4  where t1.col1 = t2.col1
      5  or ( (t1.col1 is null and t2.col1 = 0) or (t2.col1 is null and t1.col1 = 0) or (t1.col1 is null and t2.col1 is null) )
      6  /
    Explained.
    SQL>
    SQL> SELECT * FROM table(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT                                                              
    Plan hash value: 1043818223                                                    
    | Id  | Operation              | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT       |       |     1 |     8 |     2   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE        |       |     1 |     8 |            |          |
    |   2 |   NESTED LOOPS         |       |  1000 |  8000 |     2   (0)| 00:00:01 |
    |   3 |    INDEX FAST FULL SCAN| T1_PK |  1000 |  4000 |     2   (0)| 00:00:01 |
    |*  4 |    INDEX UNIQUE SCAN   | T2_PK |     1 |     4 |     0   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT                                                              
    Predicate Information (identified by operation id):                            
       4 - access("T1"."COL1"="T2"."COL1")                                         
    16 rows selected.So if we compare the 'verbose' version of the query, in the "predicate information" section of the explain you can see that the optimizer was able to completely ignore the
    or ( (t1.col1 is null and t2.col1 = 0) or (t2.col1 is null and t1.col1 = 0) or (t1.col1 is null and t2.col1 is null) ) condition since it knows that neither t1.col1 NOR t2.col1 columns can be null (by definition), and because of this we get a slightly different index access choice.

  • NVL function's strange behaviour

    Hi,
    I have a sql statement (listed below) that uses NVL function which returns either the business name of branch name depending on whether the business name is null or not. It also uses the branch_name pl/sql function that returns the name of the branch.
    What I found strange was that it executes the branch_name function even when the business_name is not null. It was my understanding that nvl returns expr1 if it's not null, and expr2 if expr1 is null. I don't want it to execute the branch_name function if business_name exists. Is it possible using NVL, or do I need to use DECODE to achieve that? p_record_id is a parameter that I pass to the function containing the sql statement e.g., p_record_id=10.
    SELECT nvl( business_name, branch_name( p_record_id) ) "Name"
    FROM entity
    WHERE record_id = p_record_id;
    Thanks
    Vic

    Marc,
    Thanks for looking into it.
    I just ran the code using DECODE and it seems that it executes the function only when the condition is true, which is exactly what I want. It won't execute the function if the condition is false, e.g., in the code below if the business_name is null then it executes the branch_name function, other wise it returns the business_name.
    SELECT DECODE ( business_name,
    null, branch_name( p_record_id ),
    business_name ) "Name"
    FROM entity
    WHERE record_id = p_record_id;
    Vic

  • NVL Function and Truncate Function in Template Builder

    Hi Guys,
    How would I use NVL function and Truncate function in the Word Template Builder.
    These functions do not work in the Query Builder when i use SQL Query as the Dataset while creating a report.
    I could not find examples in the Publisher Guide either.
    Thanks
    rkingmdu

    Hi
    How can you not use the functions in your query? Does the builder return an error? ow about just pasting your query into the report definition does the nvl/trunc work then ?
    Regards
    Tim
    http://blogs.oracle.com/xmlpublisher

  • Function Module or BAPI to update Sale Order Quantity (VBAP-kwmeng)

    Hi,
    I have a requirement to use a Function Module or BAPI to update Sale Order Quantity (VBAP-kwmeng), which one (Function Module or BAPI) should I use? is there any sample codes?
    Thanks a lot!!

    Hi,
    *& Report  ZTEST
    REPORT  ztest.
    DATA : wa_header TYPE bapisdh1x,
                i_item TYPE TABLE OF bapisditm WITH HEADER LINE,
                i_itemx TYPE TABLE OF bapisditmx WITH HEADER LINE,
                i_return TYPE TABLE OF bapiret2.
               wa_header-updateflag = 'U'.
               i_item-itm_number = '000010'.
               i_item-target_qty = '4'.
               APPEND i_item.
              i_itemx-itm_number = '000010'.
              i_itemx-updateflag = 'U'.
              i_itemx-target_qty = 'X'.
              APPEND i_itemx.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
      EXPORTING
        salesdocument               = '1234567890'
        order_header_inx            = wa_header
      TABLES
        return                            = i_return
        order_item_in                 = i_item
        order_item_inx               = i_itemx
    Hope this will help you.
    Regards,
    Anand.

  • ORA-00917: missing comma when using NVL

    Hi All,
    I have a INSERT statement which works fine and looks something like:
    EXECUTE IMMEDIATE
    'insert into MYTABLE(ID,TASK_ROLE, PROGRESS,SALES_PERSON) values ...
    However if I change the above piece to use NVL function like this:
    EXECUTE IMMEDIATE
    'insert into MYTABLE(ID,TASK_ROLE, NVL(PROGRESS,''0''),SALES_PERSON) values ...
    I am getting the following error:
    ORA-00917: missing comma
    Where should I enter the extra comman needed?
    Regards,
    Pawel.

    Hi these are in fact two simple quotes '. If I use only one simple quote I get an error:
    1 error has occurred
    ORA-06550: line 48, column 239: PLS-00103: Encountered the symbol "0" when expecting one of the following: * & = - + ; < / > at in is mod remainder not rem return returning <> or != or ~= >= <= <> and or like LIKE2_ LIKE4_ LIKEC_ between into using || multiset bulk member SUBMULTISET_ The symbol "* was inserted before "0" to continue.
    Same thing happens if I ommit the quotes at all and leave it like NVL(PROGRESS,0)
    Edited by: padmocho on Sep 20, 2010 11:37 AM

  • I want single update query without use the function.

    I want to update sells_table selling_code field with max date product_code from product table.
    In product table there is multiple product_code date wise.
    I have been done it with below quey with the use of function but can we do it in only one update query
    without use the function.
    UPDATE sells_table
    SET selling_code = MAXDATEPRODUCT(ctd_vpk_product_code)
    WHERE NVL(update_product_flag,0) = 0 ;
    CREATE OR REPLACE FUNCTION HVL.maxdateproduct (p_product IN VARCHAR2) RETURN NUMBER
    IS
    max_date_product VARCHAR2 (100);
    BEGIN
    BEGIN
    SELECT NVL (TRIM (product_code), 0)
    INTO max_date_product
    FROM (SELECT product_code, xref_end_dt
    FROM product
    WHERE TO_NUMBER (p_product) = pr.item_id
    ORDER BY xref_end_dt DESC)
    WHERE ROWNUM = 1; -- It will return only one row - max date product code
    EXCEPTION
    WHEN OTHERS
    THEN
    RETURN 0;
    END;
    RETURN max_date_product;
    END maxdateproduct;
    Thanks in Advance.

    Hi,
    Something like this.
    update setlls_table st
            set selling_code =(select nvl(trim(product_code)) from 
                                  (select product_code
                                          , rank() over (partition by item_id order by xref_end_dt DESC) rn
                                       from product
                                   ) pr
                                   where rn =1
                                         and pr.item_id = st.ctd_vpk_product_code
                               ) where NVL(update_product_flag,0) = 0 ;As such not tested due to lack of input sample.
    Regards
    Anurag Tibrewal.

Maybe you are looking for

  • Apple Authorized Center swapped my RAM with a fake one!

    I had given my MBP [Mid 2008] model for motherboard repairs in Mumbai, India around 6 months ago. Just recently, my MBP started making a long beep kinda sound & refused to boot up. I figured that this was a RAM problem. I went to the Apple Center to

  • Same SQL Statement Works in Data Service but not in its Input Port

    Hi Experts, I am using this query in one of my data service. Test execute success which returned:                                         E      U      H     M      L 2     Less Than 1 Week     0     0     0     0     0 3     1 - 2 weeks          0  

  • File content conversion for Pipe delimited file

    Hi i have a scenario ( file-xi-proxy) in whch file is coming in a pipe delimited. my data type is like DT_ XXXXX AwardInfo Header contains some fileds DetailRecord contains some fileds trailer contains some fields what are content conversion paramete

  • Message Driven Bean - Configuration problem

    Hi I have created the connection factory as jms/ConnectionFactory and physical destination as PhysicalQueue and queue as jms/Queue as per http://java.sun.com/j2ee/1.4/docs/tutorial/doc/MDB5.html#wp79772 http://java.sun.com/j2ee/1.4/docs/tutorial/doc/

  • PEN TOOL DOESN'T WORK ANY MORE after PS 2014.2 update!

    I just downloaded the latest Photoshop update.  Pretty slick......adjustable fonts in the dropdown menus again.....nice guide improvements.  One little problem....THE PEN TOOL DOESN'T WORK ANY MORE.  The program is totally useless.  What the h%+l is