Convert NVARCHAR2 to VARCHAR2 in select statement

I need to convert NVARCHAR2 values to VARCHAR2 in a select statement. Is this possible? The COUNTY_PARCEL_DATA colums are the NVARCHAR2 columns that need converting. I've tried TRANSLATE(COUNTY_PARCEL_DATA.SITUS_STREET_NUMBER USING CHAR_CS), CAST(COUNTY_PARCEL_DATA.SITUS_STREET_NUMBER AS VARCHAR2(100)), CONVERTCS(COUNTY_PARCEL_DATA.SITUS_STREET_NUMBER, 'CHAR_CS') and others directly in the statement for each column. Anything I'm missing? Thanks.
SELECT BENEFICIARY.NAME_FIRST || ' ' || BENEFICIARY.NAME_LAST AS NAME,
COUNTY_PARCEL_DATA.SITUS_STREET_NUMBER
|| ' '
|| COUNTY_PARCEL_DATA.SITUS_STREET_DIRECTION
|| ' '
|| COUNTY_PARCEL_DATA.SITUS_STREET_NAME
|| ' '
|| COUNTY_PARCEL_DATA.SITUS_STREET_TYPE
AS ADDRESS,
COUNTY_PARCEL_DATA.SITUS_CITY AS CITY,
'AZ' AS STATE,
COUNTY_PARCEL_DATA.SITUS_ZIP AS ZIP,
'T4' AS TRACER
FROM BENEFICIARY
LEFT OUTER JOIN
VARS_PARCEL
ON BENEFICIARY.AVNUM = VARS_PARCEL.AVNUM
LEFT OUTER JOIN
COUNTY_PARCEL_DATA
ON VARS_PARCEL.APN = COUNTY_PARCEL_DATA.APN
LEFT OUTER JOIN
OWNER
ON BENEFICIARY.BENEFICIARY_ID = OWNER.BENEFICIARY_ID
WHERE (SUBSTR (VARS_PARCEL.AVNUM, 0, 4) IN
(SELECT COLUMN_VALUE
FROM TABLE(SPLIT_STRING (
R_VARS_MAILING_NOTICES.NEIGHBORHOODS
OR R_VARS_MAILING_NOTICES.NEIGHBORHOODS IS NULL)
AND BENEFICIARY.BENEFICIARY_TYPE = 'Tenant';
Edited by: Guddie on Apr 6, 2010 12:23 PM

Are you doing the NVARCHAR2 to VARCHAR2 conversions everywhere, see comments below
SELECT BENEFICIARY.NAME_FIRST || ' ' || BENEFICIARY.NAME_LAST AS NAME,
COUNTY_PARCEL_DATA.SITUS_STREET_NUMBER                        <==== Here, obviously
|| ' '
|| COUNTY_PARCEL_DATA.SITUS_STREET_DIRECTION                <==== Here
|| ' '
|| COUNTY_PARCEL_DATA.SITUS_STREET_NAME                        <==== Here
|| ' '
|| COUNTY_PARCEL_DATA.SITUS_STREET_TYPE                        <==== Here
AS ADDRESS,
COUNTY_PARCEL_DATA.SITUS_CITY AS CITY,                            <==== Here
'AZ' AS STATE,
COUNTY_PARCEL_DATA.SITUS_ZIP AS ZIP,                                 <==== Here
'T4' AS TRACER
FROM BENEFICIARY
LEFT OUTER JOIN
VARS_PARCEL
ON BENEFICIARY.AVNUM = VARS_PARCEL.AVNUM
LEFT OUTER JOIN
COUNTY_PARCEL_DATA
ON VARS_PARCEL.APN = COUNTY_PARCEL_DATA.APN                   <==== Here, maybe not so obvious
LEFT OUTER JOIN
OWNER
ON BENEFICIARY.BENEFICIARY_ID = OWNER.BENEFICIARY_ID
WHERE (SUBSTR (VARS_PARCEL.AVNUM, 0, 4) IN
(SELECT COLUMN_VALUE
FROM TABLE(SPLIT_STRING (
R_VARS_MAILING_NOTICES.NEIGHBORHOODS
OR R_VARS_MAILING_NOTICES.NEIGHBORHOODS IS NULL)
AND BENEFICIARY.BENEFICIARY_TYPE = 'Tenant';This is assuming that all fields in COUNTY_PARCEL_DATA are NVARCHAR2.
Edited by: AlanWms on Apr 6, 2010 3:53 PM changed "joins" to "conversions" in 1st sentence.

Similar Messages

  • Convert CLOB to XMLType in SELECT statement ?

    Hi XML Xperts,
    In my Oracle 9.2.0.3 I have 1 table (tab1) with 2 cols (col1 as XMLType and col2 as CLOB). I Inserted in both fields the following same XML data :
    <?xml version="1.0"?>
    <TABLE_NAME>MY_TABLE</TABLE_NAME>
    With the following statement, I can get the data from col1 which is a XMLType column :
    SELECT a.col1.extract('//TABLE_NAME/text()').getStringVal() AS "Table Name"
    FROM tab1 a
    WHERE a.col1.existsNode('/TABLE_NAME') = 1;
    How to get the same data FROM col2 whcih is a CLOB column ? Is it possible to transform the CLOB to XMLType in the SELECT statement ?
    Note : I cannot change the type of the colulmn col2 to XMLType
    Thanks in advance.
    Phil

    I tested it in 10g and it seems to be OK.
    create table clobtoxml(xmldata clob);
    insert into clobtoxml
    values('<RootE><FirstNode>This is CLOB data to XML</FirstNode></RootE>');
    commit;
    select sys.xmltype(xmldata).extract('/RootE/FirstNode/text()').getStringVal() from clobtoxml;
    This is CLOB data to XML
    select sys.xmltype(xmldata).extract('/*') from clobtoxml;
    <RootE>
    <FirstNode>This is CLOB data to XML</FirstNode>
    </RootE>
    Ben

  • Convert sql select statement to oracle

    Hi All,
    Can anyone help me converting this Sql select statement to oracle ....
    -----------------------------------------Query--------------------------------------------------------------
    select emp_master.emp_code ,
    emp_master.dept_cd ,
    attendance_master.daily_attn_code ,
    attendance_master.linked_column ,
    case when location.payroll_status <> 'N' and eDocsNetEmployeesLeave.StartDate < dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))     
    then
    dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))
    when eDocsNetEmployeesLeave.StartDate < convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01')     
    then convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01') else eDocsNetEmployeesLeaveDetails.StartDate           
    end ,
    eDocsNetEmployeesLeaveDetails.NoOfDays,          
    case when eDocsNetEmployeesLeave.StartDate > location.next_pay_date     
    then convert(datetime , convert(varchar, dateadd(ss,-1, dateadd(mm, 1, convert(datetime , datename(yy,eDocsNetEmployeesLeave.StartDate)+ '/' + datename(mm,eDocsNetEmployeesLeave.StartDate)+ '/01') )),106) )     
    else      
    case when location.payroll_status <> 'N'
    then dateadd(mm,1,location.next_pay_date)      
    else location.next_pay_date
    end      
    end as PaymentDate               ,
    isnull(grade_master.leave_type,'C') ,
    eDocsNetEmployeesLeave.StartDate ,          
    eDocsNetEmployeesLeaveDetails.LeaveType
    from eDocsNetEmployeesLeave ,
    eDocsNetEmployeesLeaveDetails ,
    eDocsNetLeaveTypes ,
    emp_master ,
    grade_master ,
    attendance_master ,
    location
    where eDocsNetEmployeesLeaveDetails.RequestID     = eDocsNetEmployeesLeave.RequestID and
    eDocsNetEmployeesLeave.EmployeeID = emp_master.emp_code and
    eDocsNetEmployeesLeaveDetails.LeaveType = eDocsNetLeaveTypes.LeaveTypeID and
    eDocsNetLeaveTypes.loc_cd = emp_master.loc_cd and
    location.loc_cd = emp_master.loc_cd and
    attendance_master.loc_cd = emp_master.loc_cd and
    attendance_master.linked_column = eDocsNetLeaveTypes.LinkedAttendance and
    grade_master.loc_cd = emp_master.loc_cd and
    grade_master.grade_cd = emp_master.grade_cd and
    eDocsNetEmployeesLeaveDetails.RequestID      = @RequestID
    order by eDocsNetEmployeesLeaveDetails.StartDate
    Thanks in Advance
    Smiley

    Seems like you want to convert a SQL statement from the ??? dialect to the Oracle dialect. *(It would be useful to indicate the non-ANSI standard SQL you are starting with.)
    Part of the problem is that you use several date related functions. Some are unnecessary in Oracle and some need to translated into Oracle functions as found in the Functions section (chapter 5) of the SQL Reference manual at http://www.oracle.com/pls/db102/homepage
    Note that columns and expressions of type 'date' in ORacle always contain all of "yyyy mm dd hh mi ss" and you need to format and trauncate as necessary.
    Also note that '09-JAN-31' is NOT an Oracle date, but rather a character representation of a date which must be converted to/from a date expression. You will often need to use the to_date() and to_char() functions with a format mask as the second parameter. This is also descreibed in the first 2 chapters of the SQL Reference manual.

  • How to convert this select statement into update

    Hai All
    I have two table Namely Daily_attend , Train_mast
    Daily_attend Consist Of fields are Train_mast consist Of fields are
    Name varchar Train no var
    Empcode Num T_date date
    Intime Date Train_name var
    Outtime date Late_hrs var
    IND_IN Number
    IDE_OUT Number
    Attend_date date
    I need to update IDE_IN In Daily_attend table Depend upon late_hrs in the Train_mast table
    I have got Through in select statement This is my select statement
    select to_number(TO_DATE(TO_CHAR(Intime,'DD-MON-YYYY')||' '||
    TO_CHAR(0815,'0000'),'DD-MON-YYYY HH24:MI')+late_hrs/(24*60)-intime
    ) * 24*60 from dail_Att,train_mast;
    How can i convert it to update
    Any help is highly appricateable
    Thanks In Advance
    Regards
    Srikkanth.M

    Srikkanth,
    Try this code. And 1 more thing, i can't see any WHERE condition to join between the 2 tables DAIL_ATT, TRAIN_MAST.
    UPDATE DAIL_ATT A SET A.IDE_IN = (SELECT TO_NUMBER(TO_DATE(TO_CHAR(INTIME, 'DD-MON-YYYY')|| ' ' || TO_CHAR(0815, '0000'), 'DD-MON-YYYY HH24:MI') + LATE_HRS / (24 * 60) - INTIME) * 24 * 60 FROM TRAIN_MAST B WHERE <condition>);Regards,
    Manu.
    If my response or the response of another was helpful or Correct, please mark it accordingly

  • How to convert simple SQL Select statements into Stored Procedures?

    Hi,
    How can I convert following SELECT statement into a Stored Procedure?
    SELECT a.empno, b.deptno
    FROM emp a, dept b
    WHERE a.deptno=b.deptno;
    Thanking in advance.
    Wajid

    stored procedure is nothing but a named PL/SQL block
    so you can do it like this see below example
    SQL> create or replace procedure emp_details is
      2  cursor c1 is SELECT a.empno, b.deptno
      3  FROM scott.emp a, scott.dept b
      4  WHERE a.deptno=b.deptno;
      5  begin for c2 in c1
      6  LOOP
      7  dbms_output.put_line('name is '||c2.empno);
      8  dbms_output.put_line('deptno is ' ||c2.deptno);
      9  END LOOP;
    10  END;
    11  /
    Procedure created.and to call it use like below
    SQL> begin
      2  emp_details;
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on;
    SQL> /
    empno is 7839
    deptno is 10
    empno is 7698
    deptno is 30
    empno is 7782
    deptno is 10
    empno is 7566
    deptno is 20
    empno is 7654
    deptno is 30
    empno is 7499
    deptno is 30
    empno is 7844
    deptno is 30
    empno is 7900
    deptno is 30
    empno is 7521
    deptno is 30
    empno is 7902
    deptno is 20
    empno is 7369
    deptno is 20
    empno is 7788
    deptno is 20
    empno is 7876
    deptno is 20
    empno is 7934
    deptno is 10Edited by: Qwerty on Sep 17, 2009 8:37 PM

  • Select Statement - How do i convert rows to columns

    Hi, i need your help please.
    i have three options: A, B, C in table T_OPTIONS (not more and not less, it is always 3)
    no i can assign articles to this option.
    Article 1, 2, 3, 4
    in the table it looks like this
    ARTICLE_ID T_OPTIONS
    1                   A
    1                   B
    2                   C
    3                    A
    3                    C
    But now i want to have a select statement which convert rows to columns, it has to look like this
    ARTICLE A B C
    1             x x
    2             x
    3             x   x
    Can you help me!?
    Edited by: Dila on 02.08.2012 01:52
    Edited by: Dila on 02.08.2012 01:53

    Dila wrote:
    Hi, i need your help please.
    i have three options: A, B, C in table T_OPTIONS (not more and not less, it is always 3)
    no i can assign articles to this option.
    Article 1, 2, 3, 4
    in the table it looks like this
    ARTICLE_ID T_OPTIONS
    1                   A
    1                   B
    2                   C
    3                    A
    3                    C
    But now i want to have a select statement which convert rows to columns, it has to look like this
    ARTICLE A B C
    1             x x
    2             x
    3             x   x
    Can you help me!?
    Edited by: Dila on 02.08.2012 01:52
    Edited by: Dila on 02.08.2012 01:53Read {message:id=9360002} and {message:id=9360005}
    SQL> ed
    Wrote file afiedt.buf
      1  with sample_data as
      2  (
      3  select 1 ARTICLE_ID,'A' T_OPTIONS from dual union all
      4  select 1, 'B' from dual union all
      5  select 2, 'C' from dual union all
      6  select 3, 'A' from dual union all
      7  select 3, 'C' from dual
      8  )
      9   select article_id,
    10         decode(sum(case
    11                      when t_options = 'A' then 1
    12                      else 0
    13                    end), 0, null,
    14                          'X') A,
    15         decode(sum(case
    16                      when t_options = 'B' then 1
    17                      else 0
    18                    end), 0, null,
    19                          'X') B,
    20         decode(sum(case
    21                      when t_options = 'C' then 1
    22                      else 0
    23                    end), 0, null,
    24                          'X') C
    25  from   sample_data
    26* group  by article_id
    SQL> /
    ARTICLE_ID A B C
             1 X X
             2     X
             3 X   X

  • Convert long to varchar2

    Hi there,
    I am looking for a convertion, long to varchar2, in a sql statement.
    If I run the following query :
    select data_default from user_tab_columns
    It works fine in sql developper but when I execute it in my PHP code it returns:
    Notice: Undefined index: DATA_DEFAULT in /opt/lampp/htdocs/datamodel/index.php on line 64
    This issue is due in the case where the columns has null.
    So I try with the NVL function:
    select nvl(data_default, 'null') from user_tab_columns
    ORA-00932: inconsistent datatypes: expected LONG got CHAR
    I found on internet some people are using the substr function but it did not working for me.
    select substr(data_default, 1, 2000) from user_tab_columns
    ORA-00932: inconsistent datatypes: expected NUMBER got LONG
    Any one has an idea ?
    Regards !

    See this thread as well you can get an exaple user function
    ORA-00932: inconsistent datatypes
    G.

  • Convert CLOB to VARCHAR2 in Oracle 8i

    Hello all,
    I would like to convert a CLOB column from a table to a VARCHAR2.
    How can I do this?
    I would like that this works in Oracle 8i, 9i and 10g.
    Thank you very much.

    Hello APC,
    I found the problem.
    I have Oracle Reports 6i + patch 17.
    The problem was that I couldn't select a CLOB column and store his value in a CLOB variable.
    I needed to do the conversion DBMS_LOB.SUBSTR in the select statement and store his value in a VARCHAR2 variable.
    Thank you

  • Re-use SELECT statement in several procedures (other than copy-and-paste)

    Our site uses a procedure of the following procedure construct to generate Excel spreadsheets:
    TYPE retCur is REF CURSOR;
    PROCEDURE get_data_for_excel (
      p_filter1 VARCHAR2
      ,p_filter2 VARCHAR2
      ,c_OutCursor out retCur
    IS
      retCursor retcur
    BEGIN
      BEGIN
      OPEN c_OutCursor FOR
        SELECT XMLELEMENT("TR", XMLFOREST(
           "col1" AS "TD"
           ,"col2" AS "TD"
           ,"col3" AS "TD"
          )).getstringval()DATA FROM (SELECT * FROM
       SELECT col1, col2, col3
       FROM sometable
       WHERE somecolumn = p_filter1
        AND someothercolumn = p_filter2
       ) x);
      END;
    END get_data_for_excel
    My question is, the subselect:
    SELECT col1, col2, col3
    FROM sometable
    is used in another procedure. Is there a way to reuse the select from the other procedure into this procedure so we don't copy-and-paste each time the other procedure is changed?
    Thanks a lot.

    This is a design decision you need to make BEFORE it goes into production.
    Right now you have
    procedure get_data_for_excel (
       p_filter1 VARCHAR2
      ,p_filter2 VARCHAR2
      ,c_OutCursor out retCur );
    What, I think jihuyao is trying to say is:  convert it to a pipelined function.
    I agree with jihuyao as I have ran into to this problem before.
    create type d4e_t as object ( DATA xmltype);
    create type d4e_table is table of d4e_t;
    create or replace function get_data_for_excel (
       p_filter1 VARCHAR2
      ,p_filter2 VARCHAR2 )
      return d4e_table pipelined;
    as
    begin
      for curr in ( --start of SELECT statement
    SELECT XMLELEMENT("TR", XMLFOREST(
           "col1" AS "TD"
           ,"col2" AS "TD"
           ,"col3" AS "TD"
          )).getstringval()DATA FROM (SELECT * FROM
       SELECT col1, col2, col3
       FROM sometable
       WHERE somecolumn = p_filter1
        AND someothercolumn = p_filter2
       ) x) )
    LOOP
      pipe row( d4e_t( curr.data ) );
    end loop;
    return;
    end;
    From there, you use it elsewhere as if it were a table.
    insert into t
    select X.data from table( get_data_for_excel( l_var1, l_var2 ) ) X;
    MK

  • How to create a cursor on a union select statement?

    Hi,
    Using Oracle 10g RAC +ASM ( RELEASE 1002000300)
    What are is the proper way to create a cursor on a union select statement?
    Is it possible?
    code lines, Results in PLS-00201 error: sT := crsR.STATUS; sS := crsR.TIME;
    Procedure listed below:
    CREATE OR REPLACE PROCEDURE BUILD_SUMMARY IS
    CURSOR csrO IS
    SELECT
    STATUS,
    TIME
    FROM (
    SELECT
    SUBSTR(DESCRIPTION,1,50) STATUS,
    TO_CHAR(TIMESTAMP,'MM/DD/YY hh12:mi:ss') TIME
    FROM GLOBALSALES.CUBE_STATUS
    UNION ALL
    SELECT
    ' TOTAL BUILD TIME',
    TO_CHAR(TO_DATE('00:00:00','HH24:MI:SS') +(MAX(TIMESTAMP) - MIN(TIMESTAMP)), 'HH24:MI:SS')
    FROM GLOBALSALES.CUBE_STATUS);
    csrR csrO%ROWTYPE;
    sT LONG :='';
    sS LONG :='';
    BEGIN
    FOR csrR IN csrO
    LOOP
    sT := crsR.STATUS;
    sS := crsR.TIME;
    DBMS_OUTPUT.PUT_LINE(sT || ' ' || sS);
    END LOOP;
    END;
    /

    csrR csrO%ROWTYPE;
    Declares the csrR correct? Cursor Record of Cursor Object Type?That line declares one variable CSRR with your column structure described by the cursor (CSRO) type you declared above it. It means the CSRR variable has the columns you had in the SELECT statement in that cursor.
    When you run a cursor as you did you don't need to declare the record variable. Try this:
    CREATE OR REPLACE PROCEDURE build_summary IS
      CURSOR csro IS
        SELECT status, TIME
          FROM (SELECT substr(description, 1, 50) status, to_char(TIMESTAMP, 'MM/DD/YY hh12:mi:ss') TIME
                  FROM globalsales.cube_status
                UNION ALL
                SELECT ' TOTAL BUILD TIME',
                       to_char(to_date('00:00:00', 'HH24:MI:SS') + (MAX(TIMESTAMP) - MIN(TIMESTAMP)),
                               'HH24:MI:SS')
                  FROM globalsales.cube_status);
      --csrr csro%ROWTYPE;
      st   LONG := '';
      ss   LONG := '';
    BEGIN
      FOR csrr IN csro
      LOOP
        st := csrr.status;
        ss := csrr.time;
        dbms_output.put_line(st || ' ' || ss);
      END LOOP;
    END;Also why are you using LONG? It's a deprecated data type and Oracle recommends against using it. Either pick varchar2(4000) or CLOB.
    DBMS_OUTPUT.PUT_LINE will implicitly convert that LONG data type anyway.

  • Select statement operators in ecc 6.

    Hi Experts,
    I have a small doubt about the '>=' ( greater than or equal to ) operator usage in select statement. Is this operator by any chance perform not as desired in ECC 6.0. Is it a good option to use 'GE' instead of '>='. ?
    It may sound a bit awkward, but still I would like to know. I am facing a situation, which could be related to this. An early response would be highly appreciated.
    I would request,you NOT TO REPLY with links/explanations which says how to use select statement. Only answer if you have the  answers related to this query.
    Regards,
    Sandipan

    >
    Jaideep Sharma wrote:
    > Hi,
    > The only difference is GE will take a little more time than >= as system need to convert the keyword into actual operator when fetching data from Database.
    >
    > KR Jaideep,
    ????? Every Open SQL statements is translated to the SQL slang the underlying database is talking regardless if you type GE or >=
    If the result differs using >= or GE i would open a call at SAP instead of asking in SDN.

  • If I want to order by dateAdded to I have to include it in the select statement like

    If I do this:
    <cfquery name="chart" datasource="#datasource#">
    select behaviourID,score, dateAdded2 = convert(varchar,
    dateAdded , 101)
    from staff_charts_data
    where userID =
    <cfqueryparam value="#arguments.userID#"
    cfsqltype="cf_sql_integer"> AND
    NOT score = 5
    </cfquery>
    If I want to order by dateAdded to I have to include it in
    the select statement like so:
    <cfquery name="chart" datasource="#datasource#">
    select behaviourID,score, dateAdded2 = convert(varchar,
    dateAdded , 101),dateAdded
    from staff_charts_data
    where userID =
    <cfqueryparam value="#arguments.userID#"
    cfsqltype="cf_sql_integer"> AND
    NOT score = 5
    </cfquery>

    you should be able to order by dateAdded without it being in
    the select clause. The only time the order by field has to be in
    the select clause is when your query has an aggregate and group by
    clause, like this:
    select field1, field2, max(field3) as youralias
    from sometables
    where whatever
    group by field1, field2
    order by ???
    You can only order field1, field2, max(field3) or youralias.
    You can't order by field4.

  • Select statement in a smartform

    Hi
    is it possible to write a select stmt in a smartform?
    what is the use of convert data (step) in lsmw?
    thanks,
    sap-abap.

    hi,
    u can write select statement in smartforms
    <b>what is the use of convert data (step) in lsmw?</b>
    this step is used to convet the legacy system data into sap format based upon conversion rules
    if u find it useful mark the points
    Regards,
    Naveen

  • Select statement in a function does Full Table Scan

    All,
    I have been coding a stored procedure that writes 38K rows in less than a minute. If I add another column which requires call to a package and 4 functions within that package, it runs for about 4 hours. I have confirmed that due to problems in one of the functions, the code does full table scans. The package and all of its functions were written by other contractors who have been long gone.
    Please note that case_number_in (VARCHAR2) and effective_date_in (DATE) are parameters sent to the problem function and I have verified through TOAD’s debugger that their values are correct.
    Table named ps2_benefit_register has over 40 million rows but case_number is an index for that table.
    Table named ps1_case_fs has more than 20 million rows but also uses case_number as an index.
    Select #1 – causes full table scan runs and writes 38K rows in a couple of hours.
    {case}
    SELECT max(a2.application_date)
    INTO l_app_date
    FROM dwfssd.ps2_benefit_register a1, dwfssd.ps2_case_fs a2
    WHERE a2.case_number = case_number_in and
    a1.case_number = a2.case_number and
    a2.application_date <= effective_date_in and
    a1.DOCUMENT_TYPE = 'F';
    {case}
    Select #2 – runs – hard coding values makes the code to write the same 38K rows in a few minutes.
    {case}
    SELECT max(a2.application_date)
    INTO l_app_date
    FROM dwfssd.ps2_benefit_register a1, dwfssd.ps2_case_fs a2
    WHERE a2.case_number = 'A006438' and
    a1.case_number = a2.case_number and
    a2.application_date <= '01-Apr-2009' and
    a1.DOCUMENT_TYPE = 'F';
    {case}
    Why using the values in the passed parameter in the first select statement causes full table scan?
    Thank you for your help,
    Seyed
    Edited by: user11117178 on Jul 30, 2009 6:22 AM
    Edited by: user11117178 on Jul 30, 2009 6:23 AM
    Edited by: user11117178 on Jul 30, 2009 6:24 AM

    Hello Dan,
    Thank you for your input. The function is not determinsitic, therefore, I am providing you with the explain plan. By version number, if you are refering to the Database version, we are running 10g.
    PLAN_TABLE_OUTPUT
    Plan hash value: 2132048964
    | Id  | Operation                     | Name                    | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
    |   0 | SELECT STATEMENT              |                         |   324K|    33M|  3138   (5)| 00:00:38 |       |       |
    |*  1 |  HASH JOIN                    |                         |   324K|    33M|  3138   (5)| 00:00:38 |       |       |
    |   2 |   BITMAP CONVERSION TO ROWIDS |                         |     3 |     9 |     1   (0)| 00:00:01 |       |       |
    |*  3 |    BITMAP INDEX FAST FULL SCAN| IDX_PS2_ACTION_TYPES    |       |       |            |          |       |       |
    |   4 |   PARTITION RANGE ITERATOR    |                         |   866K|    87M|  3121   (4)| 00:00:38 |   154 |   158 |
    |   5 |    TABLE ACCESS FULL          | PS2_FS_TRANSACTION_FACT |   866K|    87M|  3121   (4)| 00:00:38 |   154 |   158 |
    Predicate Information (identified by operation id):
       1 - access("AL1"."ACTION_TYPE_ID"="AL2"."ACTION_TYPE_ID")
       3 - filter("AL2"."ACTION_TYPE"='1' OR "AL2"."ACTION_TYPE"='2' OR "AL2"."ACTION_TYPE"='S')
    Thank you very much,
    Seyed                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • IF-ELSE issue in Select Statement

    Hello,
    I have following query in SQL Server which I am trying to convert to Oracle 11g.
    IF '[Param.1]' = 'S' OR '[Param.1]' = 'T' THEN
    select * from ULQUEUE
    END IF
    But when I write the same query in Oracle, it gives error stating Invalid SQL Statement. So how do I incorporate IF-ELSE in Select Statement in Oracle?
    Edited by: 967327 on Oct 31, 2012 2:01 PM

    Hi,
    First of all, remove asterisk sign from the end of line
    select * from ULQUEUE;* Second: where you try to put this code? This is not SQL, but PL\SQL so you have to have some variable where you want to put query result like this:
    declare
    x ULQUEUE%Rowtype;
    begin
    select *
    into    x
    from ULQUEUE
    end; This of course works when your query returns only one row. Otherwise process data in the loop or put result into array.

Maybe you are looking for

  • 10.5.7 restart problems

    If I restart my macbook using the restart command from the apple menu, it boots to a white-ish blue-ish screen and the only way to get out of it is to hard reset (hold down power button) my macbook. It even disables my external Iomega 1TB TM drive. I

  • Screen resolution of 2nd monitor

    Dear all, i am working on an application which uses 2 monitors. i have a VI which measures the screen resolution of the screen. i want to know the screen resolution of the 2nd monitor. how can i get that ? thanks, ritesh Solved! Go to Solution.

  • 1.My itunes app list on laptop does not match my devices, how do i fix?

    Two questions... 1. my itunes app list on my laptop does not match my iphone and ipad2.  It has apps that have been deleted years ago as well as some of my wifes apps and mothers which leads me to... 2. I have setup my mom's ipad mini and wifes iphon

  • How can I get the infoset name by giving the name of a program of a query?

    How can I get the infoset name by giving the name of a program of a SAP Query? Regards, Subho

  • Internal Pricing Error in VKM3

    When i am trying to release a Sales Order for Credit Block in VKM3, I am getting the Error " Internal Pricing Error" and the msg is The program link between tables KOMT1 and XKOMV using the XKOMV-IX_KOMT1 field no longer works in the pricing program