SQL Query with variable range

Hi
  I want to give range to a user to enter in a variable through sql query . If there are 200 records , if user wants to display from 5-45 , 75-110 , 130-145. how it can be done through SQl Query
Thanks
Edited by: Matt on Aug 31, 2010 6:23 PM - modified title - please use a meaningful title in future

Dear Saini,
This query will allow you to choose the values only when you know them.
SELECT T0.[DocEntry], T0.[ItemCode] FROM INV1 T0 WHERE T0.[LineNum] >[%0]   and T0.[LineNum] <[%1]
If you run it in the query Generator in SAP Business One a little window will pop up and will ask you to choose the 2 variables.
You can choose different variables every time you run it. At least you won't have to save many queries with different values.
If you want 2 different groups, e.g. from 10 to 20 and from 30 to 40, then you can add another part in the where clause:
SELECT T0.[LineNum], T0.[ItemCode], T0.[DocEntry] FROM INV1 T0 WHERE T0.[LineNum]  >= [%0] and  T0.[LineNum]  <= [%2] and T0.[LineNum]  >= [%4] or  T0.[LineNum]  <= [%6]
Please, let me know if this query helps.
Regards,
Marcella Rivi
SAP Business One Forums Team

Similar Messages

  • SQL Query with Date Range

    I have a query that will retrieve order between selected dates. It works great but returns no record if the 2 dates are the same.
    Example:
    Orders between 9-1-2010 and 9-30-2010 retunes 35 records.
    But if I select between -9-25-2010 and 9-25-2010, so I can see all order from this 1 day, it returns 1 records, and I know there are records for that day!
    Here's my query:
    <%
    Dim rsOrders__MMColParam
    rsOrders__MMColParam = "1"
    If (Request.QueryString("datefrom") <> "") Then
      rsOrders__MMColParam = Request.QueryString("datefrom")
    End If
    %>
    <%
    Dim rsOrders__MMColParam2
    rsOrders__MMColParam2 = "1"
    If (Request.QueryString("dateto") <> "") Then
      rsOrders__MMColParam2 = Request.QueryString("dateto")
    End If
    %>
    <%
    Dim rsOrders
    Dim rsOrders_cmd
    Dim rsOrders_numRows
    Set rsOrders_cmd = Server.CreateObject ("ADODB.Command")
    rsOrders_cmd.ActiveConnection = MM_ezcaldatasource_STRING
    rsOrders_cmd.CommandText = "SELECT * FROM dbo.orders WHERE (OrderDate between ? and ?) AND Finalized  = 1"
    rsOrders_cmd.Prepared = true
    rsOrders_cmd.Parameters.Append rsOrders_cmd.CreateParameter("param1", 135, 1, -1, rsOrders__MMColParam) ' adDBTimeStamp
    rsOrders_cmd.Parameters.Append rsOrders_cmd.CreateParameter("param2", 135, 1, -1, rsOrders__MMColParam2) ' adDBTimeStamp
    Set rsOrders = rsOrders_cmd.Execute
    rsOrders_numRows = 0
    %>

    2 possible
    1) Change the column's data type from a datetime to a date if supported by your DBMS
    2) Use date math to always add 1 day to the end date. So instead of the end date of 9-25-2010 (00:00) it will be 9-26-2010 (00:00)

  • SQL query with Bind variable with slower execution plan

    I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
    1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
    3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
    4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
    (Cost=2 Card=135 Bytes=6480)
    Statistics
    0 recursive calls
    18 db block gets
    15558 consistent gets
    47 physical reads
    9896 redo size
    423 bytes sent via SQL*Net to client
    1095 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
    2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
    3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
    4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
    0 recursive calls
    12 db block gets
    3003199 consistent gets
    54 physical reads
    9448 redo size
    423 bytes sent via SQL*Net to client
    1258 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
    Regards
    Ivan

    Many thanks for your reply.
    I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
    for table I use:-
    begin
    dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
    end;
    for index I use:-
    begin
    dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
    end;
    Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
    regards
    Ivan

  • SQL query with JSP and WML-parameters

    Hey,
    Could you help me?
    I'm trying to do the following. WML deck card 1 send parameter to same WML deck's card help. I try to read the parameter with JSP in card help by putting the parameter to SQL query, but it doesn't work. I can read the parameter with WML in card help. I can also print the value of the parameter with JSP if I generate WML with JSP.
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi' value='$(valittukurssi)'/>");
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    /'parameter read with JSP by generating WML with JSP*/
    out.println("<p>$valittukurssi</p>");
    /* SQL query with JSP */
    ResultSet uudettulokset = uusilause.executeQuery("select * from kurssi where lyhenne='$valittukurssi'");
    Thanks,
    Rampe

    You're problem is easy to fix. You're confusing WML variables with JSP variables. See below:
    >
    /*parameter sending from card 1 to card help*/
    out.println("<go href='#helpcard'>");
    out.println("<setvar name='valittukurssi'
    value='$(valittukurssi)'/>");
    Above you set a var that will work on the phone, not in JSP.
    /*parameter read with WML in card help */
    <p>Valitse kurssi.
    $valittukurssi</p>
    Yes the above does display the parameter, because it is a client side WML var, but you cannot use this variable in the JSP code (that's why your SWL fails).
    /'parameter read with JSP by generating WML with
    JSP*/
    out.println("<p>$valittukurssi</p>");Here's you're problem, the above line is EXACTLY the same as the one before it. When the container parses through this JSP code it translates the above line to:
    <p>$valittukurssi</p> on the WML page and the CLIENT uses it's local variable to display it.
    What you need and want is to have a variable that can be used in JSP code and output to your WML page. Here's how it's done:
    out.println("<go href='#helpcard'>");
    String some_name = "valittukurssi";
    out.println("<setvar name='"+some_name+"'
    value='$("+some_name+")'/>");
    //note that you may have to escape the ( and ) with a \
    //so we displayed the variable above into the WML page, now we can use it in the SQL query:
    /* SQL query with JSP */
    ResultSet uudettulokset =
    uusilause.executeQuery("select * from kurssi where
    lyhenne='"+some_name+"'");//the end of the command is: " ' " ) ;
    Frank Krul
    Got Node?

  • Cell Offload will Happen for pl/sql Block with variables

    Hello Experts,
    i am working on procedures on exadata now. i was confused with cell offload in exadata. somehow offload is not happening when i ran the sql statement in in pl/sql block with variables.
    here are my findings.
    when i ran insert into from select with values at toad, my query response time is very good. the total process is completed in less than a minute.
    i checked offload is happening.
    same sql statement is placed in plsql block with variable, procedure is taking lot of time and it is not completing. this case offload is not happening.
    is it true, if i use variables in pl/sql block will not use cell offload and smart scan?
    if yes, what is the work around.
    Thanks
    #! Pavan

    Hello Marc,
    Thanks for quick response.
    when i ran the query with literals in toad session i am getting response.
    when i run it with pl/sql block , block is not completing at all.
    here is the plsql block:
    My Apologies for sending big code,with out proper format.
    DECLARE
    P_BUSINESS_DATE DATE;
    P_BATCH_ID NUMBER;
    UTC_OFFSET NUMBER;
    BEGIN
    P_BUSINESS_DATE := to_date('02/01/2012', 'MM/DD/YYYY');
    P_BATCH_ID := 1;
    UTC_OFFSET := 0;
    INSERT /*+ APPEND */ INTO UPL_CLIENT_tbl
    ( reportdate,
    LastName,
    FirstName,
    MiddleInitial,
    AccountNumber,
    Address,
    City,
    State,
    Zip,
    HomePhone,
    WorkPhone,
    BirthDate,
    Age,
    Sex,
    NumberOfChildren,
    Occupation,
    LeadSource,
    Consultant,
    ProgramDirector,
    CallTaker,
    LeadDate,
    FirstVisitDate,
    LastVisitDate,
    BillType,
    ClientType,
    PreviousClientType,
    AppointmentDate,
    DoctorLetterRequired,
    OneYearPermStabilizationDate,
    UnlimitedPermStabilizationDate,
    MaritalStatus,
    ReferrerName,
    ReferrerCentreID,
    CentreID,
    PaymentDateOne,
    PaymentAmountOne,
    PaymentDateTwo,
    PaymentAmountTwo,
    PaymentDateThree,
    PaymentAmountThree,
    PaymentDateFour,
    PaymentAmountFour,
    LibraryPurchased,
    BalanceDue,
    FoodNSFBalance,
    ProductNSFBalance,
    ProgramNSFBalance,
    StartWeight,
    CurrentWeight,
    GoalWeight,
    Height,
    DateGoalWeightAchieved,
    DateSuccessPlusPurchased,
    ReturnToActiveDate,
    VersionNumber,
    HalfWayDate,
    LastLSCDate,
    LastUpdatedDate,
    VitaminWaiverSigned,
    LastSupplementPurchaseDate,
    LastSupplementCodePurchased,
    LastTotalSupplementSupplyCycle,
    LastAddtlSupplPurchaseDate,
    LastAddtlSupplCodePurchased,
    LastAddtlSupplSupplyCycle,
    DiabetesClient,
    DietControlled,
    TakingOralMed,
    TakingInsulin,
    EmailId,
    CTADate,
    RWLDate,
    Address2)
    (SELECT /*+ full(S_CONTACT) full(REFERRER) full(Consultant) full(ProgramDirector) full(CallTaker) full(S_CONTACT_X) full(a) full(a2) full (a3) */ distinct p_business_date reportdate,
    SUBSTR(S_CONTACT.LAST_NAME,1,25) AS LastName,
    SUBSTR(S_CONTACT.FST_NAME,1,25) AS FirstName,
    SUBSTR(S_CONTACT.MID_NAME,1,1) AS MiddleInitial,
    S_CONTACT.X_JC_ACNT_NUM + 900000000 AS AccountNumber,
    SUBSTR(S_ADDR_PER.ADDR,1,40) AS ADDRESS,
    SUBSTR(S_ADDR_PER.CITY,1,20) AS City,
    S_ADDR_PER.STATE AS State,
    SUBSTR(S_ADDR_PER.ZIPCODE,1,15) AS Zip,
    SUBSTR(REPLACE(S_CONTACT.HOME_PH_NUM,'-',''),1,10) AS HomePhone,
    SUBSTR(REPLACE(S_CONTACT.WORK_PH_NUM,'-',''),1,10) AS WorkPhone,
    S_CONTACT.BIRTH_DT AS BirthDate,
    CASE WHEN FLOOR((p_business_date - S_CONTACT.BIRTH_DT)/360) < 0 THEN NULL ELSE FLOOR((p_business_date - S_CONTACT.BIRTH_DT)/360) END AS AGE,
    S_CONTACT.SEX_MF AS SEX,
    NULL AS NumberOfChildren,
    S_CONTACT_X.ATTRIB_34 AS OCCUPATION,
    CASE WHEN SUBSTR(S_CONTACT_X.ATTRIB_37,1,4)='Othe' THEN 'Othr'
    WHEN SUBSTR(S_CONTACT_X.ATTRIB_37,1,4)='Inte' THEN 'Intr'
    WHEN SUBSTR(S_CONTACT_X.ATTRIB_37,1,4)='Prin' THEN 'News'
    WHEN SUBSTR(S_CONTACT_X.ATTRIB_37,1,4)='Gues' THEN 'Gst'
    ELSE SUBSTR(S_CONTACT_X.ATTRIB_37,1,4) END AS LeadSource,
    SUBSTR(Consultant.EMP_NUM,1,10) AS CONSULTANT,
    ProgramDirector.EMP_NUM AS ProgramDirector,
    CallTaker.EMP_NUM CallTaker,
    S_CONTACT.X_LEAD_DT AS LeadDate,
    LEAST(nvl(S_CONTACT.X_LAST_CONSULTATION_DATE,O.FirstPurchaseDate ), nvl(O.FirstPurchaseDate,S_CONTACT.X_LAST_CONSULTATION_DATE+1) ) AS FirstVisitDate, --X_LAST_CONSULTATION_DATE stores the performed date or the legacy client firstvisitdate
    GREATEST(nvl(S_CONTACT_XM.X_CONSULTATION_DT ,S_CONTACT_X.ATTRIB_29), nvl(S_CONTACT_X.ATTRIB_29, S_CONTACT_XM.X_CONSULTATION_DT-1) ) AS LastVisitDate,
    CASE WHEN S_CONTACT.X_INSTALLMENT_BALANCE > 0 THEN 'B' ELSE NULL END AS BillType,
    ct.current_client_type ClientType,
    SUBSTR(ct.saved_client_type,1,1) PreviousClientType,
    S_CONTACT.LAST_CREDIT_DT AS AppointmentDate,
    CASE WHEN a.X_DR_LETTER_STATUS IS NOT NULL THEN 'Y' ELSE 'N' END AS DoctorLetterRequired,
    NULL AS OneYearPermStabilizationDate,
    DECODE(S_PROD_INT.X_PROGRAM_CLASSIFICATION,'Premium',a.START_DT ,NULL) AS UnlimitedPermStabilizationDate,
    SUBSTR(S_CONTACT.MARITAL_STAT_CD,1,1) AS MaritalStatus,
    SUBSTR(REFERRER.FST_NAME ||' '|| REFERRER.LAST_NAME,1,34) AS ReferrerName,
    ORGEXT_REF.LOC AS ReferrerCentreID,
    S_ORG_EXT.LOC AS CentreID,
    NULL AS PaymentDateOne,
    NULL AS PaymentAmountOne,
    NULL AS PaymentDateTwo,
    NULL AS PaymentAmountTwo,
    NULL AS PaymentDateThree,
    NULL AS PaymentAmountThree,
    NULL AS PaymentDateFour,
    NULL AS PaymentAmountFour,
    NULL AS LibraryPurchased,
    nvl(S_CONTACT.X_INSTALLMENT_BALANCE,0) + nvl(S_CONTACT.X_PREPAID_BALANCE,0) AS BalanceDue, -- Changed operation from (-) prepaid to (+) prepaid since the sign was flipped in OLTP.
    NULL AS FoodNSFBalance,
    NULL AS ProductNSFBalance,
    NULL AS ProgramNSFBalance,
    a2.X_START_WEIGHT AS StartWeight,
    a2.X_CURRENT_WEIGHT AS CurrentWeight,
    a2.X_GOAL_WEIGHT AS GoalWeight,
    a3.X_HEIGHT AS Height,
    a2.X_FAXSENT_DATETIME DateGoalWeightAchieved,
    DECODE(S_PROD_INT.X_PROGRAM_CLASSIFICATION,'Premium',a.START_DT,NULL) AS DateSuccessPlusPurchased,
    CASE WHEN A2.ARCHIVE_FLG = 'N' THEN a2.START_DT ELSE NULL END AS ReturnToActiveDate,
    600 VersionNumber,
    a2.X_FAXRECV_DATETIME AS HalfWayDate,
    NULL AS LastLSCDate,
    TRUNC(S_CONTACT.LAST_UPD-UTC_OFFSET/24) AS LastUpdatedDate,
    NULL AS VitaminWaiverSigned,
    LastSupplementPurchaseDate,
    LastSupplementCodePurchased,
    LastTotalSupplementSupplyCycle,
    LastAddtlSupplPurchaseDate,
    LastAddtlSupplCodePurchased,
    LastAddtlSupplSupplyCycle,
    CASE WHEN (a.X_DIABETES_NO_MEDS_FLG='Y' OR a.X_DIABETES_ORAL_MEDS_FLG = 'Y' OR a.X_DIABETES_ON_INSULIN_FLG = 'Y') THEN 'Y' ELSE 'N' END AS DiabetesClient,
    DECODE(a.X_DIABETES_NO_MEDS_FLG,'Y','Y','N') AS DietControlled,
    a.X_DIABETES_ORAL_MEDS_FLG AS TakingOralMed,
    a.X_DIABETES_ON_INSULIN_FLG AS TakingInsulin,
    S_CONTACT.EMAIL_ADDR AS EmailId,
    NULL CTADATE,
    NULL RWLDATE,
    SUBSTR(S_ADDR_PER.ADDR_LINE_2,1,40) AS Address2
    FROM S_CONTACT,
    S_CONTACT REFERRER,
    S_CONTACT Consultant,
    S_CONTACT ProgramDirector,
    S_CONTACT CallTaker,
    S_CONTACT_X,
    (SELECT /*+ parallel full(S_CONTACT_XM) */ PAR_ROW_ID, attrib_05, MAX(X_CONSULTATION_DT) AS X_CONSULTATION_DT FROM S_CONTACT_XM
    WHERE (S_CONTACT_XM.last_upd_by < '1-14WD'
    or S_CONTACT_XM.last_upd_by > '1-14WD')
    AND S_CONTACT_XM.ATTRIB_05 IN (SELECT row_id FROM S_ORG_EXT WHERE S_ORG_EXT.ACCNT_TYPE_CD IN ('Corporate Centre','Franchise Centre')) LOC IN (SELECT centreid FROM UPL_LIVE_CENTRES WHERE LIVE = 'Y' AND BATCHID = p_batch_id)) where S_ORG_EXT.ACCNT_TYPE_CD IN ('Corporate Centre','Franchise Centre')) --
    GROUP BY PAR_ROW_ID, attrib_05) S_CONTACT_XM,
    (SELECT CONTACT_ID, ACCNT_ID,
    MAX(LastSupplementPurchaseDate) AS LastSupplementPurchaseDate,
    MAX(LastSupplementCodePurchased) AS LastSupplementCodePurchased,
    MAX(LastTotalSupplementSupplyCycle) AS LastTotalSupplementSupplyCycle,
    MAX(LastAddtlSupplPurchaseDate) AS LastAddtlSupplPurchaseDate,
    MAX(LastAddtlSupplCodePurchased) AS LastAddtlSupplCodePurchased,
    MAX(LastAddtlSupplSupplyCycle) AS LastAddtlSupplSupplyCycle,
    MIN(FirstPurchaseDate) AS FirstPurchaseDate,
    MAX(LastPurchaseDate) AS LastPurchaseDate
              FROM (
              SELECT /*+ parallel full(S_ORDER) full(S_ORDER_XM) */ S_ORDER.CONTACT_ID AS CONTACT_ID,S_ORDER.ACCNT_ID,
    NULL AS LastSupplementPurchaseDate,
    NULL AS LastSupplementCodePurchased,
    NULL AS LastTotalSupplementSupplyCycle,
    NULL AS LastAddtlSupplPurchaseDate,
    NULL AS LastAddtlSupplCodePurchased,
    NULL AS LastAddtlSupplSupplyCycle,
    (S_ORDER_XM.X_BUSINESS_DATE) FirstPurchaseDate,
    (S_ORDER_XM.X_BUSINESS_DATE) LastPurchaseDate
              FROM S_ORDER,S_ORDER_XM
              WHERE S_ORDER.ROW_ID = S_ORDER_XM.PAR_ROW_ID
              AND S_ORDER.STATUS_CD IN ('Complete', 'Submitted', 'Ready')
              AND TRUNC(S_ORDER_XM.X_BUSINESS_DATE - UTC_OFFSET/24) <= (p_business_date)
              --GROUP BY S_ORDER.CONTACT_ID
              UNION ALL
              SELECT /*+ parallel full(S_ORDER) full (S_ORDER_ITEM) */ S_ORDER.CONTACT_ID AS CONTACT_ID,S_ORDER.ACCNT_ID,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '931' THEN S_ORDER.CREATED ELSE NULL END) AS LastSupplementPurchaseDate,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '931' THEN 931 ELSE NULL END) AS LastSupplementCodePurchased,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '931' THEN 7 ELSE NULL END) AS LastTotalSupplementSupplyCycle,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '920' THEN S_ORDER.CREATED ELSE NULL END) AS LastAddtlSupplPurchaseDate,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '920' THEN 920 ELSE NULL END) AS LastAddtlSupplCodePurchased,
              (CASE WHEN SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) = '920' THEN 28 ELSE NULL END) AS LastAddtlSupplSupplyCycle,
              NULL FirstPurchaseDate,
              NULL LastPurchaseDate
              FROM S_ORDER,S_ORDER_ITEM, S_PROD_INT
              WHERE S_ORDER_ITEM.PROD_ID = S_PROD_INT.ROW_ID
                   AND S_ORDER.ROW_ID = S_ORDER_ITEM.ORDER_ID
                   AND S_ORDER_ITEM.qty_req <> 0
                   AND s_order.created_by <> '1-14WD'
                   AND S_ORDER_ITEM.PAR_ORDER_ITEM_ID is null
                   AND (S_ORDER_ITEM.PAR_ORDER_ITEM_ID is null
                   OR EXISTS (select 1 from S_ORDER_ITEM i2,s_prod_int p
    where i2.row_id = S_ORDER_ITEM.PAR_ORDER_ITEM_ID
    and SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) IN ('931','920')
    and i2.prod_id = p.row_id
                   AND S_ORDER.status_cd in ('Complete', 'Submitted', 'Ready')
                   and SUBSTR(SUBSTR(S_PROD_INT.PART_NUM,1,INSTR(S_PROD_INT.PART_NUM,'-',1,1)-1),2,4) IN ('931','920')
    GROUP BY CONTACT_ID,ACCNT_ID) O,
    S_CONTACT_TNTX,
    S_ORG_EXT,
    S_ORG_EXT ORGEXT_REF,
    S_ADDR_PER,
    S_ASSET a,
    S_PROD_INT,
    S_ASSET a2,
    S_ASSET a3,
    UPL_CLIENT_TYPES ct,
    (select /*+ parallel */ o.contact_id, o.accnt_id
    from S_ORDER o, S_ORDER_XM oxm
    where o.row_id = oxm.par_row_id
    and trunc(oxm.X_BUSINESS_DATE - (UTC_OFFSET/24)) = trunc(p_business_date)
    group by o.contact_id, o.accnt_id) oxm2
    WHERE S_CONTACT.ROW_ID = S_CONTACT_X.PAR_ROW_ID
    AND S_CONTACT_X.ROW_ID = S_CONTACT_XM.PAR_ROW_ID (+)
    AND (S_ORG_EXT.ROW_ID = S_CONTACT.PR_DEPT_OU_ID
    OR S_ORG_EXT.ROW_ID = oxm2.accnt_id
    OR S_ORG_EXT.ROW_ID = S_CONTACT_XM.attrib_05)
    AND ORGEXT_REF.ROW_ID(+) = REFERRER.PR_DEPT_OU_ID
    AND S_CONTACT.CON_ASST_PER_ID = Consultant.ROW_ID
    AND S_ORG_EXT.X_DIRECTOR_ID = ProgramDirector.ROW_ID (+)
    AND S_CONTACT.CREATED_BY = CallTaker.ROW_ID
    AND S_CONTACT.ROW_ID = a.PR_CON_ID (+)
    AND S_CONTACT.PR_PER_ADDR_ID = S_ADDR_PER.ROW_ID (+)
    AND S_CONTACT_TNTX.PAR_ROW_ID (+) = S_CONTACT.ROW_ID
    AND REFERRER.ROW_ID(+) = S_CONTACT_TNTX.REFERRED_BY_ID
    AND a.PROD_ID = S_PROD_INT.ROW_ID (+)
    AND O.CONTACT_ID (+) = S_CONTACT.ROW_ID
    AND a.STATUS_CD (+) = 'Active'
    AND a.TYPE_CD (+) ='Program'
    AND S_CONTACT.ROW_ID = a2.PR_CON_ID (+)
    AND a2.STATUS_CD (+) = 'Active'
    AND a2.TYPE_CD (+) = 'Lifecycle'
    AND a3.PR_CON_ID(+) = S_CONTACT.ROW_ID
    AND a3.STATUS_CD (+) = 'Active'
    AND a3.TYPE_CD (+) = 'HealthSheet'
    AND S_CONTACT.X_JC_ACNT_NUM = ct.CLIENT_NUMBER (+)
    --AND S_ORG_EXT.LOC NOT LIKE 'F%'
    AND S_ORG_EXT.ACCNT_TYPE_CD NOT IN 'Division'
    --AND S_ORG_EXT.Loc in (select to_char(centreid) from UPL_LIVE_CENTRES where LIVE = 'Y')
    AND (trunc(S_CONTACT.LAST_UPD - (UTC_OFFSET/24)) = trunc(p_business_date) or trunc(S_CONTACT_X.LAST_UPD - (UTC_OFFSET/24)) = trunc(p_business_date) OR (S_CONTACT_XM.X_CONSULTATION_DT = p_business_date) OR oxm2.CONTACT_ID IS NOT NULL)
    AND S_CONTACT.last_upd_by not in ('1-14WD')
    AND oxm2.CONTACT_ID (+) = o.CONTACT_ID
    AND S_ORG_EXT.LOC <> 'CW_846'
    AND (a.pr_accnt_id in (select row_id from S_ORG_EXT where S_ORG_EXT.LOC IN (Select CentreID from UPL_Live_Centres where BATCHID = p_batch_id)) or a.pr_accnt_id is null)
    AND (a2.pr_accnt_id in (select row_id from S_ORG_EXT where S_ORG_EXT.LOC IN (Select CentreID from UPL_Live_Centres where BATCHID = p_batch_id)) or a2.pr_accnt_id is null)
    AND (a3.pr_accnt_id in (select row_id from S_ORG_EXT where S_ORG_EXT.LOC IN (Select CentreID from UPL_Live_Centres where BATCHID = p_batch_id)) or a3.pr_accnt_id is null));
    rollback;
    END;
    --------------------------------------------------------------------------------------------------

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • How could I replace hard coded value in my sql query with constant value?

    Hi all,
    Could anyone help me how to replace hardcoded value in my sql query with constant value that might be pre defined .
    PROCEDURE class_by_day_get_bin_data
         in_report_parameter_id   IN   NUMBER,
         in_site_id               IN   NUMBER,
         in_start_date_time       IN   TIMESTAMP,
         in_end_date_time         IN   TIMESTAMP,
         in_report_level_min      IN   NUMBER,
         in_report_level_max      IN   NUMBER
    IS
      bin_period_length   NUMBER(6,0); 
    BEGIN
      SELECT MAX(period_length)
         INTO bin_period_length
        FROM bin_data
         JOIN site_to_data_source_lane_v
           ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
         JOIN bin_types
           ON bin_types.bin_type = bin_data.bin_type 
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
       SELECT site_to_data_source_lane_v.site_id,
             site_to_data_source_lane_v.site_lane_id,
             site_to_data_source_lane_v.site_direction_id,
             site_to_data_source_lane_v.site_direction_name,
             bin_data_set.start_date_time,
             bin_data_set.end_date_time,
             bin_data_value.bin_id,
             bin_data_value.bin_value
        FROM bin_data
        JOIN bin_data_set
          ON bin_data.bin_serial = bin_data_set.bin_serial
        JOIN bin_data_value
          ON bin_data_set.bin_data_set_serial = bin_data_value.bin_data_set_serial
        JOIN site_to_data_source_lane_v
             ON bin_data.data_source_id = site_to_data_source_lane_v.data_source_id
            AND bin_data_set.lane = site_to_data_source_lane_v.data_source_lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) lane_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'LANE'
                  AND report_parameters.report_parameter_name  = 'LANE'
             ) report_lanes
          ON site_to_data_source_lane_v.site_lane_id = report_lanes.lane_id
        JOIN (
               SELECT CAST(report_parameter_value AS NUMBER) class_id
                 FROM report_parameters
                WHERE report_parameters.report_parameter_id    = in_report_parameter_id
                  AND report_parameters.report_parameter_group = 'CLASS'
                  AND report_parameters.report_parameter_name  = 'CLASS'
             ) report_classes
          ON bin_data_value.bin_id = report_classes.class_id
        JOIN edr_rpt_tmp_inclusion_table
          ON TRUNC(bin_data_set.start_date_time) = TRUNC(edr_rpt_tmp_inclusion_table.date_time)
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time     >= in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time     <  in_end_date_time   + numtodsinterval(1, 'DAY')
         AND bin_data_set.start_date_time >= in_start_date_time
         AND bin_data_set.start_date_time <  in_end_date_time
         AND bin_data.bin_type            =  2
         AND bin_data.period_length       =  bin_period_length;
    END class_by_day_get_bin_data;In the above code I'm using the hard coded value 2 for bin type
    bin_data.bin_type            =  2But I dont want any hard coded number or string in the query.
    How could I replace it?
    I defined conatant value like below inside my package body where the actual procedure comes.But I'm not sure whether I have to declare it inside package body or inside the procedure.
    bin_type     CONSTANT NUMBER := 2;But it does't look for this value. So I'm not able to get desired value for the report .
    Thanks.
    Edited by: user10641405 on May 29, 2009 1:38 PM

    Declare the constant inside the procedure.
    PROCEDURE class_by_day_get_bin_data(in_report_parameter_id IN NUMBER,
                                        in_site_id             IN NUMBER,
                                        in_start_date_time     IN TIMESTAMP,
                                        in_end_date_time       IN TIMESTAMP,
                                        in_report_level_min    IN NUMBER,
                                        in_report_level_max    IN NUMBER) IS
      bin_period_length NUMBER(6, 0);
      v_bin_type     CONSTANT NUMBER := 2;
    BEGIN
      SELECT MAX(period_length)
        INTO bin_period_length
        FROM bin_data
        JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                           site_to_data_source_lane_v.data_source_id
        JOIN bin_types ON bin_types.bin_type = bin_data.bin_type
       WHERE site_to_data_source_lane_v.site_id = in_site_id
         AND bin_data.start_date_time >=
             in_start_date_time - numtodsinterval(1, 'DAY')
         AND bin_data.start_date_time <
             in_end_date_time + numtodsinterval(1, 'DAY')
         AND bin_data.bin_type = v_bin_type
         AND bin_data.period_length <= 60;
      --Clear the edr_class_by_day_bin_data temporary table and populate it with the data for the requested
      --report.
      DELETE FROM edr_class_by_day_bin_data;
      INSERT INTO edr_class_by_day_bin_data
        (site_id,
         site_lane_id,
         site_direction_id,
         site_direction_name,
         bin_start_date_time,
         bin_end_date_time,
         bin_id,
         bin_value)
        SELECT site_to_data_source_lane_v.site_id,
               site_to_data_source_lane_v.site_lane_id,
               site_to_data_source_lane_v.site_direction_id,
               site_to_data_source_lane_v.site_direction_name,
               bin_data_set.start_date_time,
               bin_data_set.end_date_time,
               bin_data_value.bin_id,
               bin_data_value.bin_value
          FROM bin_data
          JOIN bin_data_set ON bin_data.bin_serial = bin_data_set.bin_serial
          JOIN bin_data_value ON bin_data_set.bin_data_set_serial =
                                 bin_data_value.bin_data_set_serial
          JOIN site_to_data_source_lane_v ON bin_data.data_source_id =
                                             site_to_data_source_lane_v.data_source_id
                                         AND bin_data_set.lane =
                                             site_to_data_source_lane_v.data_source_lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) lane_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'LANE'
                   AND report_parameters.report_parameter_name = 'LANE') report_lanes ON site_to_data_source_lane_v.site_lane_id =
                                                                                         report_lanes.lane_id
          JOIN (SELECT CAST(report_parameter_value AS NUMBER) class_id
                  FROM report_parameters
                 WHERE report_parameters.report_parameter_id =
                       in_report_parameter_id
                   AND report_parameters.report_parameter_group = 'CLASS'
                   AND report_parameters.report_parameter_name = 'CLASS') report_classes ON bin_data_value.bin_id =
                                                                                            report_classes.class_id
          JOIN edr_rpt_tmp_inclusion_table ON TRUNC(bin_data_set.start_date_time) =
                                              TRUNC(edr_rpt_tmp_inclusion_table.date_time)
         WHERE site_to_data_source_lane_v.site_id = in_site_id
           AND bin_data.start_date_time >=
               in_start_date_time - numtodsinterval(1, 'DAY')
           AND bin_data.start_date_time <
               in_end_date_time + numtodsinterval(1, 'DAY')
           AND bin_data_set.start_date_time >= in_start_date_time
           AND bin_data_set.start_date_time < in_end_date_time
           AND bin_data.bin_type = v_bin_type
           AND bin_data.period_length = bin_period_length;
    END class_by_day_get_bin_data;

  • How to write sql query with many parameter in ireport

    hai,
    i'm a new user in ireport.how to write sql query with many parameters in ireport's report query?i already know to create a parameter like(select * from payment where entity=$P{entity}.
    but i don't know to create query if more than 1 parameter.i also have parameter such as
    $P{entity},$P{id},$P{ic}.please help me for this.
    thanks

    You are in the wrong place. The ireport support forum may be found here
    http://www.jasperforge.org/index.php?option=com_joomlaboard&Itemid=215&func=showcat&catid=9

  • Need help with SQL Query with Inline View + Group by

    Hello Gurus,
    I would really appreciate your time and effort regarding this query. I have the following data set.
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
    1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
    Please Ignore '----', added it for clarity
    I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
    The query should return the following data set
    Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
    1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
    7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
    4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
    The following is my query. I am kind of lost.
    select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
    from (
    select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
    from INVOICE
    group by sequence_id,check_date, check_number, invoice_number, vendor_number
    ) A, INVOICE B
    where A.sequence_id = B.sequence_id
    Thanks,
    Nick

    It looks like it is a duplicate thread - correct me if i'm wrong in this case ->
    Need help with SQL Query with Inline View + Group by
    Regards.
    Satyaki De.

  • Extract Sql Query with Actual Parameters from Report

    Hi
    I am able to extract query from Crystal Report using the following code :
    ReportDocument.ReportClientDocument.RowSetController.GetSqlStatement(new GroupPath, out tmp);
    But the sql query retrieve comes in the following format :
    select name , trans_code, account_code from command_query.accounts
    where account_code = {?Command_query_Prompt0}  and effective_date < '{?Command_query_prompt1 }'
    The parameters which I m using in the reports are :
    Account_Code and Effective_Date .
    Why does my extracted sql translates it into {?Command_query_Prompt0} and '{?Command_query_prompt1 }' .
    Is there any way to map this to the actual parameter values ?
    OR
    Can we extract the query after assigning the values ?
    Any help is appreciated ... 
    Thanks
    Sanchet

    hi,
    You can create nested sql query with conditional parameters,
    For example
    Select Code From OITT Where Code IN (Select ItemCode From OITM
    Where ItemName LIKE '[%0]' + '%%')
    Edited by: Jeyakanthan A on Jun 9, 2009 12:31 PM

  • Hosting company does not support SQL query with OUTFILE clause

    From my mysql database, I want to allow the user to run a query and produce a csv / text file of our membership database.   Unfortunately,  I just found out my hosting company does not support the SQL query with OUTFILE clause for MySQL database.
    Are there any other options available to produce a file besides me running the query in phpadmin and making the file available to users.
    Thanks.  George

    Maybe this external Export Mysql data to CSV - PHP tutorial will be of help
    Cheers,
    Günter

  • Issue with SQL Query with Presentation Variable as Data Source in BI Publisher

    Hello All
    I have an issue with creating BIP report based on OBIEE reports which is done using direct SQL. There is this one report in OBIEE dashboard, which is written using direct SQL. To create the pixel perfect version of this report, I am creating BIP data model using SQL Query as data source. The physical query that is used to create OBIEE report has several presentation variables in its where clause.
    select TILE4,max(APPTS), 'Top Count' from
    SELECT c5 as division,nvl(DECODE (C2,0,0,(c1/c2)*100),0) AS APPTS,NTILE (4) OVER ( ORDER BY nvl(DECODE (C2,0,0,(c1/c2)*100),0))  AS TILE4,
    c4 as dept,c6 as month FROM 
    select sum(case  when T6736.TYPE = 'ATM' then T7608.COUNT end ) as c1,
         sum(case  when T6736.TYPE in ('Call Center', 'LSM') then T7608.CONFIRMED_COUNT end ) as c2,
         T802.NAME_LEVEL_6 as c3,
         T802.NAME_LEVEL_1 as c4,
         T6172.CALENDARMONTHNAMEANDYEAR as c5,
         T6172.CALENDARMONTHNUMBERINYEAR as c6,
         T802.DEPT_CODE as c7
    from
         DW_date_DIM T6736 /* z_dim_date */ ,
         DW_MONTH_DIM T6172 /* z_dim_month */ ,
         DW_GEOS_DIM T802 /* z_dim_dept_geo_hierarchy */ ,
         DW_Count_MONTH_AGG T7608 /* z_fact_Count_month_agg */
    where  ( T802.DEpt_CODE = T7608.DEPT_CODE and T802.NAME_LEVEL_1 =  '@{PV_D}{RSD}' 
    and T802.CALENDARMONTHNAMEANDYEAR = 'July 2013'
    and T6172.MONTH_KEY = T7608.MONTH_KEY and T6736.DATE_KEY = T7608.DATE_KEY
    and (T6172.CALENDARMONTHNUMBERINYEAR between substr('@{Month_Start}',0,6)  and substr('@{Month_END}',8,13))
    and (T6736.TYPE in ('Call Center', 'LSM')) )
    group by T802.DEPT_CODE, T802.NAME_LEVEL_6, T802.NAME_LEVEL_1, T6172.CALENDARMONTHNAMEANDYEAR, T6172.CALENDARMONTHNUMBERINYEAR
    order by c4, c3, c6, c7, c5
    ))where tile4=3 group by tile4
    When I try to view data after creating the data set, I get the following error:
    Failed to load XML
    XML Parsing Error: mismatched tag. Expected: . Location: http://172.20.17.142:9704/xmlpserver/servlet/xdo Line Number 2, Column 580:
    Now when I remove those Presention variables (@{PV1}, @{PV2}) in the query with some hard coded values, it is working fine.
    So I know it is the PV that's causing this error.
    How can I work around it?
    There is no way to create equivalent report without using the direct sql..
    Thanks in advance

    I have found a solution to this problem after some more investigation. PowerQuery does not support to use SQL statement as source for Teradata (possibly same for other sources as well). This is "by design" according to Microsoft. Hence the problem
    is not because different PowerQuery versions as mentioned above. When designing the query in PowerQuery in Excel make sure to use the interface/navigation to create the query/select tables and NOT a SQL statement. The SQL statement as source works fine on
    a client machine but not when scheduling it in Power BI in the cloud. I would like to see that the functionality within PowerQuery and Excel should be the same as in Power BI in the cloud. And at least when there is a difference it would be nice with documentation
    or more descriptive errors.
    //Jonas 

  • SQL Query with a variable?

    In Inventory > Item Master Data > Properties
    There are 'Property Name' and a column of checkboxes..
    How can I write a query to select the Property Names when the checkboxes are checked?
    My problem is the column of checkboxes does not show a table or column where its located, it only shows a variable..
    Is there away I can use variables in my SQL query?
    Any help is appreciated, thank you.

    Hi David,
    Each of those properties are linked to a field named QryGroupX, where the X starts at 1 and ends at 64. Each columns takes a "Y" ou "N" value.
    Don't know if this is what you want:
        Public Function GetBPProperties(ByRef oCompany As SAPbobsCOM.Company, ByRef oApplication As SAPbouiCOM.Application, ByRef CardCode As String) As String
            GetBPProperties = ""
            Try
                Dim oRS As SAPbobsCOM.Recordset = oCompany.GetBusinessObject(BoObjectTypes.BoRecordset)
                For i As Integer = 1 To 64
                    oRS.DoQuery("SELECT * FROM [dbo].[OCRD] T0 WHERE T0.CardCode='" & CardCode & "' AND T0.QryGroup" & i.ToString & " = 'Y'")
                    If oRS.RecordCount > 0 Then
                        GetBPProperties += ", " & i
                    End If
                Next
            Catch ex As Exception
                oApplication.MessageBox(ex.Message)
            End Try
        End Function
    Hope it helps,
    Vítor Vieira

  • Problems in SQL transform with variable in statement

    Hi,
    I have an sql transform with a variable in the statement. It looks like this:
    SELECT * FROM I.X where I.X.CUSTOMERNUMBER IN ([$variable])
    I have a script running prior which sets the $variable = '\'366800\',\'000933\'';
    (the CUSTOMERNUMBER field is a string)
    The problem is when DI compiles the SQL with the variable value, it is replacing each single quote with two single quotes, and thus turning my list of values into a single string (as recognised by DB2).
    How can I work around this? The CUSTOMERNUMBER field is indexed and the table is very large, so I want to use a very efficient statement to retrieve the data. I'm inserting this data into a different database, so I can't use the sql() function to execute the query and insert the rows into a new table in the same database (don't have authority to do that).
    I also need the sql to be dynamic because the customer numbers required will change from time to time. They're listed in another database and I plan on writing a loop to set the $variable value to contain all values in the lookup table, but I can't use that in a join because its in a different database and would not be efficient.
    Does anyone have any ideas? I'm literally all out, have tried a wide range of things to no avail, and none of my colleagues can work it out either.
    Thanks very much,
    -Steve

    I assume the SQL Transform is used only because of that in-list, not for other reasons....
    In this book page here: https://boc.sdn.sap.com/node/20046 at the very bottom it isdescribed on how to use the pushdown_sql() function in a where clause to add *any* text of your choice into the select statement DI generates. In this example I used a "where exists" but you can easily change the text to
    where key=5 and       pushdown_sql('my_datastore', 'CUSTOMERNUMBER IN ([$variable])')    and gender='M'
    I used the key=5 and gender=M just to clarify the syntax (I hope).
    For the SQL Transform, I wonder if you need the [$variable] syntax as well....

  • SQL query with Java Server Pages

    Hey,
    I'm trying to read some information from database with SQL Query. How I can put the parameter that I get from previous *.jsp page to SQL query?
    Technologies that I use are WML, JSP and MySQL.
    I can get the parameter by method getParameter() and it is correct.
    But how to but the requested parameter into sql query and complete the sql query?
    Should I read it to some variable before putting it to sql query?
    */ this works fine */
    out.println("<p>periodi"+request.getParameter("periodi"+"loppu</p>");
    /* this doesn't work */
    ResultSet tulokset = lause.executeQuery("select * from kurssi where periodi='+request.getParameter("periodi")+'");
    /* this doesn't work */
    String periodi=request.getParameter("periodi");
    ResultSet tulokset = lause.executeQuery("select * from kurssi where periodi='periodi' '");
    Thanks,
    Rampe

    Hey,
    I'm trying to read some information from database
    se with SQL Query. How I can put the parameter that I
    get from previous *.jsp page to SQL query?
    Technologies that I use are WML, JSP and MySQL.
    I can get the parameter by method getParameter()
    () and it is correct.
    But how to but the requested parameter into sql
    ql query and complete the sql query?
    Should I read it to some variable before putting it
    it to sql query?
    */ this works fine */
    out.println("<p>periodi"+request.getParameter("periodi"
    "loppu</p>");
    /* this doesn't work */
    ResultSet tulokset = lause.executeQuery("select * from
    kurssi where
    periodi='+request.getParameter("periodi")+'");
    /* this doesn't work */
    String periodi=request.getParameter("periodi");
    ResultSet tulokset = lause.executeQuery("select *
    * from kurssi where periodi='periodi' '");
    Thanks,
    RampeTry this
    ResultSet tulokset = lause.executeQuery("select * from kurssi where periodi=" + "'" +request.getParameter("periodi")+"' " );this should work

Maybe you are looking for

  • How can I remove a song that failed in download

    I was trying to download this song on my iPhone 4S and it failed I have been trying to remove it so I can start over again and it won't let me delete it from iTunes download part and cause of that now I can't even download anything else on my iPhone

  • AutoBLocking Bug on Ipod Touch

    Hi, I have a big problem with my new ipod touch. If I set autoblock = 1 min, I have a big problem. In that case, after a minute it's blocking, then goes in stand by. When I press On/Off button, I can se the apple but is not "lighted" (sorry for my ba

  • LIKE operator- change symbol for [all characters]

    I have an input parameter which contains symbols "*" (star symbol), example: i_search_par := 'country * street'; I gonna do query: select * from SearchTable where col1 like i_search_par; I want that the "*" would act the same way as "%"-symbol in LIK

  • 2 dvds inserted into drive. i can't get them out! any ideas?

    My daughter inserted 2 dvds into the drive and the computer is trying to eject them, but they are stuck! any suggestions? can't find any advice on the apple website. thanks!

  • Can I search my calendar

    It would be very useful to me if I can search my calendar so I can record when I last saw clients. I used to have an iPAQ and I could just put in the client's name and it would list all the entries relating to that name. Is this possible on the iTouc