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.

Similar Messages

  • 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.

  • NVL in where clause not working with UNIX parameters

    Apparently this in a where clause does not work in UNIX scripts...
    .... and trans_date between to_date('&1','YYYY/MM/DD HH24:MI:SS')
    and to_date(NVL('&2','31-DEC-4712'),'YYYY/MM/DD HH24:MI:SS')
    and to_date(NVL('','31-DEC-4712'),'YYYY/MM/DD HH24:MI:SS')
    ERROR at line 14:
    ORA-01858: a non-numeric character was found where a numeric was expected
    How do I get around a null in UNIX? This works fine if both parameters are populated. Thanks.

    Jason ORCL wrote:
    Apparently this in a where clause does not work in UNIX scripts...
    .... and trans_date between to_date('&1','YYYY/MM/DD HH24:MI:SS')
    and to_date(NVL('&2','31-DEC-4712'),'YYYY/MM/DD HH24:MI:SS')
    and to_date(NVL('','31-DEC-4712'),'YYYY/MM/DD HH24:MI:SS')
    ERROR at line 14:
    ORA-01858: a non-numeric character was found where a numeric was expected
    How do I get around a null in UNIX? This works fine if both parameters are populated. Thanks.it's nothing to do with unix at all - your date value doesn't match the format mask that you've entered:
    '31-DEC-4712' doesn't map to 'YYYY/MM/DD HH24:MI:SS' in any universe unfortunately.

  • 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 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!

  • 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

  • SQL model clause not working when dimensioned on a char or a varchar2 colum

    Hi ,
    I tried to execute the below mentioned query and this returns me columns from monday to sunday values as null.
    select weekno
    , empno
    , mon
    , tue
    , wed
    , thu
    , fri
    , sat
    , sun
    from worked_hours
    model
    return updated rows
    partition by (weekno, empno)
    dimension by ( day )
    measures ( hours,lpad(' ',3) mon,lpad(' ',3) tue, lpad(' ',3) wed,lpad(' ',3) thu,lpad(' ',3) fri,lpad(' ',3) sat,lpad(' ',3) sun)
    RULES upsert
    mon [0] = hours [1]
    , tue [0] = hours [2]
    , wed [0] = hours [3]
    , thu [0] = hours [4]
    , fri [0] = hours [5]
    , sat [0] = hours [6]
    , sun [0] = hours [7]
    In the initial example day is a number and when executed the above query it works. The result set is as below :-
    WEEKNO EMPNO MON TUE WED THU FRI SAT SUN
    1 1210 8 7.5 8.5 4.5 8
    1 1215 2 7.5 8 7.5 8
    When the data type of day is changed to char and populated with the right values then the result set looks as below :-
    WEEKNO EMPNO MON TUE WED THU FRI SAT SUN
    1 1210
    1 1215
    Can anyone help me resolve this ?
    --XXXXX                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    user10723455 wrote:
    Hi ,
    When the data type of day is changed to char and populated with the right values then the result set looks as below :- Can not reproduce on 10.2.0.4.0:
    SQL> select * from v$version
      2  /
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE    10.2.0.4.0      Production
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    SQL> create table worked_hours_char as select * from worked_hours where 1 = 2
      2  /
    Table created.
    SQL> alter table worked_hours_char modify day char(10)
      2  /
    Table altered.
    SQL> insert into worked_hours_char select * from worked_hours
      2  /
    14 rows created.
    SQL> commit
      2  /
    Commit complete.
    SQL> select weekno
      2  , empno
      3  , mon
      4  , tue
      5  , wed
      6  , thu
      7  , fri
      8  , sat
      9  , sun
    10  from worked_hours
    11  model
    12  return updated rows
    13  partition by (weekno, empno)
    14  dimension by ( day )
    15  measures ( hours,lpad(' ',3) mon,lpad(' ',3) tue, lpad(' ',3) wed,lpad(' ',3) thu,lpad(' ',3) fri,lpad(' ',3) sat,lpad(' ',3) su
    n)
    16  RULES upsert
    17  (
    18  mon [0] = hours [1]
    19  , tue [0] = hours [2]
    20  , wed [0] = hours [3]
    21  , thu [0] = hours [4]
    22  , fri [0] = hours [5]
    23  , sat [0] = hours [6]
    24  , sun [0] = hours [7]
    25  )
    26  /
        WEEKNO      EMPNO MON TUE WED THU FRI SAT SUN
             1       1210 8   7.5 8.5 4.5 8
             1       1215 2   7.5 8   7.5 8
    SQL> select weekno
      2  , empno
      3  , mon
      4  , tue
      5  , wed
      6  , thu
      7  , fri
      8  , sat
      9  , sun
    10  from worked_hours_char
    11  model
    12  return updated rows
    13  partition by (weekno, empno)
    14  dimension by ( day )
    15  measures ( hours,lpad(' ',3) mon,lpad(' ',3) tue, lpad(' ',3) wed,lpad(' ',3) thu,lpad(' ',3) fri,lpad(' ',3) sat,lpad(' ',3) su
    n)
    16  RULES upsert
    17  (
    18  mon [0] = hours [1]
    19  , tue [0] = hours [2]
    20  , wed [0] = hours [3]
    21  , thu [0] = hours [4]
    22  , fri [0] = hours [5]
    23  , sat [0] = hours [6]
    24  , sun [0] = hours [7]
    25  )
    26  /
        WEEKNO      EMPNO MON TUE WED THU FRI SAT SUN
             1       1210 8   7.5 8.5 4.5 8
             1       1215 2   7.5 8   7.5 8
    SQL> SY.

  • Group By Clause not working in SQL Server CE Version 3.5.8080.0. Help needed

    SELECT Item_Type.Name AS Item_Type_Name,Category.Name AS Category_Name,UoM.UoM_Name AS Unit_Name,SUM(Invoice_Item.Quantity) AS Qty_Sold,SUM(Invoice_Item.Sold_Price) AS Sale_Price  
    FROM Invoice_Item 
    INNER JOIN Item_Type ON Invoice_Item.ItemType_ID = Item_Type.ID 
    INNER JOIN Category ON Item_Type.Category_ID = Category.ID 
    INNER JOIN UoM ON Item_Type.UoM_ID = UoM.ID  
    GROUP BY Item_Type.ID 
    Its giving following error.
    Unable to get data.In aggregate and grouping expressions, the SELECT clause can contain only aggregates and grouping expressions. [ Select clause = Item_Type,Name ]

    Hi, you have also group by
    Item_Type.Name,Category.Name,UoM.UoM_Name
    Questo post è fornito &quot;così com'è&quot;. Non conferisce garanzie o diritti di alcun tipo. Ricorda di usare la funzione &quot;segna come risposta&quot; per i post che ti hanno aiutato a risolvere il problema e &quot;deseleziona
    come risposta&quot; quando le risposte segnate non sono effettivamente utili. Questo è particolarmente utile per altri utenti che leggono il thread, alla ricerca di soluzioni a problemi similari. ENG: This posting is provided &quot;AS IS&quot;
    with no warranties, and confers no rights. Please remember to click &quot;Mark as Answer&quot; on the post that helps you, and to click &quot;Unmark as Answer&quot; if a marked post does not actually answer your question. Please Vote This As
    Helpful if it helps to solve your issue. This can be beneficial to other community members reading the thread.

  • Query, where clause not working.

    Hi,
    Query is:
    select vbeln posnr matnr
    from vbap
    into table it_ivbap.
    it_ivbap is internal table. i got records when i executed this query.
    gave  a where clause
    select vbeln posnr matnr
    from vbap
    into table it_ivbap
    where vbeln = '5049'.
    it is not returning any records. i tried with all the possile values of vbeln
    what I am doing wrong.
    Thanks in advance.

    Hello,
    Change like this,
    select vbeln posnr matnr
    from vbap
    into table it_ivbap
    where vbeln = '0000005049'. " Check here
    Regards,
    vasanth

  • Two where clauses not working together

    Good afternoon,
    I have a query where I want to find out all unsorted stock (AA, BA, UP & BS) in certain depot's (Carbide dept, Harryworks and Adwick) 
    When I run these where clauses seperately they work but when I combine them they don't work where am I going wrong?
    SELECT tblGRNItem.GRNPrefix + Convert(Varchar(10),tblGRNItem.GRN) AS GRNNumber, tblGRNItemStatus.ShortDescription, tblStorageLocation.Location, tblGRNItem.GRNItemNo, tblSupplier.SupplierName, tblGRNItem.MaterialDescription,tblGRNItem.NettWeight, tblGRNItem.LocalPrice, tblStaff.Initials, tblGRNItem.EstProductionHoursPerPO FROM tblGRNItem INNER JOIN tblGRNItemStatus ON tblGRNItem.GRNItemStatusID = tblGRNItemStatus.ItemStatusID INNER JOIN tblStorageLocation ON tblGRNItem.StorageLocationID = tblStorageLocation.LocationID INNER JOIN tblGRN ON tblGRNItem.GRNID = tblGRN.GRNID INNER JOIN tblSupplier ON tblGRN.SupplierID = tblSupplier.SupplierID INNER JOIN tblStaff ON tblGRNItem.SorterID = tblStaff.UserID
    WHERE tblGRNItemStatus.ShortDescription LIKE 'UP' OR
    tblGRNItemStatus.ShortDescription LIKE 'BA' OR
    tblGRNItemStatus.ShortDescription LIKE 'AA' OR
    tblGRNItemStatus.ShortDescription LIKE 'BS'

    I don't understand the terminology you are using.  Examples would help.
    What do you mean by "works?"  What does the query do that "doesn't work" and what does "works" mean?  "Works" can mean anything from it includes too many rows or it excludes rows.
    Give an example of running the where clause separately (and what is the result you get, either with actual results, representative results or describe the results); give an example of running with the where clauses combined (what is the result ...).
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • 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

  • Programmatic setting of where clause not working.

    Hi,
    I am using Jdeveloper 11.1.2.2 .
    I am trying query some rows from the VO by setting the VO in the programmatic way as given in this documentation : http://docs.oracle.com/cd/E15523_01/web.1111/b31974/bcquerying.htm#CHDEBEAF
    But it is returning no rows. While I tried to query through the SQL Command Line it is querying the rows.
    Is there any conditions that only bind variables declared in the VO can be queried in the programmatic way ? I tried that also. It is still not returning any rows.
    Thanks,
    Nigel.

    in the line of fire wrote:
    The best way to understand sql related issues is to enable debugger logs, where you can see actually what query is then executing. It really helps. Try it.I tried to run in the debugger mode, but there is no query execution seen. It is not throwing any errors, just its not returning the rows in the database.

  • In Report,order by clause is not working

    Hi All,
    For the report i prepared the query in this one am using the order by clause,i run the query in the sql plus working fine am getting the data based on the order by clause.when i use the same query for the report am getting the data but not in the order(i.e order by clause in not working).
    Please help me how to do this one.
    Thanks in Advance.
    Regards,
    Leelakrishna.G

    Hi Dora,
    Data is coming in the proper sequence,but in the first group data is not coming(In first group data first line only displaying,remaining data is not comming).
    My req is:
    The report is executing based on the creation date(i.e.,from creation date to today).
    In this so many Purchase requisitions will be there for this one different approval in different times will be there.
    For Ex:
    we will take 2 PR number only(for the first one 3 approvals,second one 4 levels of approval).
    1. one supplier 1person raised by 1PR submit
    No Action
    Approve
    2. 2Supplier 2personraised by 2PR Submit
    NO Action
    Forword
    Approve
    with ur suggestion am trying data is gettin fine but first group first line is coming remaining data is not coing.
    EX:
    1. one supplier 1person raised by 1PR submit
    No Action
    Approve
    2PR Submit
    NO Action
    Forword
    Approve
    Note:"2. 2Supplier 2personraised by " this kind of lines data is missing.
    Can you pls check and suggest me how i can do this.
    Thanks in Advance.
    Regards,
    Leelakrishna.G

  • Like clause in PreparedStatement not working

    Hi
    I need to create a PreparedStatement that selects using a like where clause. I do the following:
    String param0 = "ABC%";
    PreparedStatement pstmt = conn.prepareStatement("select ISSUEID from DMFI_ISSUE where ISIN like ?");
    setObject(pstmt,1,param0,java.sql.Types.VARCHAR);
    This doesn't work. If param0 is set to the exact value in the database (e.g. "ABCDEF") it selects one, but the like is not working. Is this a jdbc bug? I need to use a PreparedStatement.
    Can anyone help?
    Thanks

    Please ignore, mea culpa, just a vagary of the dos shell. I passed in "abc%" from the dos prompt.

  • DB Adapter wizard – WHERE clause on parent and child tables not working.

    I have two tables, SECURITY and SECURITY_POSITIONS, where SECURITY has a 1:M relationship with SECURITY_POSITIONS. I used the DB-adapter wizard to create the relationship and the following WHERE clause expression which is looking at both the parent and the child tables;
    The expression builder looks like this:
    AND
    |--- 1. partitionKey EQUAL p_SearchKey
    |--- 2. securityType EQUAL “DBT”
    |--- 3. securityPositionsCollection.dealReference EQUAL “NA”
    The primary key on SECURITY = PARTITION_KEY and SECURITY_REFERENCE
    The foreign key from SECURITY_POSITIONS to SECURITY = PARTITION_KEY and SECURITY_REFERENCE
    securityType is on SECURITY table (master)
    securityPositionsCollection.dealReference is on SECURITY_POSITIONS table (child)
    The invoke on the database adapter is selecting a row in securityPositionsCollection for each child row, rather than just those with dealReference = “NA”!
    I turned on DEBUG logging in the BPEL console and I can see that there are 2 SELECT queries run (guess this is how Toplink does it!), where the 1st query appears to select the parent rows and the 2nd query selects the child rows.
    However the 2nd query is not working because it is failing to select only those child rows where dealReference = “NA”. Also, don’t know why the 2nd SELECT query needs to specify the child SECURITY_POSITIONS table twice in the FROM clause, because that seems to be causing the problem.
    1st query executed is as follows;
    SELECT DISTINCT t0.PARTITION_KEY, t0.SECURITY_REFERENCE, t0.SECURITY_TYPE
    FROM CENTRAL.SECURITY t0, CENTRAL.SECURITY_POSITIONS t1
    WHERE ((((t0.PARTITION_KEY = ?) AND (t0.SECURITY_TYPE = ?)) AND (t1.DEAL_REFERENCE = ?)) AND ((t1.SECURITY_REFERENCE = t0.SECURITY_REFERENCE) AND (t1.PARTIT
    ION_KEY = t0.PARTITION_KEY)))
    bind => [200706200000, DBT, NA]
    2nd query executed is as follows, where child table appears twice! ;
    SELECT DISTINCT t0.DEAL_REFERENCE, t0.PARTITION_KEY, t0.SECURITY_REFERENCE
    FROM CENTRAL.SECURITY_POSITIONS t0,
    CENTRAL.SECURITY_POSITIONS t2,
    CENTRAL.SECURITY t1
    WHERE ((((t0.SECURITY_REFERENCE = t1.SECURITY_REFERENCE) AND (t0.PARTITION_KEY = t1.PARTITION_KEY)) AND
    (((t1.PARTITION_KEY = ?) AND (t1.SECURITY_TYPE = ?)) AND
    (t2.DEAL_REFERENCE = ?))) AND
    ((t2.SECURITY_REFERENCE = t1.SECURITY_REFERENCE) AND
    (t2.PARTITION_KEY = t1.PARTITION_KEY)))
    bind => [200706200000, DBT, NA]
    Anyone experienced the same problem e.g. why is toplink making the query more complicated that it needs to be, because the query only needs to reference the SECURITY_POSITIONS table once, as follows;
    SELECT DISTINCT t0.DEAL_REFERENCE, t0.PARTITION_KEY, t0.SECURITY_REFERENCE
    FROM CENTRAL.SECURITY_POSITIONS t0,
    CENTRAL.SECURITY t1
    WHERE ((((t0.SECURITY_REFERENCE = t1.SECURITY_REFERENCE) AND (t0.PARTITION_KEY = t1.PARTITION_KEY)) AND
    (((t1.PARTITION_KEY = '200706200000') AND (t1.SECURITY_TYPE = 'DBT')) AND
    (t0.DEAL_REFERENCE = 'NA'))) AND
    ((t0.SECURITY_REFERENCE = t1.SECURITY_REFERENCE) AND
    (t0.PARTITION_KEY = t1.PARTITION_KEY)))

    Hello,
    It looks like you have configured your 1:M relationship to use batch reading. This causes the query to bring in the Security_Position table's objects to use the same selection criteria as was used on the initial query, with a join statement. This is more efficient in most cases as it ensures only the Security_positions needed for the Security objects to be fully built are read, in a single query.
    The selection criteria added is only used to filter out the Security objects. All referenced Security_Positions must be read in for the returned Security objects so that the data matches what is in the database. If you do not want the Security_Positions, you might try using indirection on the mapping which will delay the second query until you need the Security_Positions. Or, if you want only the Security_Positions with dealReference EQUAL “NA", you could do a query specifically to filter on them.
    Best Regards,
    Chris

Maybe you are looking for