Select in FROM clause not working

Hello,
I have three tables with one table containing the name of the other two tables and i want to select dynamically the two selects based on their ID that matches in the first table.
CREATE TABLE_NAMES (ID NUMBER, TableName VARCHAR(2) )
CREATE TRADE (activites VARCHAR(2), TRADE_ID )
CREATE CONTRACT(activites VARCHAR(2), TRADE_ID )
INSERT INTO TABLE_NAMES ( 101, 'TRADE' );
INSERT INTO TABLE_NAMES ( 202, 'CONTRACT' );
INSERT INTO TRADE ('TRADE 1' , 101 )
INSERT INTO CONTRACT ('CONTRACT 1' , 202 )
What I wanted to do is select the table name dynamically based up on the id in TABLE_NAMES
and I failed when doing this
SELECT SELECTED_TABLE.activites FROM ( SELECT TABLE_NAME FROM TABLE_NAMES WHERE ID = 101 ) SELECTED_TABLE
OR a more generic form with JOIN statement also did not work
SELECT SELECTED_TABLE.activities FROM TABLE_NAMES SELECTION JOIN ( SELECT TABLE_NAME FROM TABLE_NAMES) SELECTED_TABLE
ON SELECTION.ID = SELECTED_TABLE.TRADE_ID
Thanks in advance

What you are trying to do will not work. To accomplish your requirement you would have to use dynamic SQL.
However, I want to stress that this is probably not a good design decision because:
1. Maintainability of the code may be jeopardized
2. Dynamic SQL could be laden with SQL injection vulnerabilities
3. Dynamic SQL generally does not perform as well as static SQL.
HTH!

Similar Messages

  • SELECT OID FROM clause not working

    The following statements gets ORA-00904: "OID": invalid identifier.
    The SELECT OID FROM clause is intended to pull in a REF to the MANAGER with MGR_ID= 000001.
    Oracle seems to think there are no OIDs for the entries in the MANAGERS table.
    INSERT INTO STORES VALUES (
    100001,
    ADDRESS(888, 'Main_Street', 'Rancho_Alegre', 'CA', '94049'),
    COF_ARRAY('Colombian', 'French_Roast', 'Espresso', 'Colombian_Decaf', 'French_Roast_Decaf'),
    (SELECT OID FROM MANAGERS WHERE MGR_ID = 000001)
    Here is how the MANAGER, MANAGERS, ans STORES were defined.
    CREATE TYPE MANAGER AS OBJECT (
    MGR_ID INTEGER,
    LAST_NAME VARCHAR(40),
    FIRST_NAME VARCHAR(40),
    PHONE char(10)
    CREATE TABLE MANAGERS OF MANAGER OBJECT IDENTIFIER IS SYSTEM GENERATED;
    CREATE TABLE STORES (
    STORE_NO INTEGER,
    LOCATION ADDRESS,
    COF_TYPES COF_ARRAY,
    MGR REF MANAGER
    My questions:
    1. I don't see any OIDs when I display the MANAGERS table with the Object Browser. That is normal it isn't it? Aren't they always hidden?
    2. Can anyone tell me what I am doing wrong?

    [Documentation Says....|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjdes.htm]
    The object identifier column is a hidden column that Oracle uses to construct references to the row objects. *Oracle provides no access to the internal structure of object identifiers*. This structure can change at any time. Applications are only concerned with using object references for fetching and navigating objects.
    In the above mentioned link is a link to what i think you're attempting...
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28371/adobjint.htm#i458258

  • From clause query works ok in form designer,  gets an ORA-01422 ran on web

    I am using forms 6i patch 9 with 10g database.
    I have two ‘FROM clause queries’ fired via a block/key-exeqry trigger in a if/elsif.
    The first/top SET BLOCK PROPERTY works perfect and populates the block.
    But the bottom/second SET BLOCK PROPERTY select (after the elsif)
    Is also based on a user entered field value and generates a ora-01422 error.
    The problem is that both top and bottom set block properties
    work fine when ran in forms designer,
    But when I compile it on the app_server and run the web version
    1. the top all ‘FROM clause query’ works fine
    2. the bottom ‘FROM clause query’ works fine if only one record to return.
    3. the bottom ‘FROM clause query’: gets the ora-01422 if > 1 record to return.
    FRM-40735: KEY–EXEQRY trigger raised unhandled exception ORA-01422
    The ORA-01422: ‘Exact fetch returned more than the exact number of rows’.
    Both set block property selects ‘share’ a block property/where clause of FAC_ID = :FACILITIES.ID
    The entered value in the entry field should populate 1 to many associated records
    in the bottom (elsif) set block property (and does so correctly when ran in forms designer)
    The block’s key-exeqry code:
    –-query all records associated with fac_id only
    if (:emission_stacks.stack_id_num is null) then
         SET_BLOCK_PROPERTY('EMISSION_STACKS',QUERY_DATA_SOURCE_NAME,
         '(SELECT C.ID, A.ID EP_ID,A.FAC_ID,A.NUM,A.DESCRIPTION,C.PARENT_MODE_ID,
    C.STACK_ID, C.CAPTURE_PERCENT, C.CAPTURE_METHOD, C.DATE_TESTED
    FROM EMISSION_POINTS A,
    EP_MODES B,
    CAPTURING_DEVICES C
    WHERE A.ID = B.EP_ID AND
    B.ID = C.PARENT_MODE_ID AND
    C.CD_ID IS NULL AND
    C.PARENT_MODE_ID IS NOT NULL AND
    C.STACK_ID IS NOT NULL)');
    EXECUTE_QUERY;
    elsif
    (:emission_stacks.stack_id_num is not null) then
    –-(query all records associated with fac_id and the entry field value)
    SET_BLOCK_PROPERTY('EMISSION_STACKS',QUERY_DATA_SOURCE_NAME,
         '(SELECT C.ID, A.ID EP_ID, A.FAC_ID, A.NUM, A.DESCRIPTION, C.PARENT_MODE_ID,
    C.STACK_ID, C.CAPTURE_PERCENT, C.CAPTURE_METHOD, C.DATE_TESTED
    FROM EMISSION_POINTS A,
    EP_MODES B,
    CAPTURING_DEVICES C,
    STACKS S
    WHERE A.ID = B.EP_ID AND
    B.ID = C.PARENT_MODE_ID AND
    C.STACK_ID = S.ID AND
    C.CD_ID IS NULL AND
    C.PARENT_MODE_ID IS NOT NULL AND
    C.STACK_ID IS NOT NULL AND
    S.NUM = '''||:emission_stacks.stack_id_num||''')');
    EXECUTE_QUERY;
    ** I have multiple database items in the block.
    Data block properties:
    Database/
    Data Base Block = Yes
    Query Allowed= Yes
    Is there a way to overcome the ora-01422?
    And populate the block with multiple rows(records)?
    Any suggestions appreciated.

    Sorry, false alarm, I made a mistake
    the form is working fine the way it should,
    without error. (No ora-01422 errror is occurring now.)
    I just got a new version of humming bird,
    which I used to compile the form with
    and did not have the binary switch on:
    --long story short, a new fmx was not created
    and I was not seeing the current version of screen
    at runtime.
    Thank you.

  • Can only add music with Autofill from Library (not working with playlists)

    I can only add music using the Autofill feature and it will only work when the main music library is selected. Autofill does not work when a playlist is selected and I can not add music directly by dragging songs from a library or playlist as described in the owner's manual.
    Is there something wrong with iTunes, the iPod or is this user error?

    Hi Steve,
    You're right it's the same for me.
    I don't know as you mentionned whether it is an user error or not but I've got 2 iPods now, one is 60 Go color display (60Go) and the other received yesterday is 2G iPod Shuffle (Clipod). I can't drag songs from 60Go nor to iTunes Library neither to Clipod Music. The autofill function works only from iTunes Library where I've got 5 songs only (new MacPro), somebody knows how to export 60Go music to iTunes Library ?
    Thanks,
    Peloche
    MacPro 2.66, 6GB, 1.7TB; Mini G4, 1.45, 1GB;iPod 60 GB; 30" & 20" ACD; Apple IIC   Mac OS X (10.4.8)   X1900XT

  • Type to selection tool quick command not working in InDesign CC

    When I have the type tool selected in InDesign and hold command for the selection tool, it's not working. When I hold the command button it highlights the selection tool, but as soon as I click my mouse, it reverts back to the type tool. Also, when I change the size of my text box it does not resize the text in the box, even if I hold for a a few sec before moving the cursor.

    @Cindy – usually all 3rd party developers will provide some information for installing and uninstalling their products. First see if you can find some information on their web sites.
    Also there should be a dedicated Adobe Extension Manager app where you can look up the installed parts of InDesign. Since I do not have InDesign CC installed, I do not know exactly, but its name should be something like "Adobe Extension Manager CC".
    If you start this app it will show all parts installed with InDesign (or other apps that are installed).
    Usually at the bottom of the list are the 3rd party installed components. They do not state "Adobe Incoroprate System" as author. Never uninstall (remove) the Adobe ones!
    Here a screen grab from my German Adobe Extension Manager CS5:
    If you select one, a new option is available at the right. In my case here the "Entfernen" button ("Remove" in English).
    Uwe

  • SELECT INTO ( variable ) STATEMENTS NOT WORKING FOR SYBASE TABLE AS VIEW

    Dear Experts,
    We have connected our 9i db with Sybase db using Hs connectivity.
    and then we have create the view in oracle db for SYBASE_TABLE as SYBASE_TABLE_VIEW.
    ALL THE INSERT, UPDATE AND DELETE COMMANDS ARE WORKING BUT THE
    select Into (variable) is not working.
    Please help to resolve the select into statment which is in BOLD in the below routine
    PLEASE NOTE! FORM WAS COMPILED SUCCESSFULLY AND FORM IS RUNNING BUT SELECT INTO COMMAND IS NOT WORKING.
    Thanks & Regards
    Eidy
    PROCEDURE SRBL_INSERT IS
    CURSOR SRBL IS
         SELECT impno,impcod,impnam
         from oracle_table1 a, oracle_table2 b
         WHERE a.impcod=b.empcod
         v_srpcod varchar2(5);
    BEGIN     
    FOR rec in SRBL loop     
         begin
    select "im_code" into v_impcod                    
         from SYBASE_TABLE_VIEW
         where "im_code"=rec.impcod;
    exception when no_data_found then
         v_srpcod:=null;
    end;
    END LOOP;
    END;
    Edited by: Eidy on Aug 16, 2010 11:28 AM

    hellow
    try this.
    select "im_code" into v_impcod
    from SYBASE_TABLE_VIEW
    where "im_code"=rec.impcod;
    v_srpcod := v_impcod ;
    ........

  • The select/start button is not working on my Vita?

    as title, anybody face the problems???
    actually, my vita (wifi) freezed last week, PS button blue light, cannot shut down.
    after hold down power button, enter to Safe Mode, and done everything (restore, restart, rebuild, format m.card).
    now, PS button alive, working, but select / start button still not working!!
    HELP HELP HELP.......

    Here Is the Solution see on pictures This Fault Is Caused With Shorted Right Top Button When This shows conductivity few ohm this interfere with the signal line on the pcb.to test it disconnect this button from the socket by lifting up the small lock on amphenol socket.measure the 2 tracks on the foil if its conductive.in most cases will be leave it disconnected turn on the psp vita with some games and test if the start button respond 99% it will be working ok.if yesthen turn off the unit disconnect the main battery to avoid shortage to the motherboard.peel gently off the top right button and replace with new oneiff you cannot get parts then separate the 2 foil and clean the ferrite pad's.cut a thin foil with 2 hole same size as the button conductive pad's this will create bigger gap between these conductive touch pad's and the foil. Warning !!! This guide is for advanced component level engineers not for beginners require esd protection.  

  • Order by clause not working

    Hi, everyone,
    I am trying to use the following insert statement to insert records in asc order. if i use the select statement alone the order by clause works fine, but when i use the same sql and add a insert into table statment the order by clause does not work. I am not getting the records in ascending order. could anybody help me in this regard?
    INSERT INTO cat_sales_stg
    select      b.SSC,                
         ltrim(rtrim(a.CAT_DESC)) cat_desc,                
         SUM(a.AMOUNT) AMOUNT               
    FROM Trans a, SSC b                     
    WHERE a.ACCOUNT_NUMBER = TO_CHAR(b.ACCOUNT_NUMBER)                    
         AND a.TMONTH >= 200905 AND a.TMONTH <= 200910                
         AND a.FORMAT_NAME = 'ABC'                
         AND b.BMONTH = 200910                
         AND b.SAMPLE = 3                
         AND b.BANNER_NAME = 'ABC'               
         AND b.MODEL_NAME = 'XYZ'               
    group by b.SSC, ltrim(rtrim(a.CAT_DESC))
    order by ssc,cat_desc
    Thanks in advance

    user10636796 wrote:
    Hi, everyone,
    I am trying to use the following insert statement to insert records in asc orderWhat Toon, William, and others have said is that you DON'T insert rows in a specific order. That is completely outside the way relational databases are designed. You insert rows as unordered and use an ORDER BY clause in a SELECT when reading them. ORDER BY is for SELECT statements, not INSERT.
    In particular Toon poined out that we can't control where individual rows get stored.
    There is a databas object called a varray that can store data in sorted order. I have never seen them used because selecting the data back out again is more work; using an ordinary table and an ORDER BY clause is much easier.

  • Why is the GROUP BY clause not working in my Query?

    Dear All,
    Below is the Query for a Summary Debtors Aged Analysis.
    The GROUP BY clause does not seem to be working.
    The Query returns all the unpaid invoices, instead of a single total row for each Customer.
    If a Customer X has 10 unpaid invoices, 10 rows are displayed - one for each invoice.
    I was expecting only 1 row for Customer X, 1 for Customer Y, etc.
    This is what GROUP BY is supposed to do, but it is not doing its work.
    What has gone wrong?
    Thanks
    Leon Lai
    Here's my Query:
    declare @taxdt datetime
    set @taxdt
    /*select 1 from jdt1 t0 where t0.TaxDate*/ = [%1]
    SELECT
    CASE
                 WHEN T0.Account = 1220101 THEN 'Prim Cust'
                 WHEN T0.Account = 1220102 THEN 'Fgn Cust'
                 WHEN T0.Account = 1220103 THEN 'Local Cust'
                 WHEN T0.Account = 1220104 THEN 'Staff Loan' 
                 WHEN T0.Account = 1220105 THEN 'Dep with TP'
                 WHEN T0.Account = 1220106 THEN 'Adv to Cust'
                 WHEN T0.Account = 1220108 THEN 'Sund Drs'
                 ELSE 'Error ! ! !'
    END AS 'Control A/c',
    T1.CardCode AS 'BP Code',
    T2.Notes2 AS 'BP Name',
    SUM ((T0.Debit - T0.Credit)) AS 'Orig. Rs',       
    SUM ((T0.BalDueDeb - T0.BalDueCred)) AS 'Bal. Rs',     
    ((SELECT SUM(T0.BalDueDeb) - Sum(T0.BalDueCred)
        WHERE DateDiff(mm, T0.TaxDate, @taxdt) = 1))    
        AS '1 Mth Ago' 
    /* Similarly for other age brackets*/
    FROM JDT1 T0
    INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
    LEFT OUTER JOIN OCPR T2 ON T1.CardCode = T2.Cardcode
    LEFT OUTER JOIN OJDT T3 ON T0.TransID = T3.TransID
    LEFT OUTER JOIN OINV  T4 ON T3.TransID = T4.TransID
    LEFT OUTER JOIN ORIN  T5 ON T3.TransID = T5.TransID
    WHERE
    T1.CardType = 'C'
    and (Balance) != 0
    and (T0.BalDueDeb - T0.BalDueCred) != 0
    GROUP BY T0.Account, T1.CardCode, T2.Notes2, T0.TaxDate

    Dear Neetu,
    Thanks for your reply.
    This Query is a modification of the Query you posted in SAP B1 SQL TIPS & TRICKS
    http://wiki.sdn.sap.com/wiki/display/B1/SAPB1SQLB-FNDebtorsAgingReportbydate
    So, maybe instead of referring to my Query, let's refer to yours. It may be easier for you to understand me.
    Once I understand the problem, I can adapt your query to suit my requirements
    So, let's start with a clean slate:
    The Query you have posted is for a DETAILED Debtors Aging Report.
    This lists all outstanding invoices, and ages them in the Age Brackets.
    What I want is a SUMMARY Debtors Aging Report.
    This will give the total amount owed by each Customer, and this amount is broken down in the Age Bracket Columns
    There will be a single row listed for each customer, something like this:
    Customer     Total Due     Current      1 Mth          2 Mth         3 Mth  etc
    Alfred       500,000       300,000       200,000
    Charles      800,000                     100,000       300,000       400,000
    How can you modify your query to make it become a Summary Report (1 line for each customer even if he has many invoices)?
    Thanks
    Leon Lai
    Here's your code
    SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
         CASE  WHEN T0.TransType=13 THEN 'Invoice'
              WHEN T0.TransType=14 THEN 'Credit Note'
              WHEN T0.TransType=30 THEN 'Journal'
              WHEN T0.TransType=24 THEN 'Receipt'
              END AS 'Document Type',
         T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
         ,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
    FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
    WHERE (T0.MthDate IS NULL OR T0.MthDate > [%1]) AND T0.RefDate <= [%1] AND T1.CardType = 'C'
    ORDER BY T1.CardCode, T0.DueDate, T0.Ref1

  • In clause not working

    Hi All,
    SELECT sno,mid,mname
    FROM manage_date
    WHERE mname IN
    ('KIRAN-KUMAR',
    'RAHUL-RAJ',
    'KAUSHAL-SONI');
    IF I use this query directly in DB it's working fine.
    But when this query is calling in .net using parameter as below
    it's not giving any records for more than one value.
    IN (:p_mname)
    If I pass one name 'KIRAN-KUMAR' from .net It's working.
    If I pass multiple names from .net query not returning any records.
    Please help me how to resolve this.
    Thanks.

    976208 wrote:
    Hi All,
    SELECT sno,mid,mname
    FROM manage_date
    WHERE mname IN
    ('KIRAN-KUMAR',
    'RAHUL-RAJ',
    'KAUSHAL-SONI');
    IF I use this query directly in DB it's working fine.
    But when this query is calling in .net using parameter as below
    it's not giving any records for more than one value.
    IN (:p_mname)
    If I pass one name 'KIRAN-KUMAR' from .net It's working.
    If I pass multiple names from .net query not returning any records.
    Please help me how to resolve this.
    Thanks.
    But you won't be passing multiple names in that single bind variable, you'll be passing one string of names.  Oracle is not going to magically know that just because you have commas in the string you intend to have seperate values... it doesn't work like that (and it shouldn't).
    As Karthick pointed out, it's not a case that the IN clause is not working, it's a case of you not understanding the difference between the IN clause requiring a set of values as opposed to a single value, so you should read the FAQ link which points to useful information about how to deal with such situations.

  • "Old" update rule from ODS not working

    Hi Gurus,
    I need to set up the "old" fashioned update rule to load data from an ODS1 to another ODS2.
    The thing is that I need to set up an update rule because I need to implement a Return Table Routine that is not supported (as far as I know) by the new Transformation/DTP.
    When I select option (through the right mouse click over ODS1)  "Other Options" - "Create Update Rule" it takes me out of the RSA1 and leaves me in the main menu making it impossible to create a new update rule.
    The strange thing is that I have this working from and ODS to an InfoCube.....
    Suggestions, a workaround??
    Andrea.

    Hi Jerry,
    Just to confirm that this is not working. The tys_TG_1 structure only shows me the target infoprovider structure. Check that in the how to, to be able to derive employee first you need to assign eache source_filed to the result_field leaving employee blank.
    I need to have in the same place, the source_field structure (source infoprovider field structure) and the result_field structure (target infoprovider structure). That is what the "old" return table gives me as in the same place I can have the communication_structure (source infoprovider field structure) with the return_table structure (target infoprovider structure). 
    Just to understand, in the source infoprovider I have 12 Key Figures (1 for each period) and I have to split each incoming record to 12 records. If I work only with the result_field structure tys_TG_1 and the result_package tyt_TG_1 I'm not able the see those 12 KF.
    So... return table functionality is not fully supported by BW 7 as far as I know.
    Any other ideas why I'm not able to create the old Update Rules from an ODS?
    Regards,
    Andrea.

  • Select all button is not working in vl01n

    Dear All,
    We are facing a problem at the time of creating delivery through vl01n. At the time of selecting all line items of delivery on item overview screen, we are unable to select all line items. Due to this we have to delete each line item batches separately & to redetermine the batches or we can say select button is not working on item overview screen of vl01n. Also when we redetermine the batch split & return back to item overview screen, select all button works for line items perfectly.
    thanks & regards
    Deven Sharma

    Hi,
    In the user command write the code as per the sample given below:
    FORM select_all .
      CLEAR v_lisel.
      DO.
        READ LINE sy-index FIELD VALUE v_chk.
        IF sy-subrc NE 0.
          EXIT.
        ENDIF.
        READ LINE sy-index FIELD VALUE sy-lisel INTO v_lisel.
        IF v_lisel+2(1) = ' ' AND sy-index GT 5.
          v_lisel+2(1) = 'X'.
          MODIFY LINE sy-index FIELD VALUE sy-lisel FROM v_lisel.
        ENDIF.
      ENDDO.
    ENDFORM.                    " select_all
    reward if useful
    regards,
    ANJI

  • EQUAL condition on WHERE clause not working

    Hi,
    Can someone please tell me why the following WHERE clause  (marked with ***** below) is not finding any EQUAL conditions?
    I know that table i_cust_mast is populated with several thousand rows and that there ARE matching rows in KNVP.
    Here is the code as I have it:
    TYPES:
          BEGIN OF t_cust_mast,
            kunnr TYPE kunnr,
            name1 TYPE name1_gp,
            name2 TYPE name2_gp,
            stras TYPE stras_gp,
            adrnr TYPE adrnr,
            ort01 TYPE ort01_gp,
            regio TYPE regio,
            pstlz TYPE pstlz,
            vkbur TYPE vkbur,
            konda TYPE konda,
            sortl TYPE sortl,
            katr1 TYPE katr1,
            katr2 TYPE katr2,
            katr3 TYPE katr3,
            katr4 TYPE katr4,
            katr5 TYPE katr5,
            katr6 TYPE katr6,
            katr7 TYPE katr7,
            katr8 TYPE katr8,
            katr9 TYPE katr9,
            katr10 TYPE katr10,
            bzirk TYPE bzirk,
            vkgrp TYPE vkgrp,
            kdgrp TYPE kdgrp,
            klabc TYPE klabc,
            kondaa TYPE konda,
            kalks TYPE kalks,
            pltyp TYPE pltyp,
            hityp TYPE hityp_kh,
            hkunnr TYPE hkunnr_kh,
            datab TYPE datab,
            datbi TYPE datbi,
            lzone TYPE lzone,
          parvw TYPE parvw,
            kunn2 TYPE kunn2,
            kunn2a TYPE kunn2,
            kunn2b TYPE kunn2,
            kunn2c TYPE kunn2,
            kunn2d TYPE kunn2,
            kunn2e TYPE kunn2,
            kunn2f TYPE kunn2,
            kunn2g TYPE kunn2,
            parza TYPE parza,
            ktokd TYPE ktokd,
            loevm TYPE loevm_x,
          END OF t_cust_mast .
        TYPES:
          BEGIN OF t_part_func,
            kunnr TYPE kunnr,
            parvw type parvw,
            kunn2 TYPE kunn2,
            parza type parza,
          END OF t_part_func .
        TYPES:
          t_t_cust_mast TYPE STANDARD TABLE OF t_cust_mast,
          t_t_part_func TYPE STANDARD TABLE OF t_part_func.
        DATA: i_cust_mast TYPE t_t_cust_mast,
              i_part_func TYPE t_t_part_func.
      CONSTANTS: c_type_a TYPE msgty VALUE 'A'.
      FIELD-SYMBOLS: <x_cm> LIKE LINE OF i_cust_mast.
    Get Customer Master Data
      SELECT
       hkunnr hname1 hname2 hstras hadrnr hort01 h~regio
       hpstlz ivkbur ikonda hsortl hkatr1 hkatr2 h~katr3
       hkatr4 hkatr5 hkatr6 hkatr7 hkatr8 hkatr9 h~katr10
       ibzirk ivkgrp ikdgrp iklabc ikonda ikalks i~pltyp
       khityp khkunnr kdatab kdatbi h~lzone
       hktokd hloevm
      INTO TABLE i_cust_mast " up to 50 rows
      FROM kna1 AS h
      JOIN knvv AS i ON ikunnr = hkunnr
      JOIN knvh AS k ON hityp = c_type_a   " 'A'
                    AND kkunnr = ikunnr
                    AND kvkorg = ivkorg
                    AND kvtweg = ivtweg
                    AND kspart = ispart
                    AND k~datab <= sy-datum
                    AND k~datbi >= sy-datum.
      IF sy-subrc = 0.
        SORT i_cust_mast[] BY kunnr.
      ENDIF.
    Get Partner Function Data for each Customer Master Record
      LOOP AT i_cust_mast ASSIGNING <x_cm>.
        SELECT hkunnr hparvw hkunn2 hparza
          INTO TABLE i_part_func
        FROM knvp AS h
          WHERE h~kunnr = <x_cm>-kunnr.        ***** WHERE clause not finding any matches *****
      ENDLOOP.
    Thanks!!!
    Andy

    TYPES:
          BEGIN OF t_cust_mast,
            kunnr TYPE kunnr,
            name1 TYPE name1_gp,
            name2 TYPE name2_gp,
            stras TYPE stras_gp,
            adrnr TYPE adrnr,
            ort01 TYPE ort01_gp,
            regio TYPE regio,
            pstlz TYPE pstlz,
            vkbur TYPE vkbur,
            konda TYPE konda,
            sortl TYPE sortl,
            katr1 TYPE katr1,
            katr2 TYPE katr2,
            katr3 TYPE katr3,
            katr4 TYPE katr4,
            katr5 TYPE katr5,
            katr6 TYPE katr6,
            katr7 TYPE katr7,
            katr8 TYPE katr8,
            katr9 TYPE katr9,
            katr10 TYPE katr10,
            bzirk TYPE bzirk,
            vkgrp TYPE vkgrp,
            kdgrp TYPE kdgrp,
            klabc TYPE klabc,
            kondaa TYPE konda,
            kalks TYPE kalks,
            pltyp TYPE pltyp,
            hityp TYPE hityp_kh,
            hkunnr TYPE hkunnr_kh,
            datab TYPE datab,
            datbi TYPE datbi,
            lzone TYPE lzone,
          parvw TYPE parvw,
            kunn2 TYPE kunn2,
            kunn2a TYPE kunn2,
            kunn2b TYPE kunn2,
            kunn2c TYPE kunn2,
            kunn2d TYPE kunn2,
            kunn2e TYPE kunn2,
            kunn2f TYPE kunn2,
            kunn2g TYPE kunn2,
            parza TYPE parza,
            ktokd TYPE ktokd,
            loevm TYPE loevm_x,
          END OF t_cust_mast .
        TYPES:
          BEGIN OF t_part_func,
            kunnr TYPE kunnr,
            parvw type parvw,
            kunn2 TYPE kunn2,
            parza type parza,
          END OF t_part_func .
        TYPES:
          t_t_cust_mast TYPE STANDARD TABLE OF t_cust_mast,
          t_t_part_func TYPE STANDARD TABLE OF t_part_func.
        DATA: i_cust_mast TYPE t_t_cust_mast,
              i_part_func TYPE t_t_part_func. 
    CONSTANTS: c_type_a TYPE msgty VALUE 'A'.
      FIELD-SYMBOLS: <x_cm> LIKE LINE OF i_cust_mast.
    Get Customer Master Data
      SELECT
       hkunnr hname1 hname2 hstras hadrnr hort01 h~regio
       hpstlz ivkbur ikonda hsortl hkatr1 hkatr2 h~katr3
       hkatr4 hkatr5 hkatr6 hkatr7 hkatr8 hkatr9 h~katr10
       ibzirk ivkgrp ikdgrp iklabc ikonda ikalks i~pltyp
       khityp khkunnr kdatab kdatbi h~lzone
       hktokd hloevm
      INTO TABLE i_cust_mast " up to 50 rows
      FROM kna1 AS h
      JOIN knvv AS i ON ikunnr = hkunnr
      JOIN knvh AS k ON hityp = c_type_a   " 'A'
                    AND kkunnr = ikunnr
                    AND kvkorg = ivkorg
                    AND kvtweg = ivtweg
                    AND kspart = ispart
                    AND k~datab <= sy-datum
                    AND k~datbi >= sy-datum.
      IF sy-subrc = 0.
        SORT i_cust_mast[] BY kunnr.
      ENDIF.
    Get Partner Function Data for each Customer Master Record
      LOOP AT i_cust_mast ASSIGNING <x_cm>.
        SELECT hkunnr hparvw hkunn2 hparza
          INTO TABLE i_part_func
        FROM knvp AS h
          WHERE h~kunnr = <x_cm>-kunnr.
      ENDLOOP.

  • Select for update query not working..

    hi i am tying to get this bit of ncode to work so i can then go to the next part of demonstrating a deadlock between two transactions. however i cannot go any further has my initial code does not work at all. here it goes
    //////////User A////////////////////////////////
    DECLARE
    v_salary squad.salary%TYPE := 300;
    v_pos squad.position%TYPE := 'Forward';
    BEGIN
    UPDATE squad
    SET salary = salary + v_salary
    WHERE sname = 'Henry';
    FOR UPDATE;
    UPDATE squad
    SET position = v_pos
    WHERE sname = 'Fabregas';
    COMMIT;
    END;
    //////////////////////User B/////////////
    DECLARE
    v_salary squad.salary%TYPE := 200;
    v_pos squad.position%TYPE := 'Forward';
    BEGIN
    UPDATE squad
    SET position = v_pos
    WHERE sname = 'Fabregas';
    FOR UPDATE;
    UPDATE squad
    SET salary = salary + v_salary
    WHERE sname = 'Henry';
    FOR UPDATE;
    COMMIT;
    END;
    Basicly user a creats a lock and so does user b, user b enquires a lock from user a and vice versa i.e. a deadlock

    Hi
    You get the following error:
    ORA-06550: line 8, column 7:
    PLS-00103: Encountered the symbol "UPDATE" when expecting one of the following:
    because the FOR UPDATE; is invalid in your statement.
    Try this:
    //////////User A////////////////////////////////
    DECLARE
    v_salary squad.salary%TYPE := 300;
    v_pos squad.position%TYPE := 'Forward';
    v_n number;
    BEGIN
    UPDATE squad
    SET salary = salary + v_salary
    WHERE sname = 'Henry';
    select 1 into v_n from squad
    WHERE sname = 'Fabregas'
    for update;
    UPDATE squad
    SET position = v_pos
    WHERE sname = 'Fabregas';
    COMMIT;
    END;
    //////////////////////User B/////////////
    DECLARE
    v_salary squad.salary%TYPE := 200;
    v_pos squad.position%TYPE := 'Forward';
    v_n number;
    BEGIN
    UPDATE squad
    SET position = v_pos
    WHERE sname = 'Fabregas';
    select 1 into v_n from squad
    WHERE sname = 'Henry'
    for update;
    UPDATE squad
    SET salary = salary + v_salary
    WHERE sname = 'Henry';
    COMMIT;
    END;
    To syncronize the blocks first in a SQLPlus call these two statements:
    select 1 from squad WHERE sname = 'Fabregas' for update;
    select 1 from squad WHERE sname = 'Henry' for update;
    After this start the user A code in another SQLPlus, and start the user B code. After this call rollback or commit in the first sqlplus.
    Ott Karesz
    http://www.trendo-kft.hu

  • Select in From-Clause with JPQL

    Hey,
    I'm new to JPA development. How can I transform the following SQL-Statement:
    select a from
    Gpsj a,
    (select c.tsid, c.wsid, max(c.gdat1) maxgdat from Gpsj c where c.tsid = '901' group by tsid, wsid) b
    where a.tsid = b.tsid
    and a.wsid = b.wsid
    and a.gdat1 = b.maxgdat
    I can't find any expression for using a (select-statement in a from-clause)
    thanks
    Nikolai

    JPQL does not support sub-selects in the from clause. You can use a native SQL query for this in JPA.
    James : http://www.eclipselink.org

Maybe you are looking for

  • Error installing Oracle 92021 on Windows 2003 Std 64x

    Bit of an Oracle newb here, so someone set me strait... I need to install a test instance of Oracle 92x, and I want to install it on my Windows Server 2003 R2 x64 system (AMD Athlon 64 X2 4400+, 4GB RAM, if it matters). I downloaded the Windows 2003

  • I cannot upload itunes i get an error 7 Windows error 193

    when I click on itunes I get an error message 7 and (Windows error 193)  I have tried to delete and reinstall twice also shutting down.

  • ITunes misinterprets size of iPod...

    I have a 20gb 4th gen iPod with a click wheel and for the last 2 years it has been working fine. Now, I think since the iTunes 7 update iTunes thinks that the iPod is bigger than it is... For example on the special iPod info page in iTunes it says at

  • Issue Output to within VF03

    I need to know how to activate "Issue to Output" within VF03, the menu option is active on the initial screen of VF03.  I need it active while inside VF03, the menu path is "Billing Document/Issue Output To/Issue Output to but it's greyed out not act

  • How to distribute from cost center to profit centers?

    Dear Experts, We have created profit centers as per business.  We have certain expenses that are common.  e.g. IT, A/c, HR etc.  We have created cost centers for the same.  Now we want to assign it to various PCs.  How to distribute from cost center