PLW warning?

The warning is highlighted at the bold:
create or replace procedure portal_pro IS lv_count number;
BEGIN
  SELECT COUNT(*)
  INTO lv_count
  FROM portal_log
  WHERE TRUNC(logtime) = TRUNC(sysdate);
  IF lv_count > 0 THEN
    UPDATE portal_log
    SET counter = counter + 1
WHERE TRUNC(logtime) = TRUNC(sysdate);
  ELSE
    INSERT
    INTO portal_log(logtime,   counter)
    VALUES(sysdate,   1);
  END IF;
END
portal_log
===========
logtime       DATE
counter       NUMBERI got two warnings for this procedure (above). I need help in solving this 2 warning (below) .
PLW 07204
PLW 07202
Can anyone help me on this issue?

Can you expalin..?
SQL> create table portal_log(logtime date,counter number);
Table created.
SQL> create or replace procedure portal_pro IS
  2   lv_count number;
  3   BEGIN
  4    SELECT COUNT(*)
  5    INTO lv_count
  6    FROM portal_log
  7    WHERE TRUNC(logtime) = TRUNC(sysdate);
  8    IF lv_count > 0 THEN
  9      UPDATE portal_log
10      SET counter = counter + 1
11      WHERE TRUNC(logtime) = TRUNC(sysdate);
12    ELSE
13     INSERT INTO portal_log(logtime,counter)
14     VALUES(sysdate,   1);
15    END IF;
16   END;
17  /
Procedure created.Message was edited by:
jeneesh
I think you can use merge..
SQL>  merge into portal_log p
  2   using (select sysdate dt from dual) s
  3   on (TRUNC(p.logtime) =trunc(s.dt))
  4   when matched then
  5     UPDATE SET counter = counter + 1
  6   when not matched then
  7      INSERT (logtime,counter)
  8     VALUES(sysdate,   1)
  9  /
1 row merged.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Mapping Deployment Warning - ORA-06550, PLW-07204

    While deploying a mapping, I receive a warning
    ORA-06550 and PLW-07204: conversion away from column type may result in sub-optimal query plan.
    Any ideas on why this might be happening?
    Thanks!

    Hi,
    I think you are trying to conert the datatype of your column
    Amrit

  • Warning(3806,7): PLW-06002: Unreachable code

    Why do I got this warning:
    Warning(3806,7): PLW-06002: Unreachable code
    for this code:
    if p_ws = 'D' then
    raise_application_error(-20020, 'My Error');
    else -- <--Here
    return;
    end if;
    Thank you in advance.
    P.S. p_ws is of varchar2 type.

    user504063 wrote:
    Why do I got this warning:
    Warning(3806,7): PLW-06002: Unreachable code
    for this code:
    if p_ws = 'D' then
    raise_application_error(-20020, 'My Error');
    else -- <--Here
    return;
    end if;
    Thank you in advance.
    P.S. p_ws is of varchar2 type.Why return? This really seems to do nothing to me.
    Your code is identical to
    if p_ws = 'D' then
         raise_application_error(-20020, 'My Error');
    end if;So the compiler warning might be a good hint. The else part is not needed (although it is reachable...).
    Some warnings can be ignored, but in general I would try to look careful and understand what seems to disturb the compiler.
    Edited by: Sven W. on Mar 26, 2009 11:45 AM

  • Warning (22,14): PLW-07204: may not be the conversion rate as a column.....

    Good morning
    To implement the following procedure from Oracle XE not me taking the last block, which shows me the following error at line 22 -> Warning (22,14): PLW-07204: may not be the conversion of column type will result in a suboptimal query plan
    create or replace Procedure Parse_EAN( pi_EAN In Number
    , pi_Banco In Number
    , pi_Num_Cuenta In Number )
    As
    v1 utl_file.file_type;
    v2 varchar2(100);
    Begin
    v1 := utl_file.fopen('PUBLIC_ACCESS','prueb' || to_char(sysdate, 'yyyymmdd') || '.dba', 'w');
    v2 := '01' || LPAD(pi_EAN, 13, 0) || TO_CHAR(TRUNC(SYSDATE), 'YYYYMMDD') ||
    LPAD(pi_Banco, 3, 0) || LPAD(pi_Num_Cuenta, 15, 0) || ' ';
    utl_file.put_line(v1, v2);
    For rec in (SELECT '02' || LPAD(PG.CODIGO_CUENTA, 25, 0) || LPAD(PG.VALOR_PAGO, 13, 0) ||
    LPAD(PG.COD_PROCEDENCIA, 2, 0) || LPAD(ROWNUM + 1, 7, 0) || ' ' cuerpo
    FROM PAGOS PG
    WHERE PG.EAN = pi_EAN) Loop
    utl_file.put_line(v1, rec.cuerpo);
    End Loop;
    For rec in _(SELECT '09' || LPAD(COUNT(PG.CODIGO_CUENTA), 9, 0) ||_
    LPAD(SUM(PG.VALOR_PAGO), 18, 0) || ' ' final1
    FROM PAGOS PG
    WHERE PG.FECHA_PAGO = (SELECT TO_CHAR(SYSDATE,'DD/MM/YYYY') FROM DUAL)
    AND PG.EAN = pi_EAN) Loop
    utl_file.put_line(v1, rec.final1);
    End Loop;
    utl_file.fclose(v1);
    Exception
    when others then
    dbms_output.put_line(sqlerrm);
    End;
    What should I do to run the whole procedure?
    tables...
    CREATE TABLE "PAGOS"
    (     "ID_PAGOS" NUMBER NOT NULL ENABLE,
         "CODIGO_BARRAS" VARCHAR2(62),
         "EAN" NUMBER(13,0),
         "CODIGO_CUENTA" NUMBER(18,0) NOT NULL ENABLE,
         "VALOR_PAGO" NUMBER(13,0) NOT NULL ENABLE,
         "FECHA_PAGO" DATE DEFAULT SYSDATE NOT NULL ENABLE,
         "NUM_LOTE" NUMBER DEFAULT NULL NOT NULL ENABLE,
         "COD_PROCEDENCIA" NUMBER DEFAULT 1 NOT NULL ENABLE,
         "FECHA_MODIFICACION" DATE DEFAULT SYSDATE NOT NULL ENABLE,
         "MODIFICADO_POR" VARCHAR2(50) DEFAULT USER NOT NULL ENABLE,
         "NRO_DOCUMENTO" NUMBER(9,0) NOT NULL ENABLE,
         CONSTRAINT "PAGOS_PK" PRIMARY KEY ("ID_PAGOS") ENABLE,
         CONSTRAINT "PAGOS_UK2" UNIQUE ("CODIGO_CUENTA", "NUM_LOTE", "FECHA_PAGO", "VALOR_PAGO") ENABLE,
         CONSTRAINT "PAGOS_UK1" UNIQUE ("CODIGO_BARRAS", "FECHA_PAGO") ENABLE
    ALTER TABLE "PAGOS" ADD CONSTRAINT "PAGOS_PROCEDENCIA_PAGO_FK1" FOREIGN KEY ("COD_PROCEDENCIA")
         REFERENCES "PROCEDENCIA_PAGO" ("ID_PROC_PAGOS") ENABLE
    and...
    CREATE TABLE "PROCEDENCIA_PAGO"
    (     "ID_PROC_PAGOS" NUMBER NOT NULL ENABLE,
         "DESCRIPCION_PAGO" VARCHAR2(80) NOT NULL ENABLE,
         "FECHA_MODIFICACION" DATE DEFAULT SYSDATE NOT NULL ENABLE,
         "MODIFICADO_POR" VARCHAR2(60) DEFAULT USER NOT NULL ENABLE,
         CONSTRAINT "PROCEDENCIA_PAGO_PK" PRIMARY KEY ("ID_PROC_PAGOS") ENABLE,
         CONSTRAINT "PROCEDENCIA_PAGO_UK1" UNIQUE ("ID_PROC_PAGOS", "DESCRIPCION_PAGO") ENABLE,
         CONSTRAINT "PROCEDENCIA_PAGO_UK2" UNIQUE ("DESCRIPCION_PAGO") ENABLE
    CREATE OR REPLACE TRIGGER "PROCEDENCIA_PAGO_TRG"
    before insert on PROCEDENCIA_PAGO
    for each row
    BEGIN
    SELECT PROCEDENCIA_PAGO_SEQ.NEXTVAL INTO :NEW.ID_PROC_PAGOS FROM DUAL;
    END;
    ALTER TRIGGER "PROCEDENCIA_PAGO_TRG" ENABLE
    Thank you very much for your cooperation_
    GOOD DAY ..._

    this is my solution
    trunc (pi_Fecha) the variable
    truncated variable that goes into the procedure trunc (variable) Parse_ean (x, y, z, variable)
    in this case the variable that enters pi_Fecha
    create or replace
    Procedure Parse_EAN( pi_EAN In Number
    , pi_Banco In Number
    , pi_Num_Cuenta In Number
    , pi_Fecha In Date)
    As
    v1 utl_file.file_type;
    v2 varchar2(100);
    fecha varchar2(8);
    Begin
    -- Aqui inicia el bloque de proceso que generar el archivo de Acuavalle.
    IF (pi_Ean = 7709998001589) then
    v1 := utl_file.fopen('PUBLIC_ACCESS','0'|| LPAD(pi_Banco,3,0)
    || to_char(pi_Fecha, 'yyyymmdd') || '.dba', 'w');
    v2 := '01' || LPAD(pi_EAN, 13, 0) || TO_CHAR(TRUNC(pi_Fecha), 'YYYYMMDD')
    || LPAD(pi_Banco, 3, 0) || LPAD(pi_Num_Cuenta, 15, 0)
    || ' ';
    utl_file.put_line(v1, v2);
    For rec in (SELECT '02' || LPAD((PG.CODIGO_CUENTA)||(NRO_DOCUMENTO), 25, 0)
    || LPAD(PG.VALOR_PAGO, 13, 0) || LPAD(PG.COD_PROCEDENCIA, 2, 0)
    || LPAD(ROWNUM + 1, 7, 0) || ' ' cuerpo
    FROM PAGOS PG
    WHERE PG.EAN = pi_EAN) Loop
    utl_file.put_line(v1, rec.cuerpo);
    End Loop;
    select to_char(sysdate,'DD/MM/RR')
    into Fecha
    from dual;
    For rec in (Select '09'
    || LPAD(COUNT(VALOR_PAGO), 9, 0)
    || lpad(sum(PG.VALOR_PAGO), 18,0)
    ||' ' final1
    From pagos PG
    Where PG.FECHA_PAGO = pi_Fecha
    AND PG.EAN = pi_EAN) Loop
    utl_file.put_line(v1, rec.final1);
    End Loop;
    utl_file.fclose(v1);
    end if;
    -- Aqui termina el bloque de proceso que generar el archivo de Acuavalle.
    Exception
    when others then
    dbms_output.put_line(sqlerrm);
    End;
    Edited by: Rey-user6318244 on 24/03/2009 11:47 PM

  • Compiler warning PLW-05003 parameter at IN and COPY may have side effects

    For the following Procedure:
    create or replace
    PROCEDURE lob_replace
    p_lob IN OUT NOCOPY CLOB,
    p_what IN VARCHAR2,
    p_with IN VARCHAR2 )
    AS
    n NUMBER;
    BEGIN
    dbms_output.put_line('p_what = ' || p_what);
    dbms_output.put_line('p_with = ' || p_with);
    n := dbms_lob.instr( p_lob, p_what );
    dbms_output.put_line('n = ' || n);
    IF ( NVL(n,0) &gt; 0 ) THEN
    dbms_lob.copy( p_lob, p_lob, dbms_lob.getlength(p_lob), n+LENGTH(p_with), n+LENGTH(p_what) );
    dbms_lob.write( p_lob, LENGTH(p_with), n, p_with );
    IF ( LENGTH(p_what) &gt; LENGTH(p_with) ) THEN
    dbms_lob.trim( p_lob, dbms_lob.getlength(p_lob)-(LENGTH(p_what)-LENGTH(p_with)) );
    END IF;
    END IF;
    END;
    When I compile this, I receive the following warning "Warning(15,5): PLW-05003: same actual parameter(P_LOB and P_LOB) at IN and NOCOPY may have side effect"
    Line 15, column 5 is:
    dbms_lob.copy( p_lob, p_lob, dbms_lob.getlength(p_lob), n+LENGTH(p_with), n+LENGTH(p_what) );
    I'm reading about the NOCOPY Compiler hint at
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/08_subs.htm#12813 but I'm not for sure what exactly the issue is here?
    The syntax for dbms_lob.copy is:
    DBMS_LOB.COPY (
    dest_lob IN OUT NOCOPY BLOB,
    src_lob IN BLOB,
    amount IN INTEGER,
    dest_offset IN INTEGER := 1,
    src_offset IN INTEGER := 1);
    Do I need to copy the p_lob to another variable, not sure what do here?

    Hi,
    Is this really a stand alone procedure, or is it in fact part of a package?
    That warning usually comes when parameter is declared with NOCOPY in specification but without in body. Or vice versa.
    Could this be the case?
    Regards
    Peter

  • Avoiding PLW-07202 warning in SQL Developer

    Hi All,
    I am using EM Console to create package, now I have switched over to SQL Developer. When I was using EM Console, It was not showing any warning, but that same package when compiled in SQL Developer It show following warning:
    PLW-07202: bind type would result in conversion away from column type
    I want to avoid this warning to occur everytime when I compile.
    How do I do it?
    Help...

    or issue an alter session/alter system yourself or :
    http://www.oracle-base.com/articles/10g/PlsqlEnhancements10g.php#compile_time_warnings
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/errors.htm#sthref2096
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams166.htm#REFRN10249

  • Stupid PLW-07202 warning

    Hi,
    I get a stupid bunch of warning when compiling this under 11.1.0.7:
    create table test ( t varchar2(50) );
    create or replace procedure test_warn as
        BEGIN
            INSERT INTO test (t)
                 SELECT  substr('blah', 1, 2)
                           FROM dual;
      END;
    SP2-0804: Procedure created with compilation warnings
    show errors
    Errors for PROCEDURE TEST_WARN:
    LINE/COL ERROR
    6/37     PLW-07202: bind type would result in conversion away from column type
    6/40     PLW-07202: bind type would result in conversion away from column typeThe locations point to the "1" and "2" parameters in substr(). WTF???
    Thanks,
    Chris

    What is the database trying to warn me from precisely?Looks like Bug 5983734: SPURIOUS PLW-07202, which still holds in 11gR2:
    SQL> select * from v$version where rownum = 1
    BANNER                                                                         
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production         
    1 row selected.
    SQL> alter session set plsql_warnings='enable:all'
    Session altered.
    SQL> create table t (a varchar2(40))
    Table created.
    SQL> alter system flush shared_pool
    System altered.
    SQL> create or replace procedure p as
    begin
    insert into t values (substr('abc',1,2));
    end;
    Procedure created.
    SQL> show err
    Errors for PROCEDURE P
    LINE/COL ERROR                                                           
    3/37     PLW-07202: bind type would result in conversion away from column
             type                                                            
    3/39     PLW-07202: bind type would result in conversion away from column
             type                                                            
    1/1      PLW-05018: unit P omitted optional AUTHID clause; default value D
             EFINER used                                                     
    SQL> exec p
    PL/SQL procedure successfully completed.
    SQL> select  sql_text from v$sql
    where   lower(sql_text) not like '%v$sql$'
    and     lower(sql_text) like 'insert into t values%'
    SQL_TEXT                                                                       
    INSERT INTO T VALUES (SUBSTR('abc',1,2))                                       
    1 row selected.
    /* no binding takes place at all, so a message about binding seems non-sensical. */
    SQL> alter system flush shared_pool
    System altered.
    SQL> create or replace procedure p as
    s varchar2(3) := 'abc';
    s1 int := 1;
    s2 int := 1;
    begin
    insert into t values (substr(s, s1, s2));
    end;
    Procedure created.
    SQL> show err
    Errors for PROCEDURE P
    LINE/COL ERROR                                                           
    6/34     PLW-07202: bind type would result in conversion away from column
             type                                                            
    6/38     PLW-07202: bind type would result in conversion away from column
             type                                                            
    1/1      PLW-05018: unit P omitted optional AUTHID clause; default value D
             EFINER used                                                     
    SQL> exec p
    PL/SQL procedure successfully completed.
    SQL> select  sql_text from v$sql
    where   lower(sql_text) not like '%v$sql$'
    and     lower(sql_text) like 'insert into t values%'
    SQL_TEXT                                                                       
    INSERT INTO T VALUES (SUBSTR(:B3 , :B2 , :B1 ))                                
    1 row selected.
    But (1) the datatypes of the PL/SQL variables that are bound are exactly
    right for Substr(). And (2), the binding occurs in an expression that's that
    right-hand-side for "set <column> =" so there's possibility of an index
    being in use.
    */

  • PLW-07204 Warning

    We are using SQLDeveloper and almost every stored procedure I compile I get this warning. If I had it my way, I would not use SQLDeveloper but due to budget restrictions this is all I have.
    Here is the piece of code I am getting this warning on.
    select count(*)
    into dup_cnt
    FROM trans
    WHERE trans.ID_SSN = SSN_NUM
    AND trans_cd = 'DU'
    and trans_date between '01-NOV-'||to_char(to_number(to_char(sysdate,'YYYY')-1)) and trunc(sysdate);
    Thank you for taking time to look at this.
    Sandeep.

    I don't get any errors compiling it (in SQL*Plus or
    SQLDeveloper) these are only warnings, but would like
    not to get any warnings.did you get any warning message when you tried to recompile it in SQL*Plus?
    i think it might have been because your start range is ahead of end range. if your 01-NOV is always fixed you need to define some mechanism that would allow your code to use the current year or prior year if the current month is not yet in november or ahead of november which is in december.
      decode(to_char(sysdate,'MON'),'NOV', to_date('01-NOV-'||to_char(sysdate,'YYYY'),'DD-MON-YYYY'),
                                    'DEC','to_date('01-NOV-'||to_char(sysdate,'YYYY'),'DD-MON-YYYY'),
                                    to_date('01-NOV-'||to_char(to_number(to_char(sysdate,'YYYY'))-1),'DD-MON-YYYY'))

  • How do I get rid of this sql warning?

    Hi folks,
    I am running oracle 10.2.0 on Linux. I would like to get rid of this sql code warning
    (Warning(151,3): PLW-07202: bind type would result in conversion away from column type)I get when I compile the code below. Basically Oracle does not like the idea of using a number in an expression with sysdate. eg (sampling_date < sysdate - p_n_value) where p_n_value is a number;
    What is the best way to do this?
    CREATE TABLE "USERDATA"."TBL_SESSION_SQL_WAIT_HISTORY"
       (           "SESSION_SQL_WAIT_HIST_SEQ_ID" NUMBER,
                    "DBID" NUMBER,
                    "SID" NUMBER,
                    "SEQ#" NUMBER,
                    "EVENT" VARCHAR2(64 BYTE),
                    "P1TEXT" VARCHAR2(64 BYTE),
                    "P1" NUMBER,
                    "P1RAW" RAW(8),
                    "P2TEXT" VARCHAR2(64 BYTE),
                    "P2" NUMBER,
                    "P2RAW" RAW(8),
                    "P3TEXT" VARCHAR2(64 BYTE),
                    "P3" NUMBER,
                    "P3RAW" RAW(8),
                    "WAIT_TIME" NUMBER,
                    "SECONDS_IN_WAIT" NUMBER,
                    "STATE" VARCHAR2(19 BYTE),
                    "SAMPLING_DATE" DATE,
                    "SAMPLING_TIME" VARCHAR2(8 BYTE),
                    "SERIAL#" NUMBER,
                    "USERNAME" VARCHAR2(30 BYTE),
                    "OSUSER" VARCHAR2(30 BYTE),
                    "PADDR" RAW(4),
                    "LOGON_TIME" DATE,
                    "PROCESS" VARCHAR2(24 BYTE),
                    "SQL_HASH_VALUE" NUMBER,
                    "SADDR" RAW(4),
                    "MODULE" VARCHAR2(48 BYTE),
                    "ROW_WAIT_OBJ#" NUMBER,
                    "ROW_WAIT_FILE#" NUMBER,
                    "ROW_WAIT_BLOCK#" NUMBER,
                    "ROW_WAIT_ROW#" NUMBER
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 16384 NEXT 65536 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERDATA" ;
      CREATE TABLE "USERDATA"."TBL_SQLTEXT_WAIT_HISTORY"
       (           "SQLTEXT_SEQ_ID" NUMBER,
                    "DBID" NUMBER,
                    "ADDRESS" RAW(4),
                    "HASH_VALUE" NUMBER,
                    "SQL_ID" VARCHAR2(13 BYTE),
                    "COMMAND_TYPE" NUMBER,
                    "PIECE" NUMBER,
                    "SQL_TEXT_PIECE" VARCHAR2(64 BYTE),
                    "SQL_TEXT" VARCHAR2(1000 BYTE),
                    "DISK_READS" NUMBER,
                    "BUFFER_GETS" NUMBER,
                    "DIRECT_WRITES" NUMBER,
                    "PARSE_CALLS" NUMBER
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 16384 NEXT 65536 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERDATA" ;
    create or replace
    PROCEDURE data_coll AS
    p_n_value userdata.tbl_options.n_value%type;  -- number
    BEGIN
    -- irrelevant code here
      select n_value into p_n_value from tbl_options where name ='PURGE_DAY_COUNT';
      DELETE FROM tbl_sqltext_wait_history t where t.hash_value in
        (select s.sql_hash_value from cc_session_sql_wait_history s
        where s.sampling_date < sysdate  - p_n_value
        and s.sql_hash_value = t.hash_value);
      DELETE FROM tbl_session_sql_wait_history
      WHERE sampling_date < sysdate - p_n_value;
    END;Thanks in advance for your feedback.
    rgds, Efachim
    Edited by: efachim on Jan 19, 2009 10:44 AM

    One general suggestion.
    "TBL_SESSION_SQL_WAIT_HISTORY"Did you create your table and column names within double quotes?
    It will make your table as case sensitive.
    Regards.
    Satyaki De.

  • PLSQL warning

    Hi All,
    I have compiled a procedure which contains the below query, is giving the below warning...Can any one help me to get out of this issue...
    Warning(6,3): PLW-07204: conversion away from column type may result in sub-optimal query plan
    SELECT count(JOBAMTID) into l_cnt
    FROM JOBAMT, JOBDETL
    where JOBDETL.PLANTDATE= TO_NUMBER(TO_CHAR(JOBAMT.POSTINGDATE,'YYMMDD'));
    Plantdate -- NUMBER(10,0)
    Postingdate -- DATE
    Even I converted to this number type...getting same error
    Edited by: Raj Muthyala on Aug 2, 2012 3:20 PM

    Something to play with (considering your plantdate is a number) ;)
    with
    dates(plantdate) as
    (select 120802 from dual union all
    select 121314 from dual union all
    select 121100 from dual union all
    select 121101.75 from dual union all
    select 120229 from dual union all
    select 20130229 from dual union all
    select 201300.5 from dual union all
    select 20120802 from dual
    select plantdate,
           trunc(mod(trunc(plantdate),1000000)/10000) yy,
           mod(trunc(mod(trunc(plantdate),1000000)/100),100) mm,
           mod(mod(trunc(plantdate),1000000),100) dd,
           case when mod(trunc(mod(trunc(plantdate),1000000)/100),100)
                     between 1
                         and 12
                then case when mod(mod(trunc(plantdate),1000000),100)
                     between 1
                         and to_number(to_char(last_day(to_date(to_char(trunc(mod(trunc(plantdate),
                                                                                  1000000
                                                                                 ) / 10000
                                                                       ) ||
                                                                lpad(to_char(mod(trunc(mod(trunc(plantdate),
                                                                                           1000000
                                                                                          ) / 100
                                                                                 100
                                                                     2,
                                                                     '0'
                                                                'yymm'
                                               'dd'
                          then to_date(to_char(trunc(mod(trunc(plantdate),
                                                         1000000
                                                        ) / 10000
                                              ) ||
                                       lpad(to_char(mod(trunc(mod(trunc(plantdate),
                                                                  1000000
                                                                 ) / 100
                                                        100
                                            2,
                                            '0'
                                           ) ||
                                       lpad(to_char(mod(mod(trunc(plantdate),
                                                            1000000
                                                        100
                                            2,
                                            '0'
                                       'yymmdd'
                     end
           end the_date
      from datesRegards
    Etbin

  • PLW-07204: conversion away from column type may result in sub-optimal query

    I have the following query in the package that created using sql developer. I am receiving the error 'PLW-07204: conversion away from column type may result in sub-optimal query plan' when try to compile the package. The issue is happen to be in the last line where the date is. Any help? Thanks
    select count(*) into n_cnt
    from tmp_order
    where sgn_off_dt is null and cmt_dt is not null
    and sysdate - cmt_dt > 90;

    Sy:
    Try doing as a procedure instead of an anonymous block. It looks like warnings do not apply to blocks.
    SQL> create table tmp_order(sgn_off_dt date,cmt_dt date);
    Table created.
    SQL> alter session set plsql_warnings='ENABLE:ALL';
    Session altered.
    SQL> create procedure p as
      2     n_cnt number;
      3  begin
      4     select count(*) into n_cnt
      5     from tmp_order
      6     where sgn_off_dt is null and
      7           cmt_dt is not null and
      8           sysdate - cmt_dt > 90;
      9  end;
    10  /
    SP2-0804: Procedure created with compilation warnings
    SQL> show err
    Errors for PROCEDURE P:
    LINE/COL ERROR
    8/18     PLW-07204: conversion away from column type may result in
             sub-optimal query planlindalop:
    In this case, you can ignore the warning, as it is not correct. Sysdate and a date column have different internal data types (note the type 13 for sysdate and type 12 for the date column), and whatever internally generates the warnings seems to just compare the type number.
    SQL> insert into tmp_order values(sysdate, sysdate);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select dump(sysdate) sdate, dump(cmt_dt) cmt_dt from tmp_order;
    SDATE                             CMT_DT
    Typ=13 Len=8: 7,219,2,3,15,44,4,0 Typ=12 Len=7: 120,111,2,3,16,44,12However, Oracle is perfectly capable of using an index on a date column with sysdate as a predicate. I would agree with Sy's suggestion to re-work the predicate to be something like cmt_dt < sysdate - 90.
    John

  • PLW-07202: bind type would result in conversion away from column type

    Got this error, "PLW-07202: bind type would result in conversion away from column type", when compiling in the stored procedure editor.
    CREATE OR REPLACE
    procedure test_proc (at_incoming varchar)
    as begin
    insert into test2(itemname) values (substr('1234',1,2));
    end;
    The table test2 was created like this:
    CREATE TABLE "DMSCO"."TEST2"
    (     "ITEMNAME" VARCHAR2(30),
         "ITEM2" VARCHAR2(10),
         "ITEMNUM" NUMBER(10,0)
    Removed the substr, and it compiles.
    CREATE OR REPLACE
    procedure test_proc (at_incoming varchar)
    as begin
    insert into test2(itemname) values ('1234');
    end;
    In sqlplus it compiles fine even with the substr.

    PLW-07202: is a warning. There's a bug that it's showing as an error.
    -kris

  • Warning message in 10g related to timestamp

    select * from v$version;
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    create table jtime(jtime timestamp with time zone);
    create or replace procedure jtimePro as
    begin
    insert into jtime values(systimestamp);
    end jtimePro;
    Assuming I compile it via SQL Developer I get a message of
    Warning(3,28): PLW-07202: bind type would result in conversion away from column type
    I did check the return type on systimestamp it is a timestamp with time zone.
    I also different column type of just timestamp with the same warning message. Any ideas how to use a timestamp or timestamp with time zone datatype and not get a warning message?
    Also how do I see the warning messages in sql+ there is no 'show warnings'
    Thanks

    SQL> alter session set PLSQL_WARNINGS = 'enable:ALL' ;
    Session altered.
    SQL> create table jtime(jtime timestamp with time zone);
    Table created.
    SQL> create or replace procedure jtimePro as
      2  begin
      3  insert into jtime values(systimestamp);
      4  end jtimePro;
      5  /
    SP2-0804: Procedure created with compilation warnings
    SQL> show errors
    Errors for PROCEDURE JTIMEPRO:
    LINE/COL ERROR
    3/26     PLW-07202: bind type would result in conversion away from column
             type
    SQL> create or replace procedure jtimePro as
      2      dt_tz timestamp with time zone ;
      3  begin
      4      dt_tz := systimestamp ;
      5  insert into jtime values(dt_tz);
      6  end jtimePro;
      7  /
    Procedure created.
    SQL> show errors
    No errors.
    SQL>

  • PLW-06015 when compilling for debug

    Hi,
    I have the error message: "Warning(1): PLW-06015: parameter PLSQL_DEBUG is deprecated; use PLSQL_OPTIMIZE_LEVEL = 1"
    each time I compile for debug.
    The Oracle database parameters are
    plsql_warnings ENABLE:ALL
    plsql_debug FALSE
    plsql_optimize_level 2
    So Why do I have this message?
    Seb

    Yes,
    I can modify everything under Database - PL/SQL Compiler.
    Optimization Level is already set to 2.
    Here are the other preferences:
    ALL: ENABLE
    INFORMATIONAL: not set
    SEVERE: not set
    PERFORMANCE: not set
    PLScope identifiers: All
    The user for the schema has the DEBUG CONNECT SESSION.
    When I change Optimization level to 1 and compile or compile for debug, I always receive the warning message.
    When I change Optimization level to 2, I always receive the warning message only when I compile for debug,
    In case of, the SQL developer version I use is Version 2.1.1.64 Build MAIN-64.39.
    Seb

  • PLW 07204 and PLW 07202 ?

    CREATE OR REPLACE PROCEDURE library_portal_home(ldt portal_home_non_login_log.logdatetime%TYPE, COT portal_home_non_login_log.counter%TYPE) IS
    lv_count NUMBER;
    BEGIN
    SELECT COUNT(1)
    INTO lv_count
    FROM portal_home_non_login_log
    WHERE to_char(logdatetime, 'dd-mm-yyyy ') = to_char(sysdate, 'dd-mm-yyyy ');
    IF lv_count > 0 THEN
    UPDATE portal_home_non_login_log
    SET counter = counter + 1
    WHERE to_char(logdatetime, 'dd-mm-yyyy ') = to_char(sysdate, 'dd-mm-yyyy ');
    ELSE
    INSERT
    INTO portal_home_non_login_log(logdatetime, counter)
    VALUES(sysdate, 1);
    DBMS_OUTPUT.PUT_LINE('ONE RECORD IS ADDED......!');
    END IF;
    COMMIT;
    END;
    I got 2 warning when i compile for debug.
    Warning PLW 07204
    Warning PLW 07202
    Would this 2 warning affect the procedure and how do I solve it?

    create or replace PROCEDURE in_focus_page(ldt infocus_log.logdatetime%TYPE, COT infocus_log.counter%TYPE) IS
    lv_count NUMBER;
    BEGIN
    SELECT COUNT(1)
    INTO lv_count
    FROM infocus_log
    WHERE TRUNC(logdatetime) = TRUNC(sysdate);
    IF lv_count > 0 THEN
    UPDATE infocus_log
    SET counter = counter + 1
    WHERE TRUNC(logdatetime) = TRUNC(sysdate);
    ELSE
    INSERT
    INTO infocus_log(logdatetime, counter)
    VALUES(sysdate, 1);
    DBMS_OUTPUT.PUT_LINE('ONE RECORD IS ADDED......!');
    END IF;
    COMMIT;
    END;
    I still have same 2 warning. First one is PLW 07204 and other one is PLW 07202. (bold)
    Thanks in Advance

Maybe you are looking for

  • Client comparision which are in two different systems

    hi here there is a different issue this time .... we have two different clients (100 & 800) in two different  ecc servers. in both of these servers in 100 of system-1 and 800 of system-2 ,,, implementation is done. so now the problem is we have to co

  • Update query for jstl

    Hi I have one jsp page which shows values for id, name, Phone in text boxes. Here id is unique and not editable. Based on id a user can edit name and Phone # and when he submits it should be updated in the db where id = xxx. <c:set var="i"   value="$

  • IPhone 6 doesn't flash?

    I have an iPhone 6 and want to take a picture under low light conditions (of Christmas tree) but when I set the flash to "on" in the camera app it never flashes and the photos are very dark. Also tried Auto and that doesn't work either. How can I get

  • Import metadata file for FDM

    When I import the metadata file (including mapping) for FDM, I find that the mapping are not replacing the existing ones, but merging instead. Is there a way to clear all the mapping tables before importing the new metadata xml file ? Thanks.

  • My imsg is not working with only one person and her imsg is working perfectly fine with her friends

    My imsg is not working with only one person and her imsg is working perfectly fine with her friends