Group By in sql statement....

I have the following sql statement:
SELECT ROWNUM AA, EPONYMO||' '||ONOMA FNAME ,CODE_ERGAZOMENOY_TYPE_ID,MV_SIGK_KATAST_MINA.SUM_ODOIP_EXODA,
MV_SIGK_KATAST_MINA.SUM_HMERISIA_APOZIMIOSI, MV_SIGK_KATAST_MINA.SUM_SINOLO,
MV_SIGK_KATAST_MINA.SUM_KRATISI_MTPY,
MV_SIGK_KATAST_MINA.SUM_KRATISI_G_EPIM, MV_SIGK_KATAST_MINA.SUM_KRATISI_TADKY,
MV_SIGK_KATAST_MINA.ETOS , (SELECT NVL(SUM(DAYS),0) FROM MOD3_PRAGMATOP_ODOIP WHERE
CODE_ERGAZOMENOY_TYPE_ID=MV_SIGK_KATAST_MINA.CODE_ERGAZOMENOY_TYPE_ID AND
MINAS||'/'||ETOS BETWEEN :P_MONTH_APO||'/'||:P_ETOS_APO AND :P_MONTH_EOS||'/'||:P_ETOS_EOS) PRAGM_ODOIP ,
(SELECT DAYS FROM REF_DIKAIOUM_MERES_EKTOS_EDRAS
WHERE SYSDATE BETWEEN DATES_APO AND DATES_EOS AND
SEQ_CODE_ERGAZOMENOY_TYPE_ID=MV_SIGK_KATAST_MINA.CODE_ERGAZOMENOY_TYPE_ID) DIKAIOUM_ODOIP , MV_SIGK_KATAST_MINA.SUM_SINOLO-(MV_SIGK_KATAST_MINA.SUM_KRATISI_MTPY+MV_SIGK_KATAST_MINA.SUM_KRATISI_G_EPIM+MV_SIGK_KATAST_MINA.SUM_KRATISI_TADKY) NET_POSO
FROM MV_SIGK_KATAST_MINA  , REF_ERGAZOMENOS
WHERE REF_ERGAZOMENOS.SEQ_CODE_ERGAZOMENOY=MV_SIGK_KATAST_MINA.CODE_ERGAZOMENOY_TYPE_ID
  AND MV_SIGK_KATAST_MINA.MINAS||'/'||MV_SIGK_KATAST_MINA.ETOS BETWEEN :P_MONTH_APO||'/'||:P_ETOS_APO AND :P_MONTH_EOS||'/'||:P_ETOS_EOS
and i want to compute the sum of the above selected columns adding a group by clause.....Is it possible.....?????
Some sample data...
MINAS     ETOS     CODE_ERGAZOMENOY_TYPE_ID     SUM_ODOIP_EXODA     SUM_HMERISIA_APOZIMIOSI     SUM_SINOLO     SUM_KRATISI_MTPY     SUM_KRATISI_G_EPIM     SUM_KRATISI_TADKY
07     2007     161     505,95     508,64     972,74     10,32     25,48     20,28
07     2007     230     85,3     78,25     163,55     1,59     3,92     3,12
06     2007     230     0     9,78     9,78     0     0     0
06     2007     161     421,75     254,31     676,06     5,17     12,74     10,14
07     2007     26     118,35     303,21     330,81     6,17     15,19     12,09
05     2007     230     0     9,78     9,78     0     0     0
07     2007     236     328,25     88,04     407,04     1,78     4,41     3,51I use OracleDB10g...
Sorry for the format of the sample data.....!!!!
Thanks, a lot
Simon
Message was edited by:
sgalaxy

To columns... which do have the 'SUM_' prefix ....such as ...
EPONYMO||' '||ONOMA ,
CODE_ERGAZOMENOY_TYPE_ID,
MV_SIGK_KATAST_MINA.ETOS,
PRAGM_ODOIP (nested select query),
DIKAIOUM_ODOIP (nested select query)
I THINK... I HAVE DONE IT... I'LL CHECK IT MORE CAREFULLY...
Thanks...a lot
Simon
Message was edited by:
sgalaxy

Similar Messages

  • Help with Group By on SQL statement

    Iu2019m trying to group by Item Code in the following query, however, I keep receiving the following error message.  Do you know why?
    Msg 306, Level 16, State 2, Line 1
    The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
    SELECT            dbo.OQUT.DocNum,
                      dbo.OQUT.U_UDF_3 AS QuoteNumber,
                      dbo.OQUT.U_QuoteDesc,
                      dbo.OQUT.U_RevQuote,
                      dbo.OQUT.U_RevDate,
                      dbo.OQUT.DocDate,
                      dbo.OQUT.DocDueDate,
                      dbo.OQUT.U_ReqDate,
                      dbo.OQUT.U_DueDate,
                      dbo.OQUT.CardCode,
                      dbo.OQUT.CardName,
                      dbo.OQUT.CntctCode,
                      dbo.QUT1.LineNum,
                      dbo.QUT1.BaseLine,
                      dbo.QUT1.ItemCode,
                      dbo.QUT1.Dscription,
                      SUM(dbo.QUT1.Quantity),
                      SUM(dbo.QUT1.OpenQty),
                      SUM(dbo.QUT1.U_Original_Qty),
                      dbo.QUT1.U_LeadTime,
                      dbo.QUT1.Price,
                      SUM(dbo.QUT1.LineTotal),
                      dbo.QUT1.unitMsr AS SalUnitMsr,
                      dbo.QUT1.U_UDF_12 AS PNQuoted,
                      dbo.QUT1.U_UDF_13 AS MFRQuoted,
                      dbo.QUT1.U_UDF_16 AS MinQty,
                      dbo.QUT1.U_UDF_17 AS MultiQty,
                      dbo.TBC_AMLPriority1.U_Mfg_Name,
                      dbo.TBC_AMLPriority1.U_Mfg_PN,
                      dbo.QUT1.U_Parent,
                      dbo.ITT1.Quantity AS BOMQty,
                      dbo.OCPR.Name
    FROM         dbo.OQUT INNER JOIN
                      dbo.QUT1 ON dbo.OQUT.DocEntry = dbo.QUT1.DocEntry LEFT OUTER JOIN
                        dbo.OCPR ON dbo.OQUT.CntctCode = dbo.OCPR.CntctCode LEFT OUTER JOIN
    dbo.ITT1 ON dbo.QUT1.ItemCode = dbo.ITT1.Code AND dbo.QUT1.U_Parent =
    dbo.ITT1.Father LEFT OUTER JOIN
                      dbo.TBC_AMLPriority1 ON dbo.QUT1.ItemCode = dbo.TBC_AMLPriority1.U_ItemCode
    WHERE     (dbo.QUT1.Quantity > 0)and dbo.OQUT.DocNum='1'
    GROUP BY    dbo.QUT1.ItemCode,
                dbo.OQUT.DocNum,
                dbo.OQUT.U_UDF_3

    Dear,
    As per your message you mentioned that u r getting following error "
    The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator."
    The error is due to group by of a field whose type is text,ntext.....
    if it is text or ntext just replace that field
    Convert(varchar(100),fieldName)...
    Hope it will help you....
    Regards
    Sanjay

  • SQL Statement -- Throws GROUP BY issue on NVL

    Hey All,
    This is pretty much my first time tackling a very complex SQL Statement but the boss is adamant about it.
    Anyways here is the information. I have 3 Tables. Table one Contains Work Order Infromation that will be listed or grouped. Table 2 and Table 3 house information that needs to be summed (Estimate hours and Actual Hours).
    So my SQL Statement looked something like this... (Its a mess)
    select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours, sum(wplabor.quantity * wplabor.laborhrs) as estimatehrs
    from maximo.workorder left outer join maximo.labtrans on labtrans.regularhrs > 0 and labtrans.refwo = workorder.wonum and labtrans.siteid = workorder.siteid or labtrans.premiumpayratetype = 'MULTIPLIER' and labtrans.refwo = workorder.wonum and labtrans.siteid = workorder.siteid left outer join maximo.wplabor on wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid
    where workorder.istask=0 and workorder.siteid='NTS' and workorder.status in ('INPRG','SCHED') and workorder.crewid in ('MAINT','DAF') and workorder.schedstart <= TO_DATE('12-13-2009','MM-DD-YYYY') and wolo3 is not null group by workorder.wonum, workorder.status, workorder.wopriority, workorder.pmnum, workorder.location, workorder.description, workorder.targstartdate, workorder.reportdate, workorder.schedstart, workorder.wolo3, workorder.wojp1
    Now the problem is that the 2nd sum (Estimate Hrs) gets HUGE numbers if there are multiple rows in Actual Hours. So I did some searching. Seems that if I used the NVL function in the SQL Statement it would fix the issue...
    select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours,
    nvl((select sum(wplabor.quantity * wplabor.laborhrs) from maximo.wplabor where wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid),0)
    from maximo.workorder left outer join maximo.labtrans on labtrans.regularhrs > 0 and labtrans.refwo = workorder.wonum and
    labtrans.siteid = workorder.siteid or labtrans.premiumpayratetype = 'MULTIPLIER' and labtrans.refwo = workorder.wonum and
    labtrans.siteid = workorder.siteid
    where workorder.istask=0 and workorder.siteid='NTS' and workorder.status in ('INPRG','SCHED') and
    workorder.crewid in ('MAINT','DAF') and workorder.schedstart <= TO_DATE('12-13-2009','MM-DD-YYYY') and wolo3 is not null
    group by workorder.wonum, workorder.status, workorder.wopriority, workorder.pmnum, workorder.location, workorder.description, workorder.targstartdate, workorder.reportdate, workorder.schedstart, workorder.wolo3, workorder.wojp1
    However If get the error not a GROUP BY expression.
    I really need this to work. How can I get the NVL to work with out having to define a Group for it. The problem is that it is a "alias column" and you cannot Group by those fields. Frustation sets in... UGH!
    Thanks in Advance, Ben.

    Hi, Ben,
    Wlecome to the forum!
    user12273726 wrote:
    So my SQL Statement looked something like this... (Its a mess)You're right. Fix that first.
    Put each SELECT item, each condition, and each GROUP BY expression on a separate line. Indent to show here the clauses (SELECT, FROM, WHERE) are.
    For example:
    SELECT    workorder.wolo3
    ,       workorder.wojp1
    ,       workorder.wonum
    ,       workorder.description
    ,       workorder.location
    ,       workorder.status
    ,       workorder.wopriority
    ,       workorder.targstartdate
    ,       workorder.reportdate
    ,       workorder.pmnum
    ,       workorder.schedstart
    ,       SUM (labtrans.regularhrs + labtrans.premiumpayhours)     AS actualhours
    ,       SUM (wplabor.quantity * wplabor.laborhrs)          AS estimatehrs
    FROM                  maximo.workorder
    LEFT OUTER JOIN   maximo.labtrans     ON      labtrans.regularhrs         > 0
                                       AND     labtrans.refwo              = workorder.wonum
                             AND     labtrans.siteid              = workorder.siteid
                             OR     labtrans.premiumpayratetype = 'MULTIPLIER'     -- WARNING!  Don't mix AND and OR
                             AND     labtrans.refwo              = workorder.wonum
                             AND     labtrans.siteid              = workorder.siteid
    LEFT OUTER JOIN   maximo.wplabor     ON     wplabor.wonum              = workorder.wonum
                                       AND     wplabor.siteid              = workorder.siteid
    WHERE     workorder.istask      = 0
    AND       workorder.siteid       = 'NTS'
    AND       workorder.status       IN ('INPRG','SCHED')
    AND       workorder.crewid       IN ('MAINT','DAF')
    AND       workorder.schedstart   <= TO_DATE ('12-13-2009','MM-DD-YYYY')
    AND       wolo3                       IS NOT NULL
    GROUP BY  workorder.wonum
    ,            workorder.status
    ,       workorder.wopriority
    ,       workorder.pmnum
    ,       workorder.location
    ,       workorder.description
    ,       workorder.targstartdate
    ,       workorder.reportdate
    ,       workorder.schedstart
    ,       workorder.wolo3
    ,       workorder.wojp1
    ;When you post formatted text on this site, type these 6 characters:
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
    Now the problem is that the 2nd sum (Estimate Hrs) gets HUGE numbers if there are multiple rows in Actual Hours. Huge numbers are not necessarily wrong. Do yo mean the numbers computed by your query are much bigger than they are supposed to be?
    So I did some searching. Seems that if I used the NVL function in the SQL Statement it would fix the issue...
    select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours,
    nvl((select sum(wplabor.quantity * wplabor.laborhrs) from maximo.wplabor where wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid),0)
    ...It looks like you have a Chasm Trap, where you have multiple, independent one-to-many relationships on the same table, and the solution to aggregate them in separate queruies.
    It looks like you're trying to aggregate wplabor in scalar sub-queries, which makes the GROUP BY more complicated (as you discovered), and is also very inefficient.
    It would be easier to code and more efficient to run if you aggregated wplabor in a sub-query, and then joined to this sub-query (and not the actual wplabor table) in your main query.
    If you'd like help, post a little sample data (CREATE TABLE and INSERT statements) for all three tables, and the results you want from that data.
    Simplify as much as possible. Instead of GROUPing BY 11 columns, just GROUP BY, say, 3 columns: the 2 involved in the join condidiotns, and one more. Once you understand how to do this, adding the other expressions will be trivial.
    You can also simplify by ignoring, for now, the WHERE clause, and, therefore, the columns involved in the WHERE clause. It looks like that has nothing to do with the problem. Again, adding the conditions later will be trivial.

  • Group by in a SQL statement

    I have this SQL Statement
    SELECT PTE.PLT_SHORT_NAME PLT_SHORT_NAME,
    COUNT ( * ) SEGMENTS,
    COUNT ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'Y' , 1 , NULL ) ) SEGMENTS_COMPLY,
    COUNT ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'N' , 1 , NULL ) ) SEGMENTS_NO_COMPLY,
    SUM ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'Y' , ( TE.ACTUAL_DURA - ( TE.EXPCT_DURA ) ) , 0 ) ) TIEMPO_GANADO,
    ( ( COUNT ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'Y' , 1 , NULL ) ) / COUNT ( * ) ) * 100 ) || '%' COMPLY_PERCENT,
    SUM ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'N' , ( TE.ACTUAL_DURA - ( TE.EXPCT_DURA ) ) , 0 ) ) TIEMPO_PERDIDO,
    ( SUM ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'Y' , ( TE.ACTUAL_DURA - ( TE.EXPCT_DURA ) ) , 0 ) ) + SUM ( DECODE ( SUBSTR ( TE.EVAL_RESULT , 1 , 1 ) , 'N' , ( TE.ACTUAL_DURA - ( TE.EXPCT_DURA ) ) , 0 ) ) ) DIFERENCIA
    FROM PLT_TRN_EVALS PTE,
    TRN_EVALS TE,
    TRN_EVENT_TIMES_HEADERS TETH
    WHERE ( /* CG$MDTU_QWC_START Q_1.PTE */
    (PTE.PLT_SHORT_NAME IS NOT NULL AND PTE.DELETED = 'N')
    /* CG$MDTU_QWC_END Q_1.PTE */
    ) AND
    ( /* CG$MDTU_QWC_START Q_1.TE */
    (TE.TYP = 'SEG' AND TE.DELETED = 'N')
    /* CG$MDTU_QWC_END Q_1.TE */
    ) AND
    PTE.TE_SEQ = TE.SEQ AND
    ( /* CG$MDTU_QWC_START Q_1.TETH */
    (TETH.DELETED = 'N' AND TETH.SCHED_DATE BETWEEN :P_DATE_FROM AND :P_DATE_TO)
    /* CG$MDTU_QWC_END Q_1.TETH */
    ) AND
    TE.TETH_SEQ = TETH.SEQ
    GROUP BY PTE.PLT_SHORT_NAME
    And I would like to know, how can I include the GROUP BY in order to generate

    I think your question got cut off. What are you trying to generate with this SQL? I should say in advance that Oracle Designer has very few places where you can enter a SELECT command directly. You can usually get it to generate what you need by choosing the correct Table Definition (or View Definition) usages, choosing the display columns you want, and adding WHERE clauses and GROUP BY columns.
    With something as complex as your Statement, I would probably consider creating a View, then use the View in modules.

  • Group by sql statement is not sorted.

    execut sql statement include group by clause in a oci program, the result is not sorted.
    I don't know why..
    in SqlPlus, same sql statement return sorted data.
    SELECT A.SHOP_ID,A.RESALE_TYPE,
    SUM(A.DEAL_AMT,0) DEAL_AMT
    FROM SHOP_ACC A, CD_TAB C
    WHERE A.RESALE_TYPE = C.CD(+)
    AND C.GB = 'AB'
    AND A.ACC_M = :s_AccMonth
    AND DEAL_GB='FOD'
    GROUP BY A.SHOP_ID,A.RESALE_TYPE
    But, RESALE_TYPE is outer join on CD_TAB..
    if remove outer join between CD_TAB and SHOP_ACC,
    sql statement is return sorted result.
    and if modify the column RESALE_TYPE like
    RESALE_TYPE||']' or NVL(RESALE_TYPE,'AAA')
    return sorted result..
    please help..
    thanks for your kind.

    thank you.. for reply..
    I knew that order by clause make to sort.
    but, using group by clause alone in SQL statement, that return sorted results too.
    I was found a fault that outer join table CD_TAB column of one is not symbloc "(+)" in SQL statement
    SELECT A.SHOP_ID,A.RESALE_TYPE,
    SUM(A.DEAL_AMT,0) DEAL_AMT
    FROM SHOP_ACC A, CD_TAB C
    WHERE A.RESALE_TYPE = C.CD(+)
    AND C.GB = 'AB' <----------- AND C.GB(+) = 'AB'
    AND A.ACC_M = :s_AccMonth
    AND DEAL_GB='FOD'
    GROUP BY A.SHOP_ID,A.RESALE_TYPE
    I want to know that why in other application - such as SqlPlus or SqlGate and ..etc. - this fault was ignore.. but OCI application such as my application programs is not ignore.. and is not sorted..
    thank you..

  • How do I use SQL statements to perform calculations with form fields????

    Please help!!! I don't know how to use a SQL statement within my APEX form......
    My form is below. The user will enter the values in the form. Click on Submit. Then we need to run a SQL select statement with those values.
    Our form looks like this:
    Start_Date ____________
    Per_Period ____________
    Period ____________
    [Submit Button]
    The user will enter these 3 values in the form.
    This is an example of an user providing the values:
    Start_Date 03/14/08_______
    Per_Period $200.00________
    Period 4____________
    [Submit Button]
    Then they will click the Submit Button.
    The SQL statement (BELOW) returns output based on the users selections:
    START_DATE PER_PERIOD PERIOD
    14-MAR-2008 00:00 200 Week 1 of 4
    21-MAR-2008 00:00 200 Week 2 of 4
    28-MAR-2008 00:00 200 Week 3 of 4
    04-APR-2008 00:00 200 Week 4 of 4
    Total 800
    This is the full text of the SQL that makes the output above:
    with criteria as (select to_date('03/14/08', 'mm/dd/rr') as start_date,
    4 as periods,
    'Week' as period,
    200 per_period from dual),
    periods as (select 'Week' period, 7 days, 0 months from dual
    union all select 'BiWeek', 14, 0 from dual
    union all select 'Month', 0, 1 from dual
    union all select 'ByMonth', 0, 2 from dual
    union all select 'Quarter', 0, 3 from dual
    union all select 'Year', 0 , 12 from dual
    t1 as (
    select add_months(start_date,months*(level-1))+days*(level-1) start_date,
    per_period,
    c.period||' '||level||' of '||c.periods period
    from criteria c join periods p on c.period = p.period
    connect by level <= periods)
    select case grouping(start_date)
    when 1 then 'Total'
    else to_char(start_date)
    end start_date,
    sum(per_period) per_period,
    period
    from t1
    group by rollup ((start_date, period))
    THANKS VERY MUCH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    You're just doing a parameterized report, where the input fields are your parameters.
    Check out the Advanced Tutorial titled Parameterized Report here:
    http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/rprt_query.htm#BGBEEBJA
    Good luck,
    Stew

  • SQl statement cause extreme Portal log growth

    Our Portal server log file is growing very fast (30 - 50 Mb per minute). When examining the log file we see that the log file does contain only the error messages:
    #1.5#00096BF521750058005A9CA900001E480003E80BD8A2C263#1099562506968#/System/Database/sql/jdbc/common#sap.com/irj#com.sap.sql.jdbc.common.StatementAnalyzerImpl#Guest#18####655e44612e4811d9b41300096bf52175#Thread[ThreadPool-Dispatcher,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error#1#com.sap.sql.jdbc.common.StatementAnalyzerImpl#Java#com.sap.sql.jdbc.common_1123#com.sap.sql.log.OpenSQLResourceBundle#The SQL statement "" contains the semantics error[s]: #2#SELECT MIN("ID"),"PRIORITY" FROM "KMC_TQ_QUEUE" WHERE "NAMESPACE_HASH" = ? AND "NAMESPACE" = ? AND "TASK_STATE" = 1 GROUP BY "PRIORITY" ORDER BY 2 DESC#type check error: the expression >>"NAMESPACE"<< (LONGVARCHAR) is not comparable and must not be used with "="
    This message occurs more than 500 times per log file. It has something to do with Knowledge management, but we cannot find anything that triggers this sql statement.
    Any ideas?
    Noel Hendrikx & Pascal Rijnart

    SAP tells us in reaction to our customer message:
    "The table's definition is correct. What has to be changed is the
    computed type for field NAMESPACE and the generated file for the table.
    As I wrote before, if you make any change in the field NAMESPACE the
    new computation is started (so change the description which has no
    effect on the table's version on the database). Make the change and
    save the table in the SapNetWeaver Developer Studio. You will then
    see that the field's JDBC-type changes to VARCHAR.
    Choose 'Create archive' for Dictionary Project the table belongs to
    and deploy the sda on the database. Both can be done in the studio."
    Can anyone tell us what to do now?
    Noel Hendrikx

  • Possible to do "grant" sql statement in Native SQL?

    We have a need to do a grant of access from one of our systems out for various applications.  In order for this to work we need to run a grant access command on the table and are trying to put a wrapper around this so we can use an abap.  Below is the code I am unit testing.  Two questions.  First, can a grant be done via native SQL in abap?  Second, if it can be done, what is the error with the logic where I am trying to put in the table name via a parameter.
    REPORT  ZLJTEST2.
    tables dd02l.
    DATA scarr_carrid TYPE dd02l-tabname.
    SELECT-OPTIONS s_carrid for dd02l-tabname no intervals.
    DATA s_carrid_wa LIKE LINE OF s_carrid.
    DATA name TYPE c LENGTH 20.
    TRY.
        EXEC SQL.
          CREATE FUNCTION selfunc( input CHAR(20) )
            RETURNING char(20);
            DEFINE output char(20);
            set schema sapr3;
            grant select on table input to group infouser;
            RETURN output;
            END FUNCTION;
        ENDEXEC.
        LOOP AT s_carrid INTO s_carrid_wa
                         WHERE sign = 'I' AND option = 'EQ'.
          TRY.
             EXEC SQL.
                EXECUTE PROCEDURE selfunc( IN  :s_carrid_wa-low,
                                           OUT :name )
              ENDEXEC.
              WRITE: / s_carrid_wa-low, name.
            CATCH cx_sy_native_sql_error.
              MESSAGE `Error in procedure execution` TYPE 'I'.
          ENDTRY.
        ENDLOOP.
        EXEC SQL.
          DROP FUNCTION selfunc;
        ENDEXEC.
      CATCH cx_sy_native_sql_error.
        MESSAGE `Error in procedure handling` TYPE 'I'.
    ENDTRY.

    Hi,
    Yes it is posible.
    I made one program like you want. But it need very long code.
    Here I explain the idea:
    1. Create Screen with input TEXT EDIT CONTROL.
        This is for input SQL Statement.
    2. Get SQL Statement from Text Edit Control using method <b>get_text_as_r3table</b>.
    3. Now we need to separate SQL Statement into different table.
        We Separate SELECT, FROM, WHERE, GROUP, HAVING, ORDER, etc.
    4. We need dynamic internal table to store the data.
    5. Select the data according SQL statement.
          SELECT (IT_SELECT)
            into corresponding fields of table  <dyn_table>
          FROM (IT_FROM)
          WHERE (IT_WHERE)
          GROUP BY (IT_GROUP)
          HAVING (IT_HAVING)
          ORDER BY (IT_ORDER).
    6. Display our data using ALV GRID
    Hopefully it will help you.
    Regards,

  • Assigning values to 2 fields using sql statement

    db11g , apex 4.0 and firefox 24 ,
    hi all ,
    i am trying to follow this tutorial to assign values to 2 items on a page using sql statement ,
    and i am using the same sql statement the tutorial uses
    select d.loc location, count(e.empno) num_employees from dept d, emp e where d.deptno = e.deptno(+) and d.deptno = :P3_DEPTNO group by d.loc -- btw , what does the "+" sign mean?
    after the e.deptno in the where condition .
    but i am facing this error
    1 error has occurred
    Wrong number of columns selected in the SQL query. See Help of attribute for details.
    and it does not work with two columns in the select statement under any conditions , i tried to remove the group function and the group clause ,
    it does not work unless i use only one column in the select statement ??
    thanks

    Pars
    And how exactly is this rewrite of the sql statement resolving the OP's issue.
    You are still using more than 1 column which will still result in the error message:
    Wrong number of columns selected in the SQL query.
    As mentioned in my earlier post APEX 4.0 (the version the OP is using) does not handle a sql statement with multiple columns for the dynamic action Set Value.
    Which means the fastest  and simplest solution is splitting up the dynamic action in multiple Set Value actions.
    Using this plugin or upgrade to a newer apex version would also be a possibility.
    Nicolette

  • Adding a field to an sql statement in Oracle Reports error ORA-00933

    We have been requested to add a field that already exists in the table referred to by the sql statement in Oracle Reports Builder. The report was set up by a consultant about 3 yrs ago and we don't really have much skill in this area. What is happening when I try to modify the SQL statement, either adding a field or deleting a field to the SELECT statement, causes an error message preventing the statement from being saved. The only way out of the error message is to click Cancel. The error message is
    ORA-00933:SQL command not properly ended
    ORDER BY Program ==> NAME
    Even adding or deleting a space anywhere in the SQL statement causes the error (not adding any new fields). A coworker found that if we comment out the ORDER BY, the statement will accept the new field in the SELECT section, however then we lose the order by functionality. I would like to add one additional field before the FROM. Not sure if any additional data are needed. Thank you.
    SELECT p.person_uid PIDM_KEY, p.id_number ID,
                   p.full_name_lfmi name,            
                    p.BIRTH_DATE, p.GENDER Sex,
                    Decode(a.residency,'D',p.Primary_ethnicity,'F')  Ethn,
                    a.academic_period TERM,        
                    CASE WHEN :p_group_by = 'PROGRAM' THEN a.program
                                 ELSE ' '
                    END AS Program,
                    a.COLLEGE, a.degree, a.major, ' ' rule,
                    a.STUDENT_POPULATION,a.STUDENT_LEVEL,    a.application_status Status,  a.application_status_date app_sts_dte,
                    ad.decision_date1 Last_Dec_Date,
                    ad.decision1||' '||ad.decision2||' '|| ad.decision3||' '|| ad.decision4||' '|| ad.decision5 Decisions,
                    /*  Deposit Date uses the last term entered in :p_term parameter string */
                    (SELECT MAX(deposit_effective_date) FROM usf_as_deposit WHERE account_uid = a.person_uid &term_clause group by account_uid)   AS "DEPOSIT DATE",     
                    ph.phone as PHONE,
                    CASE WHEN PS.FIRST_CONTACT IN ('NET','PAP','COM','COP') THEN PS.First_Contact
                     ELSE CASE WHEN ps.latest_contact IN ('NET','PAP','COM','COP') THEN PS.Latest_Contact
                                ELSE '  '
                                END
                    END AS FIRST_CONTACT,
                    DECODE(:p_address,'Y',REPLACE(adr.street1||' '||adr.street2||' '||adr.street3||' '||adr.city||','||adr.state||' '||adr.nation||' '||adr.zip,'  ',' '),' ') as  address, adr.nation, adr.state,
                    goremal_email_address email, a.residency, a.application_date, p.primary_ethnicity, c.cohort
    FROM MST_ADMISSIONS_APPLICATION A,
               MST_PERSON p,mst_pre_student PS,  Admissions_Cohort c, usf_v_phone_pr_ma ph,
               MST_admissions_decision_slot AD, usf_v_email, usf_v_address_dr_lr_ma_pr adr
    WHERE a.PERSON_UID = p.person_uid
            AND a.curriculum_priority  = 1
            AND a.person_uid = ps.person_uid
           AND a.person_uid = ad.person_Uid(+)
           AND a.person_uid = goremal_pidm(+)
           AND a.person_uid = adr.pidm(+)
           AND a.person_uid = ph.pidm(+)
           AND ph.rnum(+) = 1
           AND a.person_uid = c.person_uid(+)
           AND a.academic_period = c.academic_period(+)
      &Where_Clause
           /*    TAKE OUT FOLLOWING LINE AFTER DATA IS CLEANED UP  */
            AND NOT(p.id_number = '00000000'   OR SUBSTR(p.id_number,1,1) = 'B'  OR UPPER(p.full_name_lfmi)  LIKE '%TESTING%')
           AND  a.application_status_date >= NVL(:p_as_of_date,sysdate-8000)
           AND a.academic_period = ad.academic_period(+)
            AND a.application_number = ad.application_number(+)
            AND a.degree <> 'ND'    /*   AND a.college <> 'LW'                         --  Does not need non-degree and law students    */
           &Cohort_Clause 
    ORDER BY Program  &ORDER_CLAUSE

    Hi Denis,
    I tried your suggestion. The good thing is that adding the comma allowed me to be able to add a.campus to the select statement, unfortunately, another error message happened.
    ORA-00936: missing expression SELECT p . person_uid PIDM_KEY ,
    p . id_number , p . full_name_lfmi name , p . BIRTH_DATE , p . GENDER Sex ,
    Decode ( a . residency , 'D' , p . Primary_Ethnicity , 'F' ) Ethn , a . academic_period TERM ,
    CASE WHEN : P_group_by = 'PROGRAM THEN a I started over and tried only putting in the comma and get the same message even though I didn't add campus. After that, removed the comma which led to the ORA-00933 error message. So once again, I had to close the file without saving, in order for the report to run at all.

  • [0098]SQL*Plus encountered oracle error 100 while executing SQL Statement

    Hi,
    i'm trying to delete duplicate records from a table and running following script. this script is triggered from a unix script. it successfully deletes the records but in the last throws following error message,
    :[0098]SQL*Plus encountered oracle error 100 while executing SQL Statement:2:Investigation required:
    can anybody please help? below is the script.
    DECLARE
    --CURSOR FOR DUPLICATE ROWS
    CURSOR CUR_DUPLICATE_ROWS IS
    Select RMS_NOTE_ID, RMS_SUMMARY_NOTE_ID, count(*) cnt from PARTY_NOTE
    group by RMS_NOTE_ID,RMS_SUMMARY_NOTE_ID having count(*) > 1;
    var_date PARTY_NOTE.PARTY_NOTE_CREATED_DATE%TYPE;
    BEGIN
    FOR DUPLICATE_ROWS_REC IN CUR_DUPLICATE_ROWS
    LOOP
    delete from party_note
    where RMS_NOTE_ID= DUPLICATE_ROWS_REC.RMS_NOTE_ID
    and RMS_SUMMARY_NOTE_ID= DUPLICATE_ROWS_REC.RMS_SUMMARY_NOTE_ID
    and rowid not in (select max(rowid) from party_note
    where RMS_NOTE_ID= DUPLICATE_ROWS_REC.RMS_NOTE_ID and RMS_SUMMARY_NOTE_ID= DUPLICATE_ROWS_REC.RMS_SUMMARY_NOTE_ID);
    commit;
    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
    ROLLBACK;
    END;

    Try this:
    delete party_note
    where  rowid not in (select max(rowid)
                         from   party_note
                         group  by rms_note_id, rms_summary_note_id
    commit;No need for cursors and loops.
    And when that's completed, consider ALTERing the table to add a unique index (or even a primary key) so you'll never need to do this again.

  • SQL Statements in ABAP and meaning

    Hello Friends,
    Please, can anybody provide me a documentation on the different ABAP SQL statements and there usage/meanings.
    Thanks,
    Shreekant

    hi,
    goto abapdocu->abap Database access->open Sql you will get examples.
    for documnetation got se38->specify the command and press F1.
    SELECT:
    Put the curson on that word and press F1 . You can see the whole documentation for select statements.
    SELECT result
    FROM source
    INTO|APPENDING target
    [[FOR ALL ENTRIES IN itab] WHERE sql_cond]
    Effect
    SELECT is an Open-SQL-statement for reading data from one or several database tables into data objects.
    The select statement reads a result set (whose structure is determined in result ) from the database tables specified in source, and assigns the data from the result set to the data objects specified in target. You can restrict the result set using the WHERE addition. The addition GROUP BY compresses several database rows into a single row of the result set. The addition HAVING restricts the compressed rows. The addition ORDER BY sorts the result set.
    The data objects specified in target must match the result set result. This means that the result set is either assigned to the data objects in one step, or by row, or by packets of rows. In the second and third case, the SELECT statement opens a loop, which which must be closed using ENDSELECT. For every loop pass, the SELECT-statement assigns a row or a packet of rows to the data objects specified in target. If the last row was assigned or if the result set is empty, then SELECT branches to ENDSELECT . A database cursor is opened implicitly to process a SELECT-loop, and is closed again when the loop is ended. You can end the loop using the statements from section leave loops.
    Up to the INTO resp. APPENDING addition, the entries in the SELECTstatement define which data should be read by the database in which form. This requirement is translated in the database interface for the database system´s programming interface and is then passed to the database system. The data are read in packets by the database and are transported to the application server by the database server. On the application server, the data are transferred to the ABAP program´s data objects in accordance with the data specified in the INTO and APPENDING additions.
    System Fields
    The SELECT statement sets the values of the system fields sy-subrc and sy-dbcnt.
    sy-subrc Relevance
    0 The SELECT statement sets sy-subrc to 0 for every pass by value to an ABAP data object. The ENDSELECT statement sets sy-subrc to 0 if at least one row was transferred in the SELECT loop.
    4 The SELECT statement sets sy-subrc to 4 if the result set is empty, that is, if no data was found in the database.
    8 The SELECT statement sets sy-subrc to 8 if the FOR UPDATE addition is used in result, without the primary key being specified fully after WHERE.
    After every value that is transferred to an ABAP data object, the SELECT statement sets sy-dbcnt to the number of rows that were transferred. If the result set is empty, sy-dbcnt is set to 0.
    Notes
    Outside classes, you do not need to specify the target area with INTO or APPENDING if a single database table or a single view is specified statically after FROM, and a table work area dbtab was declared with the TABLES statement for the corresponding database table or view. In this case, the system supplements the SELECT-statement implicitly with the addition INTO dbtab.
    Although the WHERE-condition is optional, you should always specify it for performance reasons, and the result set should not be restricted on the application server.
    SELECT-loops can be nested. For performance reasons, you should check whether a join or a sub-query would be more effective.
    Within a SELECT-loop you cannot execute any statements that lead to a database commit and consequently cause the corresponding database cursor to close.
    SELECT - result
    Syntax
    ... lines columns ... .
    Effect The data in result defines whether the resulting set consists of multiple rows (table-like structure) or a single row ( flat structure). It specifies the columns to be read and defines their names in the resulting set. Note that column names from the database table can be changed. For single columns, aggregate expressions can be used to specify aggregates. Identical rows in the resulting set can be excluded, and individual rows can be protected from parallel changes by another program.
    The data in result consists of data for the rows lines and for the columns columns.
    SELECT - lines
    Syntax
    ... { SINGLE }
    | { { } } ... .
    Alternatives:
    1. ... SINGLE
    2. ... { }
    Effect
    The data in lines specifies that the resulting set has either multiple lines or a single line.
    Alternative 1
    ... SINGLE
    Effect
    If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used.
    An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
    Note
    When SINGLE is being specified, the lines to be read should be clearly specified in the WHERE condition, for the sake of efficiency. When the data is read from a database table, the system does this by specifying comparison values for the primary key.
    Alternative 2
    Effect
    If SINGLE is not specified and if columns does not contain only aggregate expressions, the resulting set has multiple lines. All database lines that are selected by the remaining additions of the SELECT command are included in the resulting list. If the ORDER BY addition is not used, the order of the lines in the resulting list is not defined and, if the same SELECT command is executed multiple times, the order may be different each time. A data object specified after INTO can be an internal table and the APPENDING addition can be used. If no internal table is specified after INTO or APPENDING, the SELECT command triggers a loop that has to be closed using ENDSELECT.
    If multiple lines are read without SINGLE, the DISTINCT addition can be used to exclude duplicate lines from the resulting list. If DISTINCT is used, the SELECT command circumvents SAP buffering. DISTINCT cannot be used in the following situations:
    If a column specified in columns has the type STRING, RAWSTRING, LCHAR or LRAW
    If the system tries to access pool or cluster tables and single columns are specified in columns.
    Note
    When specifying DISTINCT, note that you have to carry out sort operations in the database system for this.
    SELECT - columns
    Syntax
    | { {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ... }
    | (column_syntax) ... .
    Alternatives:
    1. ... *
    2. ... {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ...
    3. ... (column_syntax)
    Effect
    The input in columns determines which columns are used to build the resulting set.
    Alternative 1
    Effect
    If * is specified, the resulting set is built based on all columns in the database tables or views specified after FROM, in the order given there. The columns in the resulting set take on the name and data type from the database tables or views. Only one data object can be specified after INTO.
    Note
    If multiple database tables are specified after FROM, you cannot prevent multiple columns from getting the same name when you specify *.
    Alternative 2
    ... {col1|aggregate( col1 )}
    {col2|aggregate( col2 )} ...
    Effect
    A list of column labels col1 col2 ... is specified in order to build the resulting list from individual columns. An individual column can be specified directly or as an argument of an aggregate function aggregate. The order in which the column labels are specified is up to you and defines the order of the columns in the resulting list. Only if a column of the type LCHAR or LRAW is listed does the corresponding length field also have to be specified directly before it. An individual column can be specified multiple times.
    The addition AS can be used to define an alternative column name a1 a2 ... with a maximum of fourteen digits in the resulting set for every column label col1 col2 .... The system uses the alternative column name in the additions INTO|APPENDING CORRESPONDING FIELDS and ORDER BY. .
    http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm

  • How to dynamically create sql statement for Defaulting Segment Values?

    Hi,
    Navigation:
    1) Descriptive/Segments
    2) Query for DFF to be modified
    3) Uncheck “Freeze Flexfield Definition”
    4) (B) Segments
    5) Segments Summary form opens
    6) (B) open - Segments form opens
    Now, here I want to specify Default type as "SQL Statement" and in the default value field I want to use SQL statement with parameters (to evaluate the default value).
    The parameters should be pass at runtime from the form in which we have this DFF. The parameters value should be one of the values which get evaluated at runtime in the form window.
    Please suggest how we can achieve this?
    Or is there any alternative to achieve this?
    Thanks!!
    Regards,
    Narender
    Edited by: Narender Singh on Mar 30, 2010 7:47 AM
    Edited by: Narender Singh on Mar 30, 2010 7:48 AM

    Jason,
    it is possible, though not so simple as with a report.
    What you need to do is to create a pipelined function, that returns your date and count data. This pipelined function can be the base of a pseudo-table, which can be used in a select. For the pipelined function you need to define types for one row and a table to define the return-type for your function:
    create or replace type calendar_row as object (date_time date, description varchar2(250));
    create type calendar_table as table of calendar_row;
    Then you can create the package with the function:
    ================================================
    create or replace package dyn_calendar is
    procedure set_query(i_query in varchar2);
    function view_source return calendar_table pipelined;
    end;
    create or replace package body dyn_calendar is
    v_query varchar2(100) := null;
    procedure set_query(i_query in varchar2) is
    begin
    v_query := i_query;
    end;
    function view_source return calendar_table pipelined is
    TYPE cursor IS REF CURSOR;
    c_cal cursor;
    v_date_time date := null;
    v_description varchar2(100) := null;
    r_cal calendar_row;
    begin
    open c_cal for v_query;
    fetch c_cal into v_date_time, v_description;
    loop
    exit when c_cal%notfound;
    r_cal := calendar_row(v_date_time, v_description);
    pipe row(r_cal);
    fetch c_cal into v_date_time, v_description;
    end loop;
    return;
    end;
    end;
    ================================================
    Now you can set query in a PL/SL region before the calendar:
    dyn_calendar.set_query(SELECT count(*), ' || :P8_SOURCE_DATE || ' FROM ' || :P8_SOURCE_TABLE || ' GROUP BY ' || :P8_SOURCE_DATE);
    and you can base your calendar on the query:
    select * from table(dyn_calendar(view_source))
    Good luck,
    Dik

  • DBIF_RSQL_INVALID_RSQL The maximum size of an SQL statement was exceeded

    Dear,
    I would appreciate a helping hand
    I have a problem with a dump I could not find any note that I can help solve the problem.
    A dump is appearing at various consultants which indicates the following.
    >>> SELECT * FROM KNA1                     "client specified
    559                  APPENDING TABLE IKNA1
    560                  UP TO RSEUMOD-TBMAXSEL ROWS BYPASSING BUFFER
    ST22
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "/1BCDWB/DBKNA1" had to be terminated because it has
        come across a statement that unfortunately cannot be executed.
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
         and
        therefore caused a runtime error.
        The reason for the exception is:
        The SQL statement generated from the SAP Open SQL statement violates a
        restriction imposed by the underlying database system of the ABAP
        system.
        Possible error causes:
         o The maximum size of an SQL statement was exceeded.
         o The statement contains too many input variables.
         o The input data requires more space than is available.
         o ...
        You can generally find details in the system log (SM21) and in the
        developer trace of the relevant work process (ST11).
        In the case of an error, current restrictions are frequently displayed
        in the developer trace.
    SQL sentence
    550     if not %_l_lines is initial.
    551       %_TAB2[] = %_tab2_field[].
    552     endif.
    553   endif.
    554 ENDIF.
    555 CASE ACTION.
    556   WHEN 'ANZE'.
    557 try.
    >>> SELECT * FROM KNA1                     "client specified
    559                  APPENDING TABLE IKNA1
    560                  UP TO RSEUMOD-TBMAXSEL ROWS BYPASSING BUFFER
    561    WHERE KUNNR IN I1
    562    AND   NAME1 IN I2
    563    AND   ANRED IN I3
    564    AND   ERDAT IN I4
    565    AND   ERNAM IN I5
    566    AND   KTOKD IN I6
    567    AND   STCD1 IN I7
    568    AND   VBUND IN I8
    569    AND   J_3GETYP IN I9
    570    AND   J_3GAGDUMI IN I10
    571    AND   KOKRS IN I11.
    572
    573   CATCH CX_SY_DYNAMIC_OSQL_SEMANTICS INTO xref.
    574     IF xref->kernel_errid = 'SAPSQL_ESCAPE_WITH_POOLTABLE'.
    575       message i412(mo).
    576       exit.
    577     ELSE.
    wp trace:
    D  *** ERROR => dySaveDataBindingValue: Abap-Field= >TEXT-SYS< not found [dypbdatab.c  510]
    D  *** ERROR => dySaveDataBindingEntry: dySaveDataBindingValue() Rc=-1 Reference= >TEXT-SYS< [dypbdatab.c  430]
    D  *** ERROR => dySaveDataBinding: dySaveDataBindingEntry() Rc= -1 Reference=>TEXT-SYS< [dypbdatab.c  137]
    Y  *** ERROR => dyPbSaveDataBindingForField: dySaveDataBinding() Rc= 1 [dypropbag.c  641]
    Y  *** ERROR => ... Dynpro-Field= >DISPLAY_SY_SUBRC_TEXT< [dypropbag.c  642]
    Y  *** ERROR => ... Dynpro= >SAPLSTPDA_CARRIER< >0700< [dypropbag.c  643]
    D  *** ERROR => dySaveDataBindingValue: Abap-Field= >TEXT-SYS< not found [dypbdatab.c  510]
    D  *** ERROR => dySaveDataBindingEntry: dySaveDataBindingValue() Rc=-1 Reference= >TEXT-SYS< [dypbdatab.c  430]
    D  *** ERROR => dySaveDataBinding: dySaveDataBindingEntry() Rc= -1 Reference=>TEXT-SYS< [dypbdatab.c  137]
    Y  *** ERROR => dyPbSaveDataBindingForField: dySaveDataBinding() Rc= 1 [dypropbag.c  641]
    Y  *** ERROR => ... Dynpro-Field= >DISPLAY_FREE_VAR_TEXT< [dypropbag.c  642]
    Y  *** ERROR => ... Dynpro= >SAPLSTPDA_CARRIER< >0700< [dypropbag.c  643]
    I thank you in advance
    If you require other information please request

    Hi,
    Under certain conditions, an Open SQL statement with range tables can be reformulated into a FOR ALL ENTRIES statement:
        DESCRIBE TABLE range_tab LINES lines.
        IF lines EQ 0.
          [SELECT for blank range_tab]
        ELSE.
          SELECT .. FOR ALL ENTRIES IN range_tab ..
          WHERE .. f EQ range_tab-LOW ...
          ENDSELECT.
        ENDF.
    Since FOR ALL ENTRIES statements are automatically converted in accordance with the database restrictions, this solution is always met by means of a choice if the following requirements are fulfilled:
    1. The statement operates on transparent tables, on database views or on a projection view on a transparent table.
    2. The requirement on the range table is not negated. Moreover, the range table only contains entries with range_tab-SIGN = 'I'
    and only one value ever occurs in the field range_tab OPTION.
    This value is then used as an operator with operand range_tab-LOW or range_tab-HIGH.In the above example, case 'EQ range_tab-LOW' was the typical case.
    3. Duplicates are removed from the result by FOR ALL ENTRIES.This must not falsify the desired result, that is, the previous Open SQL statement can be written as SELECT DISTINCT.
    For the reformulation, if the range table is empty it must be handled in a different way:with FOR ALL ENTRIES, all the records would be selected here while this applies for the original query only if the WHERE clause consisted of the 'f IN range_tab' condition.
    FOR ALL ENTRIES should also be used if the Open SQL statement contains several range tables.Then (probably) the most extensive of the range tables which fill the second condition is chosen as a FOR ALL ENTRIES table.
    OR
    What you could do in your code is,
    prior to querying;
    since your select options parameter is ultimately an internal range table,
    1. split the select-option values into a group of say 3000 based on your limit,
    2. run your query against each chunck of 3000 parameters,
    3. then put together the results of each chunk.
    For further reading, you might want to have a look at the Note# 13607 as the first suggestion is what I read from the note.

  • How to pass the bind variable value to the sql statement of the LOV

    Hi,
    I am using Forms 10g builder.
    I have a text item which will be populated by a LOV when i press a button, but i have a bind variable in the SQL statement of the LOV. That bind variable should be replaced by a value which is derived from a radio group in the same data block.
    For Ex: ( )radio1 ( )radio2
    before i click on the push button, I'll select one of the radio button above,so my question is how to assign this radio group value to the bind variable in the sql statement in the LOV?
    Pl any hint is appreciated!
    Thanks
    Reddy

    The variable can be taken into account in the SELECT order contained in the Record Group used by the LOV.
    e.g. Select ... From ... Where column = :block.radio_group ...Francois

Maybe you are looking for

  • Table error in MAM 3.0 SP4

    Hello all, I got an error when using the table ui element. De error is: Error in file: /techobj/edit/ZEquipMeasureDocs.jsp<br/> <br/>Stack trace: <br/>java.lang.NullPointerException<br/>at com.sap.mbs.ca.ur.taglib.table.SapTableHeaderTag.doStartTag(U

  • Why does Bridge CS3 just cease to work?

    Hi there. As of today, I started having trouble with Bridge CS3. Out of the blue, Bridge just cannot be launched anymore. I have 10.6.2 running and it all worked well, I changed nothing and just like that, whenever I try to start the application - no

  • How to display data as separate clumns when db data is as different rows

    Hi, I think i have been confusing the group with UI details. The basic requirement is " To display the data as columns which is present as rows in the table" For example : For customer 1 ,there are 4 accounts. This info is available in the db table a

  • Clear unplaced photos in iBook

    Anyone know if there's a workaround to clear unplaced photos in iBook. Once I've placed the photos I want to use, I'd like to get rid of the ones I haven't used and repalce them with others. Otherwise the list gets too big.

  • Transfer from corporate directory with 8945

    Hi, we have a strange issue with transferring from corporate directory.To be honest we have never really used it so I'm struggling a little with the setup. Call is placed to a phone and answered. on the answered phone User looks up person on Corp dir