Package constant in select statement

In my Package has several consatnt values...
CREATE OR REPLACE PACKAGE xoec IS
EXPIRED_DESC CONSTANT VARCHAR2(20) := 'Expired';
LIVE CONSTANT VARCHAR2(1) := 'L';
LIVE_DESC CONSTANT VARCHAR2(20) := 'Live';
CANCELLED CONSTANT VARCHAR2(1) := 'X';
CANCELLED_DESC CONSTANT VARCHAR2(20) := 'Cancelled';
END ;
I want to display the constant in Select statement.
select xoec.live from dual;
The above statement through error.
Please help to fix it.
Regards
Mani

This is one of examples.
CREATE OR REPLACE PACKAGE xoec IS
  EXPIRED_DESC CONSTANT VARCHAR2(20) := 'Expired';
  LIVE CONSTANT VARCHAR2(1) := 'L';
  LIVE_DESC CONSTANT VARCHAR2(20) := 'Live';
  CANCELLED CONSTANT VARCHAR2(1) := 'X';
  CANCELLED_DESC CONSTANT VARCHAR2(20) := 'Cancelled';
  function get(in_vc varchar2) return varchar2;
END ;
CREATE OR REPLACE
PACKAGE BODY xoec IS
  function get(in_vc varchar2) return varchar2
  is
  begin
    if    upper(in_vc) = 'EXPIRED_DESC' then
       return EXPIRED_DESC;      
    elsif upper(in_vc) = 'LIVE' then
       return LIVE;
    elsif upper(in_vc) = 'LIVE_DESC' then
       return LIVE_DESC;
    elsif upper(in_vc) = 'CANCELLED' then
       return CANCELLED;
    elsif upper(in_vc) = 'CANCELLED_DESC' then
       return CANCELLED_DESC;
    else
       null; -- somthing error raising
    end if;
  end;
END;
SQL> select xoec.get('live') from dual;
XOEC.GET('LIVE')
L

Similar Messages

  • What is the change occured by using the package in select statement

    Hi all,
    Can some one please tell me using the following package in the select statement of the view does it restricts the data or fetches the data
    what is the change occurred using the package for fetching the date column
    hr_discoverer.check_end_date (per_assignments_f.effective_end_date)
    Thanks in advance

    You can check the code -
    -- this function checks to see if a date is equivalent to the end of time(31-Dec-4712)
    -- if this is true it will return null else the actual end-date
    Cheers,
    Vignesh

  • Package size in select query

    Hi all,
    Can any body help for how to use package size in select statemtent.
    I want to seletc record in lot of 300 form 10k records.
    And i am using 4.6c version and wnat to know this statement (package size) is there in 4.6c.
    I know it is in 6.0.

    Hi
    Package size in SELECT statements
    Package size can be used to retreive a spcific number of records at a time. This can be used if you
    for example only want tofinish  processing a limited amount of data at a time due to lack of memory.
    The exampel below  read 50 records at a time from VBAK into an internal table, and selects the
    corresponding entries from vbap into an internal table. Then the two internal tables can be
    processed, and the next 50 records from VBAk can be read. remeber to reinitialize tha tables before
    the next read.
    Note the usage of SELECT - ENDSELECT !
    REPORT  z_test                        .
    TYPES:
    BEGIN OF t_vbak,
    vbeln LIKE vbak-vbeln,
    erdat LIKE vbak-erdat,
    END OF t_vbak,
    BEGIN OF t_vbap,
    posnr  LIKE vbap-posnr,
    matnr  LIKE vbap-matnr,
    meins  LIKE vbap-meins,
    END OF t_vbap,
    BEGIN OF t_report,
    vbeln LIKE vbak-vbeln,
    erdat LIKE vbak-erdat,
    posnr  LIKE vbap-posnr,
    matnr  LIKE vbap-matnr,
    meins  LIKE vbap-meins,
    END OF t_report.
    DATA:
    li_vbak   TYPE t_vbak OCCURS 0,
    l_vbak    TYPE  t_vbak,
    li_vbap   TYPE t_vbap OCCURS 0,
    l_vbap    TYPE t_vbap,
    li_report TYPE t_report OCCURS 0,
    l_report  TYPE t_report.
    START-OF-SELECTION.
    SELECT vbeln erdat
    FROM vbak
    INTO TABLE li_vbak PACKAGE SIZE 50.
    SELECT posnr matnr meins
    FROM vbap
    INTO TABLE li_vbap
    FOR ALL ENTRIES IN li_vbak
    WHERE vbeln = li_vbak-vbeln.
    IF sy-subrc = 0.
      Now you have the two internal tables li_vbak and liÆ_vbap filled with data.
      Do something with the data - remember to reinitialize internal tables
    ENDIF.
    ENDSELECT.
    All of the  product names here are trademarks of their respective companies.  The site
    www.allsaplinks.com no way affiliated with SAP AG. We have made every effort for the content
    integrity.  Information used on this site is at your own risk.
              +
    REWARD IF USEFULL+ 

  • Accessing package CONSTANT in a SQL query

    Hi,
    Can anybody explain why I cannot access the package constant in a SQL but can use it in dbms_output.put_line:
    SQL> create package scott.xx_test_const_pkg
    2 as
    3 a constant varchar2(1) :='A';
    4 end;
    5 /
    Package created.
    SQL> begin
    2 dbms_output.put_line( scott.xx_test_const_pkg.a);
    3 end;
    4 /
    A <------------------THIS WORKS
    PL/SQL procedure successfully completed.
    SQL> select * from scott.emp where ename=scott.xx_test_const_pkg.a;
    select * from scott.emp where ename=scott.xx_test_const_pkg.a <------------------THIS DOES NOT WORK
    ERROR at line 1:
    ORA-06553: PLS-221: 'A' is not a procedure or is undefined
    Thanks

    You can't refer to a pl/sql package constant in a sql statement.
    Create a function that returns the constant value and then refer to the function in a sql statement.

  • Using package constant in SQL

    I am trying to use a package constant in a query as follows:
    SELECT field1 FROM table t WHERE CEIL(sysdate - t.field2) > schema.package.constant
    field1 is a name
    field2 is a timestamp
    constant is an integer indicating the expiration time in days
    basically I am trying to find all expired items.
    I get the error "ORA-06553: PLS-221: 'constant' is not a procedure or is undefined" on this query.
    I use this same query as a cursor in the package itself with no errors.

    Unfortunately you cannot directly use package global variables in select statements like this.
    One workaround is to use bind variables for that:
    <p>
    SQL> CREATE OR REPLACE PACKAGE pkg
    AS
       myconstant   VARCHAR (20) := 'This is my constant';
    END pkg;
    Package created.
    SQL> VAR myconstant  VARCHAR2 (20)
    SQL> EXEC :myconstant :=  pkg.myconstant
    PL/SQL procedure successfully completed.
    SQL> SELECT :myconstant
      FROM DUAL
    :MYCONSTANT                                                                    
    This is my constant                                                            

  • Package procedure in invalid state

    Hi all,
    We are having an application in C# and backend oracle 10g placed in Location1.
    There is modification in Packaged procedure. So we remotely (from Location2) connected to Location1 and that Packaged procedure is created.
    This Packaged procedure has been created (in Location1 ) without any errors. But this procedure is in INVALID state. We tried to compile it remotely by using following statements, but still this is in invalid state .
    ALTER PACKAGE my_package COMPILE;
    ALTER PACKAGE my_package COMPILE BODY;
    If we run this package and package body manually, without any modifications after creating it remotly, it is becoming VALID state.
    I am not getting any idea, why it is creating in INVALID state. Any help is appreciated.
    Thanks in advance,
    Pal

    Ok, here's a previous response that I gave re. packages and their "states". Should give you a good idea what a state is...
    Packages tend to fail because of their "package state". A package has a "state" when it contains package level variables/constants etc. and the package is called. Upon first calling the package, the "state" is created in memory to hold the values of those variables etc. If an object that the package depends upon e.g. a table is altered in some way e.g. dropped and recreated, then because of the database dependencies, the package takes on an INVALID status. When you next make a call to the package, Oracle looks at the status and sees that it is invalid, then determines that the package has a "state". Because something has altered that the package depended upon, the state is taken as being out of date and is discarded, thus causing the "Package state has been discarded" error message.
    If a package does not have package level variables etc. i.e. the "state" then, taking the same example above, the package takes on an INVALID status, but when you next make a call to the package, Oracle sees it as Invalid, but knows that there is no "state" attached to it, and so is able to recompile the package automatically and then carry on execution without causing any error messages. The only exception here is if the thing that the package was dependant on has changes in such a way that the package cannot compile, in which case you'll get an Invalid package type of error.
    And if you want to know how to prevent discarded package states....
    Move all constants and variables into a stand-alone package spec and reference those from your initial package. Thus when the status of your original package is invlidated for whatever reason, it has no package state and can be recompiled automatically, however the package containing the vars/const will not become invalidated as it has no dependencies, so the state that is in memory for that package will remain and can continue to be used.
    As for having package level cursors, you'll need to make these local to the procedures/functions using them as you won't be able to reference cursors across packages like that (not sure about using REF CURSORS though.... there's one for me to investigate!)
    This first example shows the package state being invalided by the addition of a new column on the table, and causing it to give a "Package state discarded" error...
    SQL> set serveroutput on
    SQL>
    SQL> create table dependonme (x number)
      2  /
    Table created.
    SQL>
    SQL> insert into dependonme values (5)
      2  /
    1 row created.
    SQL>
    SQL> create or replace package mypkg is
      2    procedure myproc;
      3  end mypkg;
      4  /
    Package created.
    SQL>
    SQL> create or replace package body mypkg is
      2    v_statevar number := 5; -- this means my package has a state
      3
      4    procedure myproc is
      5      myval number;
      6    begin
      7      select x
      8      into myval
      9      from dependonme;
    10
    11      myval := myval * v_statevar;
    12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
    13    end;
    14  end mypkg;
    15  /
    Package body created.
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALID
    SQL>
    SQL>
    SQL> alter table dependonme add (y number)
      2  /
    Table altered.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    BEGIN mypkg.myproc; END;
    ERROR at line 1:
    ORA-04068: existing state of packages has been discarded
    ORA-04061: existing state of package body "CRISP_INTELL.MYPKG" has been invalidated
    ORA-06508: PL/SQL: could not find program unit being called: "CRISP_INTELL.MYPKG"
    ORA-06512: at line 1
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALIDAnd this next example shows how having the package variables in their own package spec, allows the package to automatically recompile when it is called even though it became invalidated by the action of adding a column to the table.
    SQL> drop table dependonme
      2  /
    Table dropped.
    SQL>
    SQL> drop package mypkg
      2  /
    Package dropped.
    SQL>
    SQL> set serveroutput on
    SQL>
    SQL> create table dependonme (x number)
      2  /
    Table created.
    SQL>
    SQL> insert into dependonme values (5)
      2  /
    1 row created.
    SQL>
    SQL> create or replace package mypkg is
      2    procedure myproc;
      3  end mypkg;
      4  /
    Package created.
    SQL>
    SQL> create or replace package mypkg_state is
      2    v_statevar number := 5; -- package state in seperate package spec
      3  end mypkg_state;
      4  /
    Package created.
    SQL>
    SQL> create or replace package body mypkg is
      2    -- this package has no state area
      3
      4    procedure myproc is
      5      myval number;
      6    begin
      7      select x
      8      into myval
      9      from dependonme;
    10
    11      myval := myval * mypkg_state.v_statevar;  -- note: references the mypkg_state package
    12      DBMS_OUTPUT.PUT_LINE('My Result is: '||myval);
    13    end;
    14  end mypkg;
    15  /
    Package body created.
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        VALID
    SQL>
    SQL> alter table dependonme add (y number)
      2  /
    Table altered.
    SQL>
    SQL> select object_name, object_type, status from user_objects where object_name = 'MYPKG'
      2  /
    OBJECT_NAME
    OBJECT_TYPE         STATUS
    MYPKG
    PACKAGE             VALID
    MYPKG
    PACKAGE BODY        INVALID
    SQL>
    SQL> exec mypkg.myproc
    My Result is: 25
    PL/SQL procedure successfully completed.

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to get the value from a function using a select statement

    I have a function(user defined not built in) that returns multiple values(like an array). My question is how do i get those values in a select statement. when i tried to retrieve it,
    select pack.my_members from dual;
    i am getting an error
    ORA-00902: invalid datatype
    I am sure this must be a syntax error with the select statement
    The following is the function that give the array of data
    package pack
    package spec
    Type my_table is table of varchar2(25);
    function the_members
    return pack.my_table;
    pakcage body
    function the_members return pack.my_table
    Remarks: This function returns a table containing names of the
    members
    is
    tm pack.my_table:= pack.my_table('first member','second member','third member','fourth member');
    begin
    return tm;
    end the_members;

    Check this example on Pipelinedfunction

  • Return multiple values from a function to a SELECT statement

    I hope I've provided enough information here. If not, just let me know what I'm missing.
    I am creating a view that will combine information from a few tables. Most of it is fairly straightforward, but there are a couple of columns in the view that I need to get by running a function within a package. Even this is fairly straightforward (I have a function named action_date in a package called rp, for instance, which I can use to return the date I need via SELECT rp.action_date(sequence_number).
    Here's the issue: I actually need to return several bits of information from the same record (not just action_date, but also action_office, action_value, etc.) - a join of the tables won't work here as I'll explain below. I can, of course, run a separate function for each statement but that is obviously inefficient. Within the confines of the view select statement however, I'm not sure how to return each of the values I need.
    For instance, right now, I have:
    Table1:
    sequence_number NUMBER(10),
    name VARCHAR(30),
    Table2:
    Table1_seq NUMBER(10),
    action_seq NUMBER(10),
    action_date DATE,
    action_office VARCHAR(3),
    action_value VARCHAR(60),
    I can't simply join Table1 and Table2 because I have to do some processing in order to determine which of the matching returned rows I actually need to select. So the package opens a cursor and processes each row until it finds the one that I need.
    The following works but is inefficient since all of the calls to the package will return columns from the same record. I just don't know how to return all the values I need into the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    rp.action_date(sequence_number) action_date,
    rp.action_office(sequence_number) action_office,
    rp.action_value(sequence_number) action_value
    FROM table1
    Is there a way to return multiple values into my SELECT statement or am I going about this all wrong?
    Any suggestions?
    Thanks so much!

    Hi,
    What you want is a Top-N Query , which you can do using the analytic ROW_NUMBER function in a sub-query, like this:
    WITH     got_rnum     AS
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;As written, this will return (at most) one row.
    I suspect you'll really want to get one row for each group , where a group is defined by some value in a table to which you're joining.
    In that case, add a PARTITION BY clause to the ROW_NUMBER function.
    If you'd post a little sample data (CREATE TABLE and INSERT statements), I could show you exactly how.
    Since I don't have your tables, I'll show you using tables in the scott schema.
    Here's a view that has data from the scott.dept table and also from scott.emp, but only for the most senior employee in each department (that is, the employee with the earliest hiredate). If there happens to be a tie for the earliest hiredate, then the contender with the lowest empno is chosen.
    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    SELECT     *
    FROM     senior_emp
    ;Output:
    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81 
    By the way, one of the conditions in the query you posted was
    action_office     LIKE 'E'which is equivalent to
    action_office     = 'E'(LIKE is always equivalent to = if the string after LIKE doesn't contain any wildcards.)
    Did you mean to say that, or did you mean something like this:
    action_office     LIKE 'E%'instead?

  • Performance Issue in Select Statement (For All Entries)

    Hello,
    I have a report where i have two select statement
    First Select Statement:
    Select A B C P Q R
         from T1 into Table it_t1
              where ....
    Internal Table it_t1 is populated with 359801 entries through this select statement.
    Second Select Statement:
    Select A B C X Y Z
         from T2 in it_t2 For All Entries in it_t1
              where A eq it_t1-A
                 and B eq it_t1-B
                 and C eq it_t1-C
    Now Table T2 contains more than 10 lac records and at the end of select statement it_t2 is populated with 844003 but it takes a lot of time (15 -20 min) to execute second select statement.
    Can this code be optimized?
    Also i have created respective indexes on table T1 and T2 for the fields in Where Condition.
    Regards,

    If you have completed all the steps mentioned by others, in the above thread, and still you are facing issues then,.....
    Use a Select within Select.
    First Select Statement:
    Select A B C P Q R package size 5000
         from T1 into Table it_t1
              where ....
    Second Select Statement:
    Select A B C X Y Z
         from T2 in it_t2 For All Entries in it_t1
              where A eq it_t1-A
                 and B eq it_t1-B
                 and C eq it_t1-C
    do processing........
    endselect
    This way, while using for all entries on T2, your it_t1, will have limited number of entries and thus the 2nd select will be faster.
    Thanks,
    Juwin

  • Dynamic WHERE clause in SELECT statement

    Hi,
    I need to extract (SELECT) all the products in different salesorganizations. Since a product can be available in more than 1 salesorg I have created several properties in the PRODUCT dimension - 1 for each salesorganization (naming: Sxxxx where xxxx is the salesorganization number).
    Since I need to prefix the salesorganization property with an "S" I have created a property on the SALESORG dimension called SALESORG.
    Therefore I need to create a dynamic WHERE clause in the SELECT statement. Currently my script is:
    *SELECT(%SORG%, "[SALESORG]",SALESORG, [ID]=%SALESORG_SET%)
    *SELECT(%PROD%, "[ID]",PRODUCT, [%SORG%]="X")
    My first SELECT find the Sxxx (equal to the property I need in the PRODUCT dimension). My second SELECT uses the variable in the first SELCT statement to use the correct property for the WHERE clause.
    Unfortunately the code is not validated - any suggestions?
    /Lars

    Hi Lars,
    If you run it from a DM package without validating it, does it still work? I would bet it does.
    If this is the case I would open a message with SAP (it would be an enhancement request). Until they fix the validation code, you would just have to live with the script not validating.
    Cheers,
    Ethan

  • Increase performance of the following SELECT statement.

    Hi All,
    I have the following select statement which I would want to fine tune.
      CHECK NOT LT_MARC IS INITIAL.
      SELECT RSNUM
             RSPOS
             RSART
             MATNR
             WERKS
             BDTER
             BDMNG FROM RESB
                          INTO TABLE GT_RESB 
                          FOR ALL ENTRIES IN LT_MARC
                          WHERE XLOEK EQ ' '
                          AND MATNR EQ LT_MARC-MATNR
                          AND WERKS EQ P_WERKS
                          AND BDTER IN S_PERIOD.
    The following query is being run for a period of 1 year where the number of records returned will be approx 3 million. When the program is run in background the execution time is around 76 hours. When I run the same program dividing the selection period into smaller parts I am able to execute the same in about an hour.
    After a previous posting I had changed the select statement to
      CHECK NOT LT_MARC IS INITIAL.
      SELECT RSNUM
             RSPOS
             RSART
             MATNR
             WERKS
             BDTER
             BDMNG FROM RESB
                          APPENDING TABLE GT_RESB  PACKAGE SIZE LV_SIZE
                          FOR ALL ENTRIES IN LT_MARC
                          WHERE XLOEK EQ ' '
                          AND MATNR EQ LT_MARC-MATNR
                          AND WERKS EQ P_WERKS
                          AND BDTER IN S_PERIOD.
      ENDSELECT.
    But the performance improvement is very negligible.
    Please suggest.
    Regards,
    Karthik

    Hi Karthik,
    <b>Do not use the appending statement</b>
    Also you said if you reduce period then you get it quickly.
    Why not try dividing your internal table LT_MARC into small internal tables having max 1000 entries.
    You can read from index 1 - 1000 for first table. Use that in the select query and append the results
    Then you can refresh that table and read table LT_MARC from 1001-2000 into the same table and then again execute the same query.
    I know this sounds strange but you can bargain for better performance by increasing data base hits in this case.
    Try this and let me know.
    Regards
    Nishant
    > I have the following select statement which I would
    > want to fine tune.
    >
    >   CHECK NOT LT_MARC IS INITIAL.
    > SELECT RSNUM
    >          RSPOS
    > RSART
    >          MATNR
    > WERKS
    >          BDTER
    > BDMNG FROM RESB
    >                       INTO TABLE GT_RESB 
    > FOR ALL ENTRIES IN LT_MARC
    >                       WHERE XLOEK EQ ' '
    > AND MATNR EQ LT_MARC-MATNR
    >                       AND WERKS EQ P_WERKS
    > AND BDTER IN S_PERIOD.
    >  
    > e following query is being run for a period of 1 year
    > where the number of records returned will be approx 3
    > million. When the program is run in background the
    > execution time is around 76 hours. When I run the
    > same program dividing the selection period into
    > smaller parts I am able to execute the same in about
    > an hour.
    >
    > After a previous posting I had changed the select
    > statement to
    >
    >   CHECK NOT LT_MARC IS INITIAL.
    > SELECT RSNUM
    >          RSPOS
    > RSART
    >          MATNR
    > WERKS
    >          BDTER
    > BDMNG FROM RESB
    > APPENDING TABLE GT_RESB
    >   PACKAGE SIZE LV_SIZE
    >                     FOR ALL ENTRIES IN LT_MARC
    >   WHERE XLOEK EQ ' '
    >                     AND MATNR EQ LT_MARC-MATNR
    >   AND WERKS EQ P_WERKS
    >                     AND BDTER IN S_PERIOD.
    > the performance improvement is very negligible.
    > Please suggest.
    >
    > Regards,
    > Karthik
    Hi Karthik,

  • Using TMVL in Select Statement

    Dear All,
    Is the usage of TMVL in Select Statement valid?
    *SELECT(%VAR_YEAR%, YEAR, TIME, ID = TMVL(-12, %TIME_SET%))
    I don't think I manage to get this statement running.
    Thanks,
    YL

    Thanks All.
    My requirement is:
    Copy from Source to Destination using script logic:
    Package Selections:
    Category : Forecast
    Time : 2025.12
    Version : 2025
    Source
    Dimension Category : Plan
    Dimension Time : 2025.12
    Dimension Version : 2024
    Destination
    Dimension Category : Forecast
    Dimension Time : 2025.12
    Dimension Version : 2025
    And question is how to derive Version 2024 which is 2025 - 1, without using a specific property for it, i.e. Previous Year?
    Thank you very much.
    Best regards,
    Yen Li

  • Dynamic SELECT statement causing CX_SY_DYNAMIC_OSQL_SEMANTICS error.

    Hello Gurus,
    We have a dynamic SELECT statement in our BW Update Rules where the the Selection Fields are populated at run-time and so are the look-up target and also the WHERE clause. The code basically looks like below:
              SELECT (lt_select_flds)
                FROM (lf_tab_name)
                INTO CORRESPONDING FIELDS OF TABLE <lt_data_tab>
                FOR ALL ENTRIES IN <lt_source_data>
                WHERE (lf_where).
    In this instance, we are selecting 5 fields from Customer Master Data and the WHERE condition for this instance of the run is as below:
    WHERE: DIVISION = <lt_source_data>-DIVISION AND DISTR_CHAN = <lt_source_data>-DISTR_CHAN AND SALESORG = <lt_source_data>-SALESORG AND CUST_SALES = <lt_source_data>-SOLD_TO AND OBJVERS = 'A'
    This code was working fine till yesterday when we encountered serious performance problems and the Basis team had to do some changes at the DB level [Oracle]. Ever since, when we execute our data load, we get the CX_SY_DYNAMIC_OSQL_SEMANTICS.
    Is setting changes at the Oracle level cause issues with how the data is being read at the DB. If yes, can you suggest what can we do to this code to get is working correctly [in case Basis can't revert back their changes]?
    Would appreciate any help we can get here.

    You don't understand - this error comes up when we run specific BEx queries.  It was working yesterday, but today it is not.  Our support package did not change from yesterday.  We did not apply any OSSnotes.
    We are however doing pre-prepare on our Prod system.
    The temporary table is used to store SIDs for use in the join.  the table exists in the dictionary, but not at an Oracle level.

  • A Select statement with Appending table statement in it.

    Hi,
      How can I use a select statement with a <Appening table> statement in it.
    SELECT DISTINCT <field Name>
                    FROM <DB table name>
                    APPENDING TABLE <itab>
                    WHERE <fieldname> EQ <Itab1-fieldname>
                      AND <fieldname> EQ <itab2-fieldname>.
    Can I use the above select statement.If I'm using this...how this works?
    Regards
    Dharmaraju

    Hi, Dharma Raju Kondeti.
    I found this in the SAP online help, hope this can help you.
    Specifying Internal Tables
    When you read several lines of a database table, you can place them in an internal table. To do this, use the following in the INTO clause:
    SELECT ... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE <itab>
                              [PACKAGE SIZE <n>] ...
    The same applies to the line type of <itab>, the way in which the data for a line of the database table are assigned to a table line, and the CORRESPONDING FIELDS addition as for flat work areas (see above).
    The internal table is filled with all of the lines of the selection. When you use INTO, all existing lines in the table are deleted. When you use APPENDING; the new lines are added to the existing internal table <itab>. With APPENDING, the system adds the lines to the internal table appropriately for the table type. Fields in the internal table not affected by the selection are filled with initial values.
    If you use the PACKAGE SIZE addition, the lines of the selection are not written into the internal table at once, but in packets. You can define packets of <n> lines that are written one after the other into the internal table. If you use INTO, each packet replaces the preceding one. If you use APPENDING, the packets are inserted one after the other. This is only possible in a loop that ends with ENDSELECT. Outside the SELECT loop, the contents of the internal table are undetermined. You must process the selected lines within the loop.
    Regards,
    feng.
    Edited by: feng zhang on Feb 21, 2008 10:20 AM

Maybe you are looking for