Parameter In Query Problem

Hi All,
I am having some trouble with my query below.  The query runs fine however the moment I put the [%0] parameters in the query does not run at all.  I don't get any errors it just simply does not run.  If I take out this part
AND (T1.WhsCode = '[%0]') AND (T2.U_Principal = '[%1]')
the query runs fine but I would like to be able to select parameters.
SELECT     T0.DocNum AS 'Document Number', T0.CardCode AS 'BP Code',
T0.CardName AS 'BP Name', T1.ItemCode AS 'Item Code', T1.Dscription AS 'Item Description',
T1.Quantity AS 'Ordered', T1.ShipDate AS 'Del. Date', T1.OpenQty AS 'Back Order',
T1.WhsCode AS 'Warehouse', T3.OnHand, T2.U_Principal AS 'Principal'
FROM         ORDR AS T0 INNER JOIN
                      RDR1 AS T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
                      OCRD AS T2 ON T0.CardCode = T2.CardCode INNER JOIN
                      OITW AS T3 ON T1.ItemCode = T3.ItemCode AND T1.WhsCode = T3.WhsCode INNER JOIN
                      OITM AS T4 ON T1.ItemCode = T4.ItemCode
WHERE     (T1.OpenQty > '0') AND (T1.WhsCode = '[%0]') AND (T2.U_Principal = '[%1]')
ORDER BY T1.ShipDate
Any help greatly appreciated.

Try this one:
SELECT     T0.DocNum AS 'Document Number', T0.CardCode AS 'BP Code',
T0.CardName AS 'BP Name', T1.ItemCode AS 'Item Code', T1.Dscription AS 'Item Description',
T1.Quantity AS 'Ordered', T1.ShipDate AS 'Del. Date', T1.OpenQty AS 'Back Order',
T1.WhsCode AS 'Warehouse', T3.OnHand
FROM  dbo.ORDR T0 INNER JOIN
          dbo.RDR1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN
          dbo.OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN
          dbo.OITW T3 ON T1.ItemCode = T3.ItemCode AND T1.WhsCode = T3.WhsCode
WHERE     T1.OpenQty > 0 AND T3.WhsCode LIKE '[%0]'
ORDER BY T1.ShipDate
I have taken out your UDF from your query.  You could added it after query is running.
Thanks,
Gordon

Similar Messages

  • How to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part

    Hi,
    I want to pass multiple query string values using the same parameter in Query String (URL) Filter Web Part like mentioned below:
    http://server/pages/Default.aspx?Title=Arup&Title=Ratan
    But it always return those items whose "Title" value is "Arup". It is not returned any items whose "Title" is "Ratan".
    I have followed the
    http://office.microsoft.com/en-us/sharepointserver/HA102509991033.aspx#1
    Please suggest me.
    Thanks | Arup
    THanks! Arup R(MCTS)
    SucCeSS DoEs NOT MatTer.

    Hi DH, sorry for not being clear.
    It works when I create the connection from that web part that you want to be connected with the Query String Filter Web part. So let's say you created a web part page. Then you could connect a parameterized Excel Workbook to an Excel Web Access Web Part
    (or a Performance Point Dashboard etc.) and you insert it into your page and add
    a Query String Filter Web Part . Then you can connect them by editing the Query String Filter Web Part but also by editing the Excel Web Access Web Part. And only when I created from the latter it worked
    with multiple values for one parameter. If you have any more questions let me know. See you, Ingo

  • Designing LOV Query Problem

    Hello APEX people,
    I posted my problem here:
    Designing LOV Query Problem
    What I have is a sequence like this:
    CREATE SEQUENCE
    DR_SEQ_FIRST_SCHEDULE_GROUP
    MINVALUE 1 MAXVALUE 7 INCREMENT BY 1 START WITH 1
    CACHE 6 ORDER CYCLE ;
    What I need would be a SQL query returning all possible values oft my sequence like:
    1
    2
    3
    4
    5
    6
    7
    I want to use it as a source for a LOV...
    The reason why I use the cycling sequence is: My app uses it to cycle scheduling priorities every month to groups identified by this number (1-7).
    In the Admin Form, I want to restrict the assignment in a user friendly way - a LOV.
    Thanks
    Johann

    Here ist the solution (posted by michales in the PL/SQL forum):
    SQL> CREATE SEQUENCE
    dr_seq_first_schedule_group
    MINVALUE 1 MAXVALUE 7 INCREMENT BY 1 START WITH 1
    CACHE 6 ORDER CYCLE
    Sequence created.
    SQL> SELECT LEVEL sn
    FROM DUAL
    CONNECT BY LEVEL <= (SELECT max_value
    FROM user_sequences
    WHERE sequence_name = 'DR_SEQ_FIRST_SCHEDULE_GROUP')
    SN
    1
    2
    3
    4
    5
    6
    7
    7 rows selected.

  • SQL+-MULTI TABLE QUERY PROBLEM

    HAI ALL,
    ANY SUGGESTION PLEASE?
    SUB: SQL+-MULTI TABLE QUERY PROBLEM
    SQL+ QUERY GIVEN:
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
    DLC_POLYMORPHS_NORMAL_VALUE FROM PATIENTS_MASTER1, HAEMATOLOGY1,
    DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM AND PATIENT_NUM = DLC_PATIENT_NUM AND PATIENT_NUM
    = &PATIENT_NUM;
    RESULT GOT:
    &PATIENT_NUM =1
    no rows selected
    &PATIENT_NUM=2
    no rows selected
    &PATIENT_NUM=3
    PATIENT_NUM 3
    PATIENT_NAME KKKK
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 4
    HMTLY_RBC_NORMAL 4.6-6.0
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     60
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    ACTUAL WILL BE:
    &PATIENT_NUM=1
    PATIENT_NUM 1
    PATIENT_NAME BBBB
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 5
    HMTLY_RBC_NORMAL 4.6-6.0
    &PATIENT_NUM=2
    PATIENT_NUM 2
    PATIENT_NAME GGGG
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     42
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    &PATIENT_NUM=3
    PATIENT_NUM 3
    PATIENT_NAME KKKK
    HMTLY_TEST_NAME HAEMATOLOGY
    HMTLY_RBC_VALUE 4
    HMTLY_RBC_NORMAL 4.6-6.0
    DLC_TEST_NAME DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE     60
    DLC_POLYMORPHS_NORMAL_VALUE     40-65
    4 TABLES FOR CLINICAL LAB FOR INPUT DATA AND GET REPORT ONLY FOR TESTS MADE FOR PARTICULAR
    PATIENT.
    TABLE1:PATIENTS_MASTER1
    COLUMNS:PATIENT_NUM, PATIENT_NAME,
    VALUES:
    PATIENT_NUM
    1
    2
    3
    4
    PATIENT_NAME
    BBBB
    GGGG
    KKKK
    PPPP
    TABLE2:TESTS_MASTER1
    COLUMNS:TEST_NUM, TEST_NAME
    VALUES:
    TEST_NUM
    1
    2
    TEST_NAME
    HAEMATOLOGY
    DIFFERENTIAL LEUCOCYTE COUNT
    TABLE3:HAEMATOLOGY1
    COLUMNS:
    HMTLY_NUM,HMTLY_PATIENT_NUM,HMTLY_TEST_NAME,HMTLY_RBC_VALUE,HMTLY_RBC_NORMAL_VALUE     
    VALUES:
    HMTLY_NUM
    1
    2
    HMTLY_PATIENT_NUM
    1
    3
    MTLY_TEST_NAME
    HAEMATOLOGY
    HAEMATOLOGY
    HMTLY_RBC_VALUE
    5
    4
    HMTLY_RBC_NORMAL_VALUE
    4.6-6.0
    4.6-6.0
    TABLE4:DIFFERENTIAL_LEUCOCYTE_COUNT1
    COLUMNS:DLC_NUM,DLC_PATIENT_NUM,DLC_TEST_NAME,DLC_POLYMORPHS_VALUE,DLC_POLYMORPHS_
    NORMAL_VALUE,
    VALUES:
    DLC_NUM
    1
    2
    DLC_PATIENT_NUM
    2
    3
    DLC_TEST_NAME
    DIFFERENTIAL LEUCOCYTE COUNT
    DIFFERENTIAL LEUCOCYTE COUNT
    DLC_POLYMORPHS_VALUE
    42
    60
    DLC_POLYMORPHS_NORMAL_VALUE
    40-65
    40-65
    THANKS
    RCS
    E-MAIL:[email protected]
    --------

    I think you want an OUTER JOIN
    SELECT PATIENT_NUM, PATIENT_NAME, HMTLY_TEST_NAME, HMTLY_RBC_VALUE,
    HMTLY_RBC_NORMAL_VALUE, DLC_TEST_NAME, DLC_POLYMORPHS_VALUE,
    DLC_POLYMORPHS_NORMAL_VALUE
    FROM PATIENTS_MASTER1, HAEMATOLOGY1,  DIFFERENTIAL_LEUCOCYTE_COUNT1
    WHERE PATIENT_NUM = HMTLY_PATIENT_NUM (+)
    AND PATIENT_NUM = DLC_PATIENT_NUM (+)
    AND PATIENT_NUM = &PATIENT_NUM;Edited by: shoblock on Nov 5, 2008 12:17 PM
    outer join marks became stupid emoticons or something. attempting to fix

  • Disable selection parameter in Query

    Hi,
    I would like to disable selection parameter in query.
    I add below coding in SQ02 "at selection-screen output" but it cannot work. Any solution besides use variant to disable it?
    loop at screen.
      if screen-name = 'pa_date'.
        screen-input = '0'.
        modify screen.
      endif.
    endloop.
    Thanks.

    Hello Winnie,
       Yes you can. Try this one:
    <><><><><><><><><><><><><><><><><><><><><><><><><><><>
    Parameters: aram1  like mara-matnr.
    AT SELECTION-SCREEN OUTPUT.
      loop at screen.
        if screen-name eq 'PARAM1'.
          screen-input = 0.
          modify screen.
        endif.
      endloop.
    <><><><><><><><><><><><><><><><><><><><><><><><><><><>
    Happy coding!

  • How tochange the description ofa field inthe parameter form query generator

    I have a parameter form which is fetching the details from the Location table.
    /* Select From [OLCT] T4 */
    Declare @ToLoc Varchar(300)
    /Where/
    Set @ToLoc = /* T4.Location*/ '[%4]'
    when i execute the parameter form Query selection criteria displayed is
    Name
    OLCT table the description of the field location is Name i want to change the description to location
    Please Help

    Thanks for the reply , It does not help.
    If meant the selection box when I run query to input values
    for example
    /* Select From [OINV] T1 */
    Declare @FromDate Datetime
    /Where/
    Set @FromDate = /* T1.DocDate*/ '[%1]'
    /* Select From [OINV] T2 */
    Declare @ToDate Datetime
    /Where/
    Set @ToDate = /* T2.DocDate*/ '[%2]'
    /* Select From [OLCT] T3 */
    Declare @FromLoc Varchar(300)
    /Where/
    Set @FromLoc = /* T3.Location*/ '[%3]'
    /* Select From [OLCT] T4 */
    Declare @ToLoc Varchar(300)
    /Where/
    Set @ToLoc = /* T4.Location*/ '[%4]'
    /* Select From [OLCT] T5 */
    Declare @Country Varchar(300)
    /Where/
    Set @Country = /* T5.Country*/ '[%5]'
    /* Select From [OLCT] T6 */
    Declare @State Varchar(300)
    /Where/
    Set @State = /* T6.state*/ '[%6]'
    Exec [SAP_SP_DB]..[NABC_TaxReport] 'SAP2007B','Inflow',@FromDate,@ToDate,@FromLoc,@ToLoc,@country,@state
    In the above query I have from and To Location which displays as Name in the selection box

  • Problem in passing parameter to query

    SELECT     OWOR.DocNum, OWOR.Series, OWOR.ItemCode AS Parent, WOR1.ItemCode, OWOR.PlannedQty, WOR1.BaseQty, WOR1.PlannedQty AS 'POD Qty',
                          WOR1.IssuedQty, IGE1.Quantity, IGE1.OpenQty, ITM1.Price, OITW.OnHand
    FROM         OITW INNER JOIN
                          IGE1 ON OITW.WhsCode = IGE1.WhsCode RIGHT OUTER JOIN
                          WOR1 INNER JOIN
                          OWOR ON WOR1.DocEntry = OWOR.DocEntry INNER JOIN
                          ITM1 ON WOR1.ItemCode = ITM1.ItemCode ON OITW.ItemCode = ITM1.ItemCode AND IGE1.BaseEntry = WOR1.DocEntry AND
                          IGE1.BaseLine = WOR1.LineNum
    WHERE     (ITM1.PriceList = 1) AND  OWOR.ItemCode='\[%0]'
    ORDER BY OWOR.DocNum
    This query runs if I remove parameter i.e AND  OWOR.ItemCode='\[%0]'.
    What correction should be done to pass parameter in the above query ?

    Dilip,
    You just need to qualify your query with an Alias.  I have fixed it for you..
    SELECT T3.DocNum, T3.Series, T3.ItemCode AS Parent, T2.ItemCode, T3.PlannedQty, T2.BaseQty, T2.PlannedQty AS 'POD Qty', T2.IssuedQty, T1.Quantity, T1.OpenQty, T4.Price, T0.OnHand
    FROM [DBO\].[OITW\] T0 INNER JOIN [DBO\].[IGE1\] T1 ON T0.WhsCode = T1.WhsCode RIGHT OUTER JOIN [DBO\].[WOR1\] T2
    INNER JOIN [DBO\].[OWOR\] T3 ON T2.DocEntry = T3.DocEntry
    INNER JOIN [DBO\].[ITM1\] T4 ON T2.ItemCode = T4.ItemCode ON T3.ItemCode = T4.ItemCode AND T1.BaseEntry = T2.DocEntry AND T1.BaseLine = T2.LineNum
    WHERE (T4.PriceList = 1) AND T3.ItemCode='[%0\]'
    ORDER BY T3.DocNum
    Suda

  • Out standing MIS Report query problem.

    Hi,
    We designed MIS Report for outstanding mis through Crystal report.here we are facing probleme.ex:AR invoice raised on 01 Jan 09 bill amount 1000 and for this client is received full amount against that bill on 04 march09.in this report we provided parameters for from date and to date. When user selected in parameter from date 010109 to 050309 it will show pending amount is 0.but users are asking if they select from date upto 030309 means it will show pending amount should be show 1000.in this query we are retrieving based on document status when open. How we can show report for this requirements. Please guide me.if we give docstatus='O' or docstatus= 'C' it's showing but pending amount =Bill amount - paid amount here it's showing 0 i think here also we need to pass incoming payment docdate.how wen do please guide me.
    below this is the query.
    set @FromYear=case when month(@ToDate)>=1 and month(@ToDate)<=3 then Year(@ToDate)-1 else Year(@ToDate) end
    set @ToYear=case when month(@ToDate)>=1 and month(@ToDate)<=3 then Year(@ToDate) else Year(@ToDate)+1 end
    --select @fromYear,@toyear,@todate,@ProjCode,@Cardcode,@VoucherType,@GroupName
    select a.u_category,a.docdate,g.name,d.CardCode,d.cardname,e.GroupName,SUBSTRING(CONVERT(VARCHAR(11), a.docdate, 113), 4, 8)as Month of invoiceraised,
    b.seriesname,a.docnum,a.Project,0,a.doctotal,
    paidamount= case when a.paidtodate is NULL then 0 else a.paidtodate end,
    pendingamount= case when isnull(a.doctotal,0)-isnull(a.paidtodate,0) is null then 0 else isnull(a.doctotal,0)-isnull(a.paidtodate,0) end,
    case when year(a.docdate) = @ToYear and month(a.docdate) = 3 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as March ,
    case when year(a.docdate) = @ToYear and month(a.docdate) = 2 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Feb,
    case when year(a.docdate) = @ToYear and month(a.docdate) = 1 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Jan,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 12 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Dec,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 11 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Nov,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 10 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Oct,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 9 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Sept,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 8 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as Aug,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 7 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as July,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 6 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as June,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 5 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as May,
    case when year(a.docdate) = @FromYear and month(a.docdate) = 4 then isnull(a.doctotal,0)-isnull(a.paidtodate,0) else 0 end as April,
    --case when a.docdate = (select f_refdate from ofpr where year(f_refdate)=year(a.refdate) then a.doctotal-c.paidtodate else 0 end as Pre-Yr
    nodocsum=isnull(f.nodocsum,0),0 as PreviousFY
    from oinv a
    left join nnm1 b on a.series=b.series
    inner join INV1 c ON a.DocEntry = c.DocEntry
    inner join OCRD d ON d.CardCode=a.CardCode
    left join ocpr g on g.cardcode=d.cardcode
    Inner join OCRG e on e.GroupCode=d.GroupCode and e.grouptype='c'
    LEFT JOIN ORCT f ON a.DocEntry = f.DocEntry
    where
    a.docstatus='O' and
    case when a.doctotal-a.paidtodate is null then 0 else a.doctotal-a.paidtodate end >= 0
    Reds,
    Sampath kumar devunuri.

    Hi,Gordon Du ,
    We are designing through Crystal reports 2008 only. Based on SQL query how we can maintain History of Document status and date in table. Please give me your advise how we can rectify this problem. Kindly find above query.
    Regds,
    Sampath Kumar.

  • Report parameter from query

    Hi,
    The distribution file uses parameters from the query in the report
    The problem is that if no records match it means that when it tries to resolve &amp;&lt;report_id it can't and generates the following error
    Terminated with error: REP-34308: Invalid reference parameter 'report_id' in distribution list
    Does anyone know how I can check if this is null in the distribution file?
    <foreach>
    <destype id="blob1" name="blobdestination" instance="this" format="pdf">
    <property name="desname"
    value="http://host:port/prod/*&amp;&lt;report_id>*/&amp;&lt;key_val>/&amp;&lt;FileName>/&amp;&lt;Type>"/>
    <include src="mainSection"/>
    </destype>
    </foreach>

    Hi Gorgo,
    According to your description, you have problem when in passing a parameter for running a Oracle Query. Right?
    Based on my knowledge, it use "&" as synax for parameter in Oracle, like we use "@" in SQL Server. In this scenario, maybe you can try '01/01/2014' when inputing in "From". We are not sure if there's any limitation for To_Date()
    function. For your self-testing, you can try the query in sqlplus/sql delveloper. Since your issue is related to Oracle query, we suggest you post this thread onto Oracle forum.
    Best Regards,
    Simon Hou

  • Query problem in non US locale and Buddhist Era

    I try to query a table with a sql statement. Then I use the result from previous statement to query again. But there's no result from the second statement??
    I think it's problem with Regional Options in the machine.
    I'm using w2k sp4.
    JDK1.5
    MySQL 4.0.18
    MySQL connector 3.1.6
    Locale Thai, Default Lang Thai
    Here is the code
    PreparedStatement ps = cn.prepareStatement("select * from EBMS_FRAUD_ATTEMPTS order by action_date asc");
    date1 = rs.getDate("action_date");
    cardNo1 = rs.getString("user_card_number");
    action1 = rs.getString("action");
    System.out.println("date1 : " + date1);
    System.out.println("cardNo1 : " + cardNo1);
    System.out.println("action1 : " + action1);
    ps = cn.prepareStatement("select * from EBMS_FRAUD_ATTEMPTS where action_date=? and user_card_number=? and action=? order by action_date asc");
    ps.setDate(1, new java.sql.Date(date1.getTime()));
    ps.setString(2, cardNo1);
    ps.setString(3, action1);
    System.out.println("date2 : " + date2);
    System.out.println("cardNo2 : " + rs.getString("user_card_number"));
    System.out.println("action2 : " + rs.getString("action"));from the testing, there's no result from the 2nd statement.
    Here is output from 1st statement.
    date1 : 2005-03-04
    cardNo1 : 1234123412341234
    action1 : test1The solution can be
    1. change the locale in regional options to en/US. or.
    2. manually convert date in Java code using the method below before setDate parameter in the 2nd statement.
         private Date convtDate(Date dInput) {
              SimpleDateFormat dfUS = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.US);
              SimpleDateFormat dfTH = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", new Locale("th", "TH"));
              try {
                   return dfTH.parse(dfUS.format(dInput));
              } catch (ParseException e) {
                   return null;
    ps = cn.prepareStatement("select * from EBMS_FRAUD_ATTEMPTS where action_date=? and user_card_number=? and action=? order by action_date asc");
    ps.setMaxRows(1);
    ps.setDate(1, new java.sql.Date(convtDate(date1).getTime()));
    ps.setString(2, cardNo1);
    ps.setString(3, action1);
    ...Both solutions are not good at all. The 1st solution break the run anywhere concept. The 2nd solution is hardcoding. I think there should be a better solution.

    So you think that is the problem? I would suggest you change "think" to "know" there before proceeding. If your solution #2 actually works (you didn't say that) then the locale most likely is the problem. In that case you should contact the maker of your JDBC driver and report the bug.

  • Export with query problem

    Hello,
    I have to export three tables out of my database with a query. I started the export with following command (on a Windows testing machine).
    exp.exe userid=ccq/xxx@KDG file=C:\download\export\NEW.dmp tables= qem_message, qem_messagestatlog, qw_text query=””"where qem_message.messagebody > 739409 AND qem_message.pkey = qem_messagestatlog.pkey AND qem_message.messagebody = qw_text.qwkey" log=C:\download\export\NEW.log
    I have got the following error:
    . . Export of the table QEM_MESSAGE
    EXP-00056: ORACLE-error 904 found
    ORA-00904: Unknown columnname
    I think the problem is the query statement. All the columns are written right. Is there an error in the statement or is it impossible to execute such statement in an export?

    Hi,
    you have to use export one time at a time with query parameter
    consider
    SQL> host type d:\query.txt
    query="where emp.deptno = dept.deptno
           and emp.sal > 1000
           or dept.deptno = 40"
    SQL> host exp scott/tiger file=d:\tt.dmp tables=(EMP,DEPT) PARFILE=d:\query.txt
    Export: Release 10.1.0.2.0 - Production on Thu Feb 1 17:11:11 2007
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
    tion
    With the Partitioning, OLAP and Data Mining options
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    About to export specified tables via Conventional Path ...
    . . exporting table                            EMP
    EXP-00056: ORACLE error 904 encountered
    ORA-00904: "DEPT"."DEPTNO": invalid identifier
    . . exporting table                           DEPT
    EXP-00056: ORACLE error 904 encountered
    ORA-00904: "EMP"."SAL": invalid identifier
    Export terminated successfully with warnings.
    SQL>regards
    Taj

  • A challenging dynamic SQL query problem

    hi All,
    I have a very interesting problem at work:
    We have this particular table defined as follows :
    CREATE TABLE sales_data (
    sales_id NUMBER,
    sales_m01 NUMBER,
    sales_m02 NUMBER,
    sales_m03 NUMBER,
    sales_m04 NUMBER,
    sales_m05 NUMBER,
    sales_m06 NUMBER,
    sales_m07 NUMBER,
    sales_m08 NUMBER,
    sales_m09 NUMBER,
    sales_m10 NUMBER,
    sales_m11 NUMBER,
    sales_m12 NUMBER,
    sales_prior_yr NUMBER );
    The columns 'sales_m01 ..... sales_m12' represents aggregated monthly sales, in which 'sales_m01' translates to 'sales for the month of january, january being the first month, 'sales_m02' sales for the month of february, and so on.
    The problem I face is that we have a project which requires that a parameter be passed to a stored procedure which stands for the month number which is then used to build a SQL query with the following required field aggregations, which depends on the parameter passed :
    Sample 1 : parameter input: 4
    Dynamically-built SQL query should be :
    SELECT
    SUM(sales_m04) as CURRENT_SALES,
    SUM(sales_m01+sales_m02+sales_m03+sales_m04) SALES_YTD
    FROM
    sales_data
    WHERE
    sales_id = '0599768';
    Sample 2 : parameter input: 8
    Dynamically-built SQL query should be :
    SELECT
    SUM(sales_m08) as CURRENT_SALES,
    SUM(sales_m01+sales_m02+sales_m03+sales_m04+
    sales_m05+sales_m06+sales_m07+sales_m08) SALES_YTD
    FROM
    sales_data
    WHERE
    sales_id = '0599768';
    So in a sense, the contents of SUM(sales_m01 ....n) would vary depending on the parameter passed, which should be a number between 1 .. 12 which corresponds to a month, which in turn corresponds to an actual field range on the table itself. The resulting dynamic query should only aggregate those columns/fields in the table which falls within the range given by the input parameter and disregards all the remaining columns/fields.
    Any solution is greatly appreciated.
    Thanks.

    Hi another simpler approach is using decode
    try like this
    SQL> CREATE TABLE sales_data (
      2  sales_id NUMBER,
      3  sales_m01 NUMBER,
      4  sales_m02 NUMBER,
      5  sales_m03 NUMBER,
      6  sales_m04 NUMBER,
      7  sales_m05 NUMBER,
      8  sales_m06 NUMBER,
      9  sales_m07 NUMBER,
    10  sales_m08 NUMBER,
    11  sales_m09 NUMBER,
    12  sales_m10 NUMBER,
    13  sales_m11 NUMBER,
    14  sales_m12 NUMBER,
    15  sales_prior_yr NUMBER );
    Table created.
    SQL> select * from sales_data;
      SALES_ID  SALES_M01  SALES_M02  SALES_M03  SALES_M04  SALES_M05  SALES_M06  SALES_M07  SALES_M08  SALES_M09  SALES_M10  SALES_M11  SALES_M12 SALES_PRIOR_YR
             1        124        123        145        146        124        126        178        189        456        235        234        789          19878
             2        124        123        145        146        124        126        178        189        456        235        234        789          19878
             1        100        200        300        400        500        150        250        350        450        550        600        700          10000
             1        101        201        301        401        501        151        251        351        451        551        601        701          10000----now for your requirement. see below query if there is some problem then tell.
    SQL> SELECT sum(sales_m&input_data), DECODE (&input_data,
      2                 1, SUM (sales_m01),
      3                 2, SUM (sales_m01 + sales_m02),
      4                 3, SUM (sales_m01 + sales_m02 + sales_m03),
      5                 4, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04),
      6                 5, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04 + sales_m05),
      7                 6, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06),
      8                 7, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07),
      9                 8, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08),
    10                 9, SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08+sales_m09),
    11                 10,SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08+sales_m09+sales_m10),
    12                 11,SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08+sales_m09+sales_m10+sales_m11),
    13                 12,SUM (sales_m01 + sales_m02 + sales_m03 + sales_m04+sales_m05+sales_m06+sales_m07+sales_m08+sales_m09+sales_m10+sales_m11+sales_m12)
    14                ) total
    15    FROM sales_data
    16   WHERE sales_id = 1;
    Enter value for input_data: 08
    Enter value for input_data: 08
    old   1: SELECT sum(sales_m&input_data), DECODE (&input_data,
    new   1: SELECT sum(sales_m08), DECODE (08,
    SUM(SALES_M08)      TOTAL
               890       5663

  • Newbie query problem: function data missing in dropdown

    I am a student using 10g express provided with our textbook. The installation to WinXp SP3 went flawlessly and I can execute all required queries from the command line, no problem. The publisher provides SQL scripts related to the chapter material that creates the users and data for the chapter exercises. When I switch to the database home page and attempt to execute a query, I can change the aliases, insert conditions and do any thing else with the record but when I hit the dropdown arrow for function there is nothing there, no list. I have been back over the chapters dealing with installation thinking I have missed some setup parameter but I am coming up empty. Ay help would be appreciated.
    Regards,
    Dave

    Ljuba,
    This may be the issue as I ran the script as 'system' but logged in the database as 'handsonxe03'. I may have missed the required login from the text. I will look closer or I may have to modify the script for required user.
    I will let you know....Thanks!

  • Different parameter usage causes problem

    Hi there,
    I am creating a report based on a sql query. Therefore I have to parameters to filter the query i.e. "SELECT * FROM Person WHERE Birthday >= {?StartDate} AND BirthDay <= {?EndDate}". Both parameters are defined as Date.
    This works so far. Then in the Field-Explorer I define a third parameter named "GroupName" which is dynamic and should be filled from the column "Groupname" of the resultset. This parameter is used to identify a leading group which is then separated from all the others.
    My problem now is that I am asked twice to input parameters. First those two I defined in the query using the database wizzard (StartDate, EndDate). Then I am asked a second time to input all the three parameters (StartDate, EndDate, GroupName) where the two first parameters where prefilled with what I entered before. But the list of groupname is not filled so I can not select one or multiple values.
    My questions are:
    - Why am I asked twice and not once including all three parameters
    - Why is group not filled in the parameter mask
    - Is this behavior by design and if yes how can I workaround
    This concerns Crystal Report 11 and 12.
    Thanks for every hint.
    Kind regards
    Patrick
    Edited by: Patrick Jox on Sep 18, 2008 9:06 AM

    Hi Patrick,
    I think in crystal if you create a parameter in command and then if you create a parameter from report then it will prompt twice. The only way is to create all the parameters in command or in report. Why you want to create a groupname parameter in report level but not in command?
    Regards,
    Raghavendra.G

  • How is the -gm parameter effecting query runtime in detail?

    During test I found out, that the parameter -gm seems to have some dramatic impact onto runtime of queries. In Detail I found a something like factor 0.5 to 0.6 inside my tests for a smaller system:
    -iqtc 12000
    -iqmc 12000
    -iqlm 1000
    -gm 100
    -m
    -iqrlvmem 6000
    When setting -gm 1001, runtimes for a single query goes up from about 10 to about 40s.
    So how is the -gm parameter effecting IQ in detail?

    When IQ starts it allocates threads based on the -iqmt parameter.  If you don't set it, then it is computed as something like:
         -- 60 threads for each core up to 4
         -- 50 threads for each core after 4
         -- number of connections (-gm option)
         -- add 6 more just for good measure
    Let's assume that your IQ instance has 16 cores and you have -gm set to 100 .  IQ would allocate 946 threads (60*4+50*12+100+6).  We have to add 1 more thread to this, too.  Before we can allocate threads, we have 1 thread that is running to start the server.
    On my 16 core system, here are the threads allocated at startup for various values of -gm:
         -gn 10: 857 threads
         -gn 100: 947 threads (notice the +1 from the above algorithm?)
         -gn 1000: 1847 total threads
    There are two major deductions from the thread total: IO threads and SA/user threads.
    Of the threads, 40% are supposed to be held in reserve to handle IO tasks (sweeper and prefetch threads are set to 10% each and apply to main and temp cache) via the Prefetch_Threads_Percent and Sweeper_Threads_Percent options.  I am double checking this area just to make sure.  There was some work done on this in the v16 timeline.
    For user threads, I don't see you having set -gn.  Assuming that -gn is not set, then IQ will reserve 5 + -gm threads (105).  Not a problem.  IQ will grab 5 more threads than are allocated via the above algorithm, but that's OK.
    Things go a bit wrong on you when your -gn is set to the recommended value of 1.5 * -gm.  What happens is that we are computing the number of threads needed based on -gm (100 or 1000).  However, we are actually allocating threads based on -gm (105, 1005, 150, or 1500 depending on the default or best practices used).
    Imagine that -gn is set to 1.5x -gm.  Of the 1847 threads allocated, 1500 are held in reserve for user connections.  Read that as threads for the catalog only.  There would be just 347 threads left over.  But don't forget the IO threads either.  Now all of a sudden there are no threads left for any work in IQ.  We are thread starved.  When IQ gets into a thread starvation mode, we have little or no threads left over to do work in IQ.  At that time, we use the one guaranteed thread that each user connection has to do all work.  This holds true for worker thread starvation as well as IO thread starvation.
    One of two things is happening in your case.  You are either thread starved and forced to run everything single threaded or your system has so many threads that it must spend too much time maintaining threads that are not being used.
    If you can run sp_iqsysmon in '-debug' mode you can look at the "Thread Manager" section to check out the thread usage and allocations.
    Mark

Maybe you are looking for

  • Why can I not preview and render all sequence clips on a CS6 project when using CC?

    I am having issues with rendering all of the sections in my sequence. Some clips will render just fine while others simply display as a blank screen (see screenshot 1). Also, parts of a clip will render while others will not (see screenshot 2). Scree

  • External Drive does not mount on desktop

    Hi, I did a Leopard upgrade and most everything went smoothly. But when I boot, Leopard pops up a window telling me that a disk I inserted is unreadable (it took me a time or two to realize it WAS referring to my USB 2.0 external hard drive). It give

  • Will books I buy in the iBookstore work with a Kobo?

    I was thinking of getting a Kobo e-reader for use at the beach (I fear water/sand damage with my iPad). Kobo's support ePub, will book I bought in the iBookstore work with a Kobo?

  • Snapshot too Old Error - Help needed

    One of the batch job is failing due to oracle error "snapshot too old." Please let me know what are the possible reason's this problem occurs and suggest me the possible solutions to rectify this problem. Thanks in advance

  • Double Clicking Photo No Longer Opens in Full Screen

    Hi all: We have our preferences in iPhoto set so that double clicking a particular thumbnail opens the photo in Full Screen mode for editing. Just this morning, for no apparent reason, we noticed that the photos when double clicked now open with gray