Logic in single statment.

1. if p_number is null then
     i have substitute 52211 value
2. if p_number is no exists in target table then
     i have substitute 52211 value
3. if p_number is exists in target table then
     i have take the target table value and i have do the some validation.
How to implement the above requirement in single statment.

If you want to do it by sql then this may help you!
Some sample data created for target table by with clause to make you understand. Id column is used for notifying your criteria to fetch number value from target table.
SQL> with target as
  2  (
  3     select 1 id, 12345 num_value from dual union all
  4     select 2, 54789 from dual union all
  5     select 3, null  from dual
  6  ),
  7  tab_52211 as
  8  (
  9     select 0 id, 52211 num_value from dual
10  )
11  select num_value res
12   from(
13     select id, nvl(num_value,52211) num_value from target where id = &p_number union all
14     select id, num_value from tab_52211
15     )
16  where rownum < 2 order by id desc
17  /
Enter value for p_number: 4
       RES
     52211
SQL> /
Enter value for p_number: 3
       RES
     52211
SQL> /
Enter value for p_number: 2
       RES
     54789

Similar Messages

  • Simple Select Single statment doubt : please help

    Dear SAP,
    One simple question !!
    What happens, If I dont pass all the key values in select single statement.
    which data would it bring, the first occurence in DB table ?????
    Cont..
    And what happens if, I use select single without passing all keys (missing POSNR) but using it in a loop and giving condition as posnr > 900000. does this always bring same values.
    Please let me know. Thank you.
    Regards
    venkat

    Hi
    If you don't pass all key fields in SELECT SINGLE there will be multiple records for those condition and it fetches the first record
    If you won't pass POSNR in a loop, then for a single doc there will be multiple items and  always the first item only selected
    if a value exists greater than 900000, then it may consider that value
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Problem in select  statment & loop of itab.

    Hi all,
          I am having on ITAB1  for, ex which is having five line items or more  .
    iam also using select statment SINGLE statment for 7 times ,to select values for
    different data base  table.
    for ex,
    loop at itab.
       1---> SELECT SINGLE Z_CTRY_ORIG INTO LS_PSHDESN-Z_CTRY_ORIG FROM ZLE_PART_MST
      WHERE                           WERKS        = ITAB1-LGNUM
      AND                                 MATNR        = ITAB1-MATNR .
    2---
    3---
    4---
    endloop
    i want to remove from the loop statment  and i have to select  the datas ..
    can any one sugesset some possible ways....
    regards
    veera

    hi,
    Solution:
    Never use select single in loop at itab!! for that :
    Solution 1:
    say ur main table is ITAB and rferring  this u want to select data from other tables.
    SELECT SINGLE Z_CTRY_ORIG INTO LS_PSHDESN-Z_CTRY_ORIG FROM ZLE_PART_MST
    into table itab2
    FOR ALL ENTRIES IN ITAB
    WHERE WERKS = ITAB-LGNUM
    AND MATNR = ITAB-MATNR.
    With this what will hapeen , u will get all records in itab2 which u can update itab1(master) using loop.
    solution 2:
    Instead of all this use JOINs in select statement properly and u can fetch data in one shot this will reduce database load as well as abap load ( More than 3 joins in SELECT stmt  are not recommeded but can be used)
    I believe this is perfect solution if and only if u are giving joins on KEY fields only.  Same is applied for wherer clause.
    Hope this will help u, if not revert.
    Jogdand M B

  • 2 player turn based game logic in c# for snake and ladder

    Hello programmers,
    I am developing a snake and ladder game in xaml and C#.(windows 8.1 app)
    my question is:
    1) I am unable to think about the solution for player turn, I have build the game logic for single player and its working fine. please provide some solutions or the concept.
    2) I have build the same game logic with two different ways, one with nested if else and the next with array which one would be good for performance.
    and I also want to know about windows Azure for online score and multi player game service.

    Hi,
    I am not very familiar with the multiplayer Game development. For multiplayer games, you'll need to set up a matchmaking server and have the clients connect to it. It can then pair them off and facilitate communications. If the clients have publicly available
    network addresses then it can introduce them and they can talk directly to each other.There isn't anything built in for this so you'll need to either build your own or find a third party implementation. If you are using Unity3d then check out
    http://docs.unity3d.com/Documentation/Components/net-MasterServer.html
    Also, you can use Xbox services, and I find an article below:
    https://msdn.microsoft.com/en-us/library/bb975801.aspx
    For windows Azure problem, you should go to windows Azure forum.
    Best Wishes!
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. <br/> Click <a
    href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

  • How to divide logic flow stream in sp

    Hi, all
    I have a call from other app that should return SELECT results with 4 different WHERE clause, depending which set of params caller specifies, and which left like null.
    So I need to separate logic in my sp (caller insist on having single sp for all). i.e
    procedure sp01( param1=22, param2=33, param3=null, param4=null) ---> SELECT COLUMN_LIST FROM TABLE WHERE COLUMN1=PARAM1 AND COLUMN2=PARAM2;
    procedure sp01( param1=null, param2=null, param3='abc', param4=null) ---> SELECT COLUMN_LIST FROM TABLE WHERE COLUMN3=PARAM3;
    procedure sp01( param1=null, param2=null, param3=null, param4='xyz') ---> SELECT COLUMN_LIST FROM TABLE WHERE COLUMN4=PARAM4;
    etc..
    COLUMN_LIST stays the same for all SELECTS just different WHEREs. So beinig new to pl I interesteing how do you think better implement this logic in single sp, can I use any VAR for WHERE ? Or maybe there are some other clever tricks I go with to make it looks sound.
    I can think go with number of IFs:
    IF (PARAM1 IS NOT NULL ) AND (PARAM2 NOT NULL) THEN
    SELECT #1
    IF (PARAM2 IS NOT NULL ) THEN
    SELECT #2
    etc..
    Apreciate you comments
    Tx
    T

    Another option (which is not Dynamic SQL).
    select <columns>
    from table
    where (column1 = param1 or param1 is null)
    and   (column2 = param2 or param2 is null)
    and   (column3 = param3 or param3 is null)
    and   (column4 = param4 or param4 is null)Either approach (this or dynamic) could have potential performance drawbacks. It will depend highly on your situation so try them both out (in as real world simulation as you can get) and take some metrics.

  • How to update for single batch id in one a table by using mutiple parametrs

    Hi Everyone,
    I need simple pl/sql logic to update one table using with some parametrs.I need a logic for single batch_id there will be 100 of records are there .how do i update my custom table ? how do i show how many records have been updated for each batch ? how to handle excpetions while updating ?Som body could help me it will be great.
    -- Sample Code
    PROCEDURE UPDATE_table (P_IN_BATCH_ID IN Number,
    P_IN_TRANS_ID IN number,
    P_IN_TRANS_STATUS IN varchar2,
    P_IN_ERROR_MSSG IN varchar2
                                                 ) is
    cursor
    select*from xx_cust_table
    BEGIN
    UPDATE xx_cust_table
    SET TRANSMISSION_ID=P_IN_TRANS_ID
    TRANSMISSION_MSG=P_IN_TRANS_STATUS     
    PROCESSED_FLAG=P_IN_ERROR_MSSG
    where BATCH_ID=P_IN_BATCH_ID
    END UPDATE_table;

    PROCEDURE UPDATE_table (P_IN_BATCH_ID IN Number,
    P_IN_TRANS_ID IN number,
    P_IN_TRANS_STATUS IN varchar2,
    P_IN_ERROR_MSSG IN varchar2
    ) IS
    BEGIN
    UPDATE xx_cust_table
           SET TRANSMISSION_ID=P_IN_TRANS_ID
                  TRANSMISSION_MSG=P_IN_TRANS_STATUS
                   PROCESSED_FLAG=P_IN_ERROR_MSSG
      WHERE BATCH_ID=P_IN_BATCH_ID;
    DBMS_OUTPUT.PUT_LINE(SQL%ROWCOUNT||' rows updated!');
    --EXCEPTION
    --  WHEN DUP_VAL_ON_INDEX THEN
    --    DBMS_OUTPUT.PUT_LINE('Duplicate value');
    --  WHEN OTHERS THEN
    --   <display sqlcode and sqlerrm>
    END UPDATE_table;

  • Logical vs relational

    hi,
    There are two notations in logical model (Barker and Backman).
    The Backman notation in logical model looks like relational model in look and feel.
    I want to know the difference between logical and relational in oracle data modeler.
    How can i correlate with design theory like (conceptual, logical, physical) ??
    regards

    It does depend on how you define conceptual and logical.
    I always use Barker notation for conceptual and logical as the diagram does not look like the relational/physical model diagram plus it allows me the option of using box-in-box to represent subtypes and to display relationship verbs phrases on the relationship lines. This helps when reviewing with the business.
    For me a conceptual model will only have primary entities without attributes (but occasionally with natural keys), and unresolved many-to-many relationships. For a logical data model I will add all attributes, UIDs, datatypes (domains), null/not null flags, resolved intersection entities for the M:M, and reference/lookup entities.
    I prefer the Barker notation because it does not show the inherited attributes from the relationships which helps me remember I am doing an entity relationship model not a database or implementation design. I then can forward engineer the logical to a relational model for Oracle or SQL Server (etc). One thing that forward engineering does is to covert the logical data types to the correct physical data types for the selected database. It also creates the PK and FK constraints that can then be generated into DDL to build the tables. You also have options on how to implement the logical subtypes (single table, separate tables, master table with siblings, etc)

  • Guys! help me iin finding the logic

    can any one help me in finding
    1. inactive  customer
      1.1  - who did not have transaction for past 15day fianancial dept
      1.2 - who did not have transaction for past 15 days with sales dept
    2. inactive vendors
    2.1 - who did not have any transaction for past 15 days with finance dept
    2.2 - who did not have transactions for past 15 days with material dept.
    help me please asap.

    Hi,
    Inactive customers:
    Use tables kna1, knb1, knkk, vbrk(past activity).
    next activity - fplt, fpla, vbpa.
    1. 1st get the payers from KNB1 based on selection screen on payer and company code.
    2. KNKK logic
      select single kkber from t001 into v_kkber
                                   where bukrs eq p_bukrs.
        select kunnr kkber knkli nxtrv from knkk into table knkk_it
               for all entries in knb1_it where kunnr = knb1_it-kunnr and
                                                kkber = v_kkber and
                                                sbgrp in s_sbgrp.
    3.Last activity
        select vkorg erdat kunrg from vbrk into table vbrk_it
                           where vkorg = v_vkorg and
                                 erdat in before_dt.
        sort vbrk_it by kunrg.
    4. Next activity
    select single vkorg from tvko into v_vkorg where bukrs = p_bukrs.
      if not v_vkorg is initial.
        select fplnr fpltr fkdat from fplt into table fplt_it
                                                where fksaf = space and
                                                      fkdat in after_dt.
        sort fplt_it by fplnr fpltr.
        if not fplt_it[] is initial.
          select fplnr vbeln from fpla into table fpla_it
                 for all entries in fplt_it where fplnr = fplt_it-fplnr.
        endif.
        sort fpla_it by fplnr vbeln.
        if not fpla_it[] is initial.
          select vbeln kunnr from vbpa into table vbpa_it for all entries in
                                  fpla_it where vbeln = fpla_it-vbeln and
                                                posnr = '000000' and
                                                parvw = 'RG'.
        endif.
        sort vbpa_it by kunnr.
      endif.
    Later process all into final internal table.
    If this helps you award points.
    Thanks,
    Deepak.
    Message was edited by:
            KDeepak

  • General doubt with statement

    Hi ,
    I have a work area with 10 fields.
    I want to check whether each field has a value.
    so i have to like this
    if  ( wa-fld1 is initial or
         wa-fld2 is initial or
    wa-fld10 is initial )
    or there a better way where with single statment i can check whether all fields of the wa have values.
    Thanks
    preeti

    You can try something like this.  This way if you add more fields to WA, you don't have to change your logic to check for initial.
    report zrich_0001.
    data: begin of wa,
          fld1 type c,
          fld2 type c,
          fld3 type c,
          fld4 type c,
          end of wa.
    data: error type c.
    field-symbols: <fs>.
    wa-fld1 = 'A'.
    wa-fld2 = 'B'.
    wa-fld3 = ' '.
    wa-fld4 = 'D'.
    do .
      assign component sy-index of structure wa to <fs>.
      if sy-subrc <> 0.
        exit.
      endif.
      if <fs> is initial.
        error = 'X'.
        exit.
      endif.
    enddo.
    if error = 'X'.
      write:/ 'There is at least one field that is initial'.
    else.
      write:/ 'All is well'.
    endif.
    Regards,
    Rich Heilman
    Message was edited by:
            Rich Heilman

  • Execute dynamic sql  statement

    Hi all
    CREATE TABLE  XX_OFFICE_USER_IMP
        ID              NUMBER,
        OFFICE          VARCHAR2(10 BYTE),
        USER_NAME       VARCHAR2(10 BYTE),
        BANK_ACCOUNT_ID NUMBER,
        TRANSFERED      NUMBER
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (421,'0000','F0000',10029,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (422,'0000','F0000',10031,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (423,'0000','F0000',10033,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (424,'0000','F0000',10036,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (425,'0000','F0000',10037,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (426,'0000','F0000',10039,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (427,'0000','F0000',10041,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (428,'0000','F0000',10046,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (429,'0000','F0000',10048,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (430,'0000','F0000',10067,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (431,'0000','F0000',10072,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (432,'0000','F0000',10087,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (433,'0000','F0000',10092,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (434,'0000','F0000',10008,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (435,'0000','F0000',10012,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (436,'0000','F0000',10013,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (437,'0000','F0000',10014,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (438,'0000','F0000',10017,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (439,'0000','F0000',10019,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (440,'0000','F0000',10024,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (441,'0000','F0000',10025,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (442,'0000','F0000',10001,null);
    Insert into xx_office_user_imp (ID,OFFICE,USER_NAME,BANK_ACCOUNT_ID,TRANSFERED) values (443,'0000','F0000',10002,null);
    CREATE TABLE XXBG_CASIER_CASH
        CASHIER         VARCHAR2(32 BYTE),
        BANK_ACCOUNT_ID NUMBER(38,0)
    declare
    v_exe_grant varchar2(32767 char);
    begin
    for i in (select * from xx_office_user_imp where office = '0000') loop
      insert into XXBG_CASIER_CASH values (i.user_name, i.bank_account_id);
      v_exe_grant :=
                     'create user '  || i.user_name || ' identified by ' || i.user_name || ';'
                  || 'GRANT create session to ' || i.user_name || ';'
                  || 'GRANT select on apps.XXBG_CE_STATEMENT_HEADERS_CASH to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.FND_USER TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.dFND_DESCR_FLEX_COL_USAGE_TL TO ' || i.user_name || ';'
                  || 'GRANT select on apps.fnd_descr_flex_column_usages to ' || i.user_name || ';'
                  || 'GRANT select on apps.fnd_descriptive_flexs to ' || i.user_name || ';'
                  || 'GRANT select on apps.fnd_descriptive_flexs_tl to ' || i.user_name || ';'
                  || 'GRANT select on ce.ce_statement_headers to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.fnd_doc_sequence_assignments TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON CE.CE_STATEMENT_HEADERS_S TO ' || i.user_name || ';'
                  || 'GRANT EXECUTE ON APPS.XXBG_GET_NEXTVAL TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON CE.CE_STATEMENT_LINES TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.XXBG_CE_STATEMENT_LINES TO ' || i.user_name || ';'
                  || 'GRANT select on apps.CE_BANK_ACCOUNTS to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.CE_BANK_BRANCHES_V TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON CE.XXBG_CASIER_CASH TO ' || i.user_name || ';'
                  || 'GRANT EXECUTE ON APPS.XXBG_ST TO ' || i.user_name || ';'
                  || 'GRANT select on ce.xxbg_ce_statement_lines_detail to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.ce_transaction_codes TO ' || i.user_name || ';'
                  || 'GRANT select on ce.ce_statement_lines_s to ' || i.user_name || ';'
                  || 'GRANT SELECT ON CE.XXBG_CE_STATEMENT_LINES_DET_SQ TO ' || i.user_name || ';'
                  || 'GRANT select on apps.xx_pko_lines to ' || i.user_name || ';'
                  || 'GRANT SELECT ON apps.xx_rko_lines TO ' || i.user_name || ';'
                  || 'GRANT select on apps.XX_INVOICE_RELATIONS_CASH to ' || i.user_name || ';'
                  || 'GRANT select on APPS.PO_VENDOR_SITES_ALL to ' || i.user_name || ';'
                  || 'GRANT select on ap.AP_INVOICE_LINES_INTERFACE_S to ' || i.user_name || ';'
                  || 'GRANT select on ap.AP_INVOICE_LINES_INTERFACE to ' || i.user_name || ';'
                  || 'GRANT select on APPS.ap_distribution_set_lines_all to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_INVOICES_INTERFACE_S TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_INVOICES_INTERFACE TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_DISTRIBUTION_SETS_ALL  TO ' || i.user_name || ';'
                  || 'GRANT select on apps.ce_lookups  to ' || i.user_name || ';'
                  || 'GRANT select on ar.HZ_CUST_SITE_USES_ALL to ' || i.user_name || ';'
                  || 'GRANT select on ar.HZ_LOCATIONS to ' || i.user_name || ';'
                  || 'GRANT select on ar.HZ_PARTIES to ' || i.user_name || ';'
                  || 'GRANT select on ar.HZ_PARTY_SITES to ' || i.user_name || ';'
                  || 'GRANT SELECT ON AR.HZ_CUST_ACCT_SITES_ALL TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON AR.HZ_CUST_ACCOUNTS TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.XXBG_CLAIMS_V TO ' || i.user_name || ';'
                  || 'GRANT select on apps.xxbg_insis_agents_v to ' || i.user_name || ';'
                  || 'GRANT select on ce.xxbg_cash_doc_types to ' || i.user_name || ';'
                  || 'GRANT select on AP.AP_BANK_ACCOUNTS_ALL to ' || i.user_name || ';'
                  || 'GRANT SELECT ON AP.AP_BANK_BRANCHES TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.FND_DESCR_FLEX_CONTEXTS TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.FND_DESCR_FLEX_CONTEXTS_TL TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_SUPPLIERS to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.per_employees_x TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.fnd_doc_seq_categories_ap_v TO ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.AP_LC_INVOICE_TYPES_V to ' || i.user_name || ';'
                  || 'GRANT SELECT ON ce.xxbg_ce_statement_lines_sq to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.XXBG_STATEMENT_HEADERS_CASH to ' || i.user_name || ';'
                  || 'GRANT SELECT ON APPS.XXBG_INSIS_POLICY_V TO ' || i.user_name || ';'
                  || 'GRANT insert  ON ce.ce_statement_lines to ' || i.user_name || ';'
                  || 'GRANT INSERT  ON CE.XXBG_CE_STATEMENT_LINES_DETAIL TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON APPS.AP_INVOICES_INTERFACE TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON APPS.AP_INVOICE_LINES_INTERFACE TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON APPS.XX_RKO_LINES TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON APPS.XX_PKO_LINES TO ' || i.user_name || ';'
                  || 'GRANT delete on ce.xxbg_ce_statement_lines_detail to ' || i.user_name || ';'
                  || 'GRANT update on ce.XXBG_CE_STATEMENT_LINES_DETAIL to ' || i.user_name || ';'
                  || 'GRANT DELETE ON CE.CE_STATEMENT_LINES TO ' || i.user_name || ';'
                  || 'GRANT INSERT ON CE.CE_STATEMENT_HEADERS TO ' || i.user_name || ';'
                  || 'GRANT update on CE.CE_STATEMENT_HEADERS to ' || i.user_name || ';'
                  || 'GRANT update on ce.CE_STATEMENT_LINES to ' || i.user_name || ';'
                  || 'GRANT select on apps.XX_AGENTS_NO_V to ' || i.user_name || ';' ;
      execute immediate v_exe_grant;
    update xx_office_user_imp
      set transfered = 1
      where id = i.id
    v_exe_grant := '';
    end loop;
    end;
    /After execute the PL/SQL block i receive the error:
    Error report:
    ORA-00911: invalid character
    ORA-06512: at line 79
    00911. 00000 -  "invalid character"
    *Cause:    identifiers may not start with any ASCII character other than
               letters and numbers.  $#_ are also allowed after the first
               character.  Identifiers enclosed by doublequotes may contain
               any character other than a doublequote.  Alternative quotes
               (q'#...#') cannot use spaces, tabs, or carriage returns as
               delimiters.  For all other contexts, consult the SQL Language
               Reference Manual.
    *Action:Any ideas? I think i call execute immediate correctly.
    DB Version: 11g
    Unfortunately i cannot provide you with the sql of the other tables to create them.... Maybe you should try without all the grants... :)
    Thanks in advance,
    Bahchevanov.
    Edited by: bahchevanov on Oct 11, 2012 6:14 AM

    bahchevanov wrote:
    Any ideas? Sure. EXECUTE IMMEDIATE executes a single statment while you are trying to execute whole bunch. So use:
    execute immediate 'create user '  || i.user_name || ' identified by ' || i.user_name;
    execute immediate 'GRANT create session to ' || i.user_name;
    execute immediate 'GRANT select on apps.XXBG_CE_STATEMENT_HEADERS_CASH to ' || i.user_name;
    .SY.

  • FM SUBST_GET_FILE_LIST no longer available in Release 702 ?

    We are in the process of upgrading to ECC 6 Release 702. In the new release, the standard Function Module SUBST_GET_FILE_LIST (which is used to get a list of files on an application server directory), has all its code commented out and replaced by a single statment "raise ACCESS_ERROR".
    There is an SAP "security" note 1555144 which mentioned FM SUBST_GET_FILE_LIST as a security risk and recommends that FM  SUBST_GET_FILE_LIST be disabled using the "raise ACCESS_ERROR" statement. However, there seems to be no mention of an alternative FM or method that can be used to work around the security issue. There is really nothing to stop us from creating our own custom Z version of the FM, but then the security issue will still be there.
    Has anyone else out there come across this issue and if so what was your approach in working around this ?
    Thanks in advance.
    Alvin

    Hi all
    Interesting conversation
    We run into this same issue earlier this year when we did on ERP EHP5 upgrade for our client. At the moment we have a temporary solution to this, but that must replaced soon.
    We asked SAP about this SUBST_GET_FILE_LIST function, and in short the answer was, well, you should not have used it because the status of that function module is Not Released. Fair enough, we really should not have used that since like they said, 'Not Released' basically means it is for internal use and they can and will change those function modules when and how they want, like they just did with this FM.
    So, we asked if they have replacement for that FM. Answer was a reference to a note which tells us what is consulting and what is OSS case, meaning, either that they won't tell or they don't have a replacement.
    We then searched and searched and found few nice candidates for replacement, also the ones mentioned here. But the problem with all of this function modules is the same, the status of them is 'Not Released'. Our client does not want to replace one burned function module with another 'Not Released' function module (and to be honest, neither do I), so we are in a limbo at the moment.
    We do have some ideas (create our own function module which would use external command the read files etc.) but I really find it strange that there does not seem to be an official solution for this. Well, maybe when more and more clients upgrade to Netweaver 7.02, maybe then something happens.
    Petri

  • Unable to read edited cell values from table view 'LineEDIT' mode

    Hello Gurus,
    Need urgent help on Cell binding - Here's what I have:
    I have a bsp with one tableview for users to update shelf quantity.
    Selection mode is <b>Lineedit</b>. I used this only bcos in this I need not select a row to update it - let me know if this is wrong.
    Our users do not like to click on the row to select and edit it! I am not getting the edited values from the tableview.
    Although I am using a contoller and view, it's not really an MVC. Can someone please guide me on this?
    <b>
    code in IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS
    append initial line to p_column_definitions assigning <def>.
    <def>-columnname = 'SHLQTY'.
    <def>-title = 'Shelf Qty'.
    <def>-EDIT = 'X'.
    Code in IF_HTMLB_TABLEVIEW_ITERATOR~RENDER_CELL_START.
    p_replacement_bee = CL_HTMLB_INPUTFIELD=>FACTORY(
                                id        = p_cell_id
    *                            type      = 'DATE'
    *                            showhelp  = 'TRUE'
    *                            type       = 'QUAN'
                                VALUE      = val
                                cellvalue = 'TRUE'
                                _VALUE = P_CELL_BINDING )
    </b>
    I do not see anything coming in <b>P_CELL_BINDING</b> .
    Tableview in layout
    <b>
    <htmlb:tableView id                    = "result"
                           design                = "STANDARD"
                           headerText            = "Header Text"
                           filter                = "SERVER"
                           onNavigate            = "onMyNavigate"
                           selectionMode         = "lineedit"
                           emptyTableText        = "No records found!"
                           onRowSelection        = "onMyRowSelection"
                           allRowsEditable       = "TRUE"
                           selectedRowKeyTable   = "<%= rkTab %>"
                           table                 = "<%= datatab %>"
                           selectedRowIndexTable = "<%= sRTable %>"
                           iterator              = "<%= iterator %>"
                           visibleRowCount       = "10" >
          </htmlb:tableView>
    </b>
    I update an internal table Datatab with all the values I require.
    Any idea why the cell binding id not working?
    Many thanks in advance.
    Mike

    Hi Mike,
    databinding is not possible with application classes. There are just a nice way to handle "session variables". You can use them with MVC as well.
    Before MVC there was flow logic. Single formfield-values are receved e.g. when declared as page parameters. Values from tableViews are received e.g. in OnInputProcessing" by fetching the TV-Object from HTMLB_MANAGER and then calling methods like "GET_CELL_VALUE".
    DATA: tv          type ref to CL_HTMLB_TABLEVIEW,
          table_event type ref to CL_HTMLB_EVENT_TABLEVIEW.
    tv ?= CL_HTMLB_MANAGER=>GET_DATA( request = request
                                      name    = 'tableView'
                                      id      = 'mytv1' ).
    table_event = tv->data.
    myValue = table_event->get_cell_value( row_index  = 1 column_index = 1 ).
    good luck,
    stefan.

  • Restrict access to buttons, regions, etc. on a per user basis?

    My application restricts access to buttons, regions, etc. on a per user basis.
    Here is my application logic...
    1. A User can only edit items they own.
    2. A Super-User can edit all items
    So, when a user logs in, I use a post-authentication process to set the user ID to an application level item.
    Now, for example, to have an edit button display on a page, I need to check the item's owner ID against the application level user ID...and check to see if this user is on the Super User list via a query.(which could be set to another application level item upon login...I guess)
    Question...What is the best way to do this? Conditional display? Authorization scheme?
    Would something like the following work for a Conditional Display?
    Condition: SQL Expression
    &USER_ID.=&P6_ITEM_OWNER_ID. OR USER_ID in (select USER_ID from table where USER_ID=&USER_ID.)
    How would I do this with an Authorization Scheme? (I like the idea of updating the logic in single location...but I'm not sure if it is possible because I have to check PX_OWNER_ID would be different on each page.)

    Hi Denes,
    Thanks for your code which allows user to edit (if authorized) and view (if not).
    But some how - I do not get the image to show up - instead it show a small underline.
    From SQL point of view - here is what I get - when i run the sql
    '<img src="/i/ed-item.gif">',2,CR TEST,,,,dune2.cit.cornell.edu,CRDMTEST.CIT.CORNELL.EDU,PSPROD,,,CRDMTEST
    Here is my wrap_image function
    create or replace function wrap_image(p_user_name in varchar2,p_dm_name_id in number)
    return varchar2 IS
    v boolean := False;
    ret_val varchar2(1000);
    begin
    dbms_output.put_line('user='||p_user_name);
    dbms_output.put_line('dm_name='||p_dm_name_id);
    -- Check authorization if the user is super user - return true, else if he has edit priv on dm_name_id - return true - else false
    v:=ACL_DMTOOLS_DM_PRIV(p_user_name,p_dm_name_id);
    if v then
    ret_val := '<img src="/i/ed-item.gif">';
    ret_val := ''''||ret_val||'''';
    dbms_output.put_line('TRUE');
    else
    ret_val := '';
    dbms_output.put_line('FALSE');
    end if;
    return ret_val;
    end;
    Thanks for your great educational site.
    Regards
    atul

  • Filter on Calculated column based on union of 2 reports

    I have Report1 Union Report2.There is column A(Logic) in report1 and report 2 and Displayed this column A(Logic) as single column after merging the results.
    i am adding another column say (Saw0(*Column A(logic)* - saw 5) which is named as 'Difference'.I need to apply the filter on Difference >0 after results has been merged.Currently i see this filter is applying before the results are processed.
    Let me know if anyone has any thoughts.
    Thanks in Advance.

    Add the difference column in report 1 and report 2 while applying the filter and hide the column. Union the reports and add difference column in your final report.
    Thanks,
    -Amith.

  • Different result comparing AWR to TKPROF

    Hi,
    I runned last night event 10046 on my database using the following commands:
    ALTER SYSTEM SET statistics_level = ALL;
    ALTER SYSTEM SET events '10046 trace name context forever, level 12';
    Today, i compared a single statment from TKPROF result to the AWR and found
    big different results:
    The TKPROF shows:
    Executions is : 1
    elpased time is :51.39 seconds
    cpu time is : 0.23 second
    Gets per Exec is : 72
    SELECT CM_CUST_DIM_INST_PROD.INST_PROD_ID, CM_CUST_DIM_INST_PROD.NAP_PRODUCT_ID, CM_CUST_DIM_INST_PROD.NAP_PACKEAGE, CM_CUST_DIM_INST_PROD.PRODUCT_ID, CM_CUST_DIM_INST_PROD.PRODUCT_DESCR, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP_DESCR, CM_CUST_DIM_INST_PROD.PROD_CATEGORY, CM_CUST_DIM_INST_PROD.PROD_CATEGORY_DESCR, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE_DESCR, CM_CUST_DIM_INST_PROD.NAP_AREA2, CM_CUST_DIM_INST_PROD.NAP_PHONE_NUM, CM_CUST_DIM_INST_PROD.NAP_CANCEL_DT, CM_CUST_DIM_INST_PROD.NAP_SERVICE_OPN_DT, CM_CUST_DIM_INST_PROD.NAP_MAKAT_CD, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS_DESCR, CM_CUST_DIM_INST_PROD.NAP_RTRV_INSPRD_ID
    FROM CM_CUST_DIM_INST_PROD ,
    cm_ip_service_delta, cm_ip_service_delta cm_ip_service_delta2
    WHERE CM_CUST_DIM_INST_PROD.prod_grp_type in ('INTR', 'HOST') and
    CM_CUST_DIM_INST_PROD.Inst_Prod_Id = cm_ip_service_delta.inst_prod_id(+) and
    CM_CUST_DIM_INST_PROD.Nap_Makat_Cd = cm_ip_service_delta.nap_billing_catnum(+)
    and cm_ip_service_delta.nap_billing_catnum is null and
    cm_ip_service_delta.inst_prod_id is null
    and cm_ip_service_delta2.inst_prod_id = CM_CUST_DIM_INST_PROD.Nap_Packeage
    ORDER BY INST_PROD_ID
    call count cpu elapsed disk query current rows
    Parse 1 0.01 0.03 0 22 0 0
    Execute 1 0.02 1.79 0 32 0 0
    Fetch 13 0.19 49.56 0 18 0 661
    total 15 0.23 51.39 0 72 0 661
    The AWR report shows
    Executions is : 1
    elpased time is :697.91 seconds
    cpu time is :41.89 second
    Gets per Exec is : 351,105.00
    Executions Gets per Exec CPU Time (s) Elapsed Time (s) SQL Id SQL
    1 351,105.00 41.89 697.91 6hh4jdx9dvjzw
    6hh4jdx9dvjzw
    SELECT CM_CUST_DIM_INST_PROD.INST_PROD_ID, CM_CUST_DIM_INST_PROD.NAP_PRODUCT_ID, CM_CUST_DIM_INST_PROD.NAP_PACKEAGE, CM_CUST_DIM_INST_PROD.PRODUCT_ID, CM_CUST_DIM_INST_PROD.PRODUCT_DESCR, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP_DESCR, CM_CUST_DIM_INST_PROD.PROD_CATEGORY, CM_CUST_DIM_INST_PROD.PROD_CATEGORY_DESCR, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE_DESCR, CM_CUST_DIM_INST_PROD.NAP_AREA2, CM_CUST_DIM_INST_PROD.NAP_PHONE_NUM, CM_CUST_DIM_INST_PROD.NAP_CANCEL_DT, CM_CUST_DIM_INST_PROD.NAP_SERVICE_OPN_DT, CM_CUST_DIM_INST_PROD.NAP_MAKAT_CD, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS_DESCR, CM_CUST_DIM_INST_PROD.NAP_RTRV_INSPRD_ID FROM CM_CUST_DIM_INST_PROD , cm_ip_service_delta, cm_ip_service_delta cm_ip_service_delta2 WHERE CM_CUST_DIM_INST_PROD.prod_grp_type in ('INTR', 'HOST') and CM_CUST_DIM_INST_PROD.Inst_Prod_Id = cm_ip_service_delta.inst_prod_id(+) and CM_CUST_DIM_INST_PROD.Nap_Makat_Cd = cm_ip_service_delta.nap_billing_catnum(+) and cm_ip_service_delta.nap_billing_catnum is null and cm_ip_service_delta.inst_prod_id is null and cm_ip_service_delta2.inst_prod_id = CM_CUST_DIM_INST_PROD.Nap_Packeage ORDER BY INST_PROD_ID
    Does one can explain the different results ?
    Thank You

    Hi Virag,
    I ran the statment from sqlplus and after that i generated an addm report:
    As you can see below TKPROF show that elspaed time was : 50.76 second,
    while ADDM show:
    "was executed 1 times and had an average elapsed time of 751 seconds."
    ALTER SESSION SET max_dump_file_size = unlimited;
    ALTER SESSION SET tracefile_identifier = '10046';
    ALTER SESSION SET statistics_level = ALL;
    ALTER SESSION SET events '10046 trace name context forever, level 12';
    SELECT CM_CUST_DIM_INST_PROD.INST_PROD_ID, CM_CUST_DIM_INST_PROD.NAP_PRODUCT_ID, CM_CUST_DIM_INST_PROD.NAP_PACKEAGE, CM_CUST_DIM_INST_PROD.PRODUCT_ID, CM_CUST_DIM_INST_PROD.PRODUCT_DESCR, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP, CM_CUST_DIM_INST_PROD.PRODUCT_GROUP_DESCR, CM_CUST_DIM_INST_PROD.PROD_CATEGORY, CM_CUST_DIM_INST_PROD.PROD_CATEGORY_DESCR, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE, CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE_DESCR, CM_CUST_DIM_INST_PROD.NAP_AREA2, CM_CUST_DIM_INST_PROD.NAP_PHONE_NUM, CM_CUST_DIM_INST_PROD.NAP_CANCEL_DT, CM_CUST_DIM_INST_PROD.NAP_SERVICE_OPN_DT, CM_CUST_DIM_INST_PROD.NAP_MAKAT_CD, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS, CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS_DESCR, CM_CUST_DIM_INST_PROD.NAP_RTRV_INSPRD_ID
    FROM CM_CUST_DIM_INST_PROD ,
    cm_ip_service_delta, cm_ip_service_delta cm_ip_service_delta2
    WHERE CM_CUST_DIM_INST_PROD.prod_grp_type in ('INTR', 'HOST') and
    CM_CUST_DIM_INST_PROD.Inst_Prod_Id = cm_ip_service_delta.inst_prod_id(+) and
    CM_CUST_DIM_INST_PROD.Nap_Makat_Cd = cm_ip_service_delta.nap_billing_catnum(+)
    and cm_ip_service_delta.nap_billing_catnum is null and
    cm_ip_service_delta.inst_prod_id is null
    and cm_ip_service_delta2.inst_prod_id = CM_CUST_DIM_INST_PROD.Nap_Packeage
    ORDER BY INST_PROD_ID
    ALTER SESSION SET EVENTS '10046 trace name context off';
    EXIT
    call count cpu elapsed disk query current rows
    Parse 1 0.05 0.05 0 0 0 0
    Execute 1 0.02 1.96 24 32 0 0
    Fetch 46 0.19 48.74 6 18 0 661
    total 48 0.26 50.76 30 50 0 661
    Rows Row Source Operation
    661 PX COORDINATOR (cr=50 pr=30 pw=0 time=50699289 us)
    0 PX SEND QC (ORDER) :TQ10003 (cr=0 pr=0 pw=0 time=0 us)
    0 SORT ORDER BY (cr=0 pr=0 pw=0 time=0 us)
    0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
    0 PX SEND RANGE :TQ10002 (cr=0 pr=0 pw=0 time=0 us)
    0 FILTER (cr=0 pr=0 pw=0 time=0 us)
    0 HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
    0 BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
    0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
    0 PX SEND BROADCAST :TQ10000 (cr=0 pr=0 pw=0 time=0 us)
    3366 INDEX FAST FULL SCAN IDX_CM_SERVICE_DELTA (cr=9 pr=6 pw=0 time=47132 us)(object id 1547887)
    0 HASH JOIN (cr=0 pr=0 pw=0 time=0 us)
    0 BUFFER SORT (cr=0 pr=0 pw=0 time=0 us)
    0 PX RECEIVE (cr=0 pr=0 pw=0 time=0 us)
    0 PX SEND BROADCAST :TQ10001 (cr=0 pr=0 pw=0 time=0 us)
    3366 INDEX FAST FULL SCAN IDX_CM_SERVICE_DELTA (cr=9 pr=0 pw=0 time=20340 us)(object id 1547887)
    0 PX BLOCK ITERATOR PARTITION: 1 4 (cr=0 pr=0 pw=0 time=0 us)
    0 TABLE ACCESS FULL CM_CUST_DIM_INST_PROD PARTITION: 1 4 (cr=0 pr=0 pw=0 time=0 us)
    RECOMMENDATION 1: SQL Tuning, 56% benefit (615 seconds)
    ACTION: Run SQL Tuning Advisor on the SQL statement with SQL_ID
    "6wd7sw8adqaxv".
    RELEVANT OBJECT: SQL statement with SQL_ID 6wd7sw8adqaxv and
    PLAN_HASH 2594021963
    SELECT CM_CUST_DIM_INST_PROD.INST_PROD_ID,
    CM_CUST_DIM_INST_PROD.NAP_PRODUCT_ID,
    CM_CUST_DIM_INST_PROD.NAP_PACKEAGE, CM_CUST_DIM_INST_PROD.PRODUCT_ID,
    CM_CUST_DIM_INST_PROD.PRODUCT_DESCR,
    CM_CUST_DIM_INST_PROD.PRODUCT_GROUP,
    CM_CUST_DIM_INST_PROD.PRODUCT_GROUP_DESCR,
    CM_CUST_DIM_INST_PROD.PROD_CATEGORY,
    CM_CUST_DIM_INST_PROD.PROD_CATEGORY_DESCR,
    CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE,
    CM_CUST_DIM_INST_PROD.PROD_GRP_TYPE_DESCR,
    CM_CUST_DIM_INST_PROD.NAP_AREA2, CM_CUST_DIM_INST_PROD.NAP_PHONE_NUM,
    CM_CUST_DIM_INST_PROD.NAP_CANCEL_DT,
    CM_CUST_DIM_INST_PROD.NAP_SERVICE_OPN_DT,
    CM_CUST_DIM_INST_PROD.NAP_MAKAT_CD,
    CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS,
    CM_CUST_DIM_INST_PROD.NAP_CRM_STATUS_DESCR,
    CM_CUST_DIM_INST_PROD.NAP_RTRV_INSPRD_ID
    FROM CM_CUST_DIM_INST_PROD ,
    cm_ip_service_delta, cm_ip_service_delta cm_ip_service_delta2
    WHERE CM_CUST_DIM_INST_PROD.prod_grp_type in ('INTR', 'HOST') and
    CM_CUST_DIM_INST_PROD.Inst_Prod_Id =
    cm_ip_service_delta.inst_prod_id(+) and
    CM_CUST_DIM_INST_PROD.Nap_Makat_Cd =
    cm_ip_service_delta.nap_billing_catnum(+)
    and cm_ip_service_delta.nap_billing_catnum is null and
    cm_ip_service_delta.inst_prod_id is null
    and cm_ip_service_delta2.inst_prod_id =
    CM_CUST_DIM_INST_PROD.Nap_Packeage
    ORDER BY INST_PROD_ID
    RATIONALE: SQL statement with SQL_ID "6wd7sw8adqaxv" was executed 1
    times and had an average elapsed time of 751 seconds.
    RATIONALE: At least one execution of the statement ran in parallel.
    Thanks.

Maybe you are looking for