SQL Report query with condition (multiple parameters) in apex item?

Hello all,
I have a little problem and can't find a solution.
I need to create reports based on a SQL query or I.R. Nothing hard there.
Then I need to add the WHERE clause dynamically with javascript from an Apex item.
Again not very hard. I defined an Apex item, set my query like this "SELECT * FROM MYTAB WHERE COL1 = :P1_SEARCH" and then I call the page setting the P1_SEARCH value. For instance COL1 is rowid. It works fine.
But here is my problem. Let's consider that P1_SEARCH will contain several rowids and that I don't know the number of those values,
(no I won't create a lot of items and build a query with so many OR!), I would like sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (:P1_SEARCH) with something like : ROWID1,ROWID2 in P1_SEARCH.
I also tried : 'ROWID1,ROWID2' and 'ROWID1','ROWID2'
but I can't get anything else than filter error. It works with IN with one value but as soon as there are two values or more, it seems than Apex can't read the string.
How could I do that, please?
Thanks for your help.
Max

mnoscars wrote:
But here is my problem. Let's consider that P1_SEARCH will contain several rowids and that I don't know the number of those values,
(no I won't create a lot of items and build a query with so many OR!), I would like sotheming like "SELECT * FROM MYTAB WHERE ROWID IN (:P1_SEARCH) with something like : ROWID1,ROWID2 in P1_SEARCH.
I also tried : 'ROWID1,ROWID2' and 'ROWID1','ROWID2'
but I can't get anything else than filter error. It works with IN with one value but as soon as there are two values or more, it seems than Apex can't read the string.For a standard report, see +{message:id=9609120}+
For an IR&mdash;and improved security avoiding the risk of SQL Injection&mdash;use a <a href="http://download.oracle.com/docs/cd/E17556_01/doc/apirefs.40/e15519/apex_collection.htm#CACFAICJ">collection</a> containing the values in a column instead of a CSV list:
{code}
SELECT * FROM MYTAB WHERE ROWID IN (SELECT c001 FROM apex_collections WHERE collection_name = 'P1_SEARCH')
{code}
(Please close duplicate threads spawned by your original question.)

Similar Messages

  • Bi publisher report issues with selecting multiple parameters.

    Hi there I have a Bi publisher report when I query it for a single parameter it works fine and gives me the result.
    But when I select multiple parameters Lets say I have selected 3 parameters and try to view the results it does nt give me a proper report. It leaves me some blanks and gives me negative values.
    The report is working finr for one parameter In order to select two parameters I added the following code in the sql query
    and ( coalesce(null, :JOB_ID) is null
    or c.JOB_ID in (:JOB_ID)) .
    Can some one please let me know if this is correct or should I have to add anything else in the query.
    Even if I hard code it by saying JOB ID IN ('x','y','Z') and try to run the report it is not giving me exact values.
    BUt when I run the same query in database am getting correct values..
    Can anyone help me with this issue please??
    Thanks

    1. What version of BIP are you using?
    2. Can you please paste here your complete SQL data model?
    3. Can you get us an example how this will work?
    4. Can you be more specific about the error you get and the output?
    thanks
    Jorge

  • Sql query with conditions and calculations???

    Hi,
    how I can build a query with conditions and calculations?
    E.g. I've got this table
    Start          | End     |     Working Place     |     Mandatory
    01-JAN-13 | 11-JAN-13 |     Office           |          1
    14-JAN-13 | 25-JAN-13 |     Home Office      |     0
    04-MRZ-13| 15-MRZ-13 |     Office           |          0
    11-FEB-13 | 22-FEB-13 |     Office           |          1
    Now if column working place=Office and column mandatory=0
    the new column "price" has to calculate: (End-Start)* $25.00
    and if working place=Office and column mandatory=1
    the "price" column has to calculate: (End-Start)* $20.60
    else $0.00
    I tried it with the case statement but I didn't know how
    to calculate my values and display it to the virtual column "price".
    Something like
    case
    when Working_Place = 'Office' and Mandatory=1
         then ...
    else '0.00'
    end as PRICE
    Or is it not possible?
    Edited by: DB2000 on 12.03.2013 05:09

    Use CASE:
    select  start_dt,
            end_dt,
            working_place,
            mandatory,
            case
              when working_place = 'Office' and mandatory = 0 then (end_dt - start_dt) * 25
              when working_place = 'Office' and mandatory = 1 then (end_dt - start_dt) * 20.60
              else 0
            end price
      from  tbl
    START_DT  END_DT    WORKING_PLA  MANDATORY      PRICE
    01-JAN-13 11-JAN-13 Office               1        206
    14-JAN-13 25-JAN-13 Home Office          0          0
    04-MAR-13 15-MAR-13 Office               0        275
    11-FEB-13 22-FEB-13 Office               1      226.6
    SQL> SY.

  • SQL Reporting Services with Java EE

    I have developed a Java application for calling the SQL Reports. A couple of reports are made in the server. This SQL Reporting server is deployed and the client is made in the java using Werb services. Whenever a search is done from the Java application, reports are displayed on the JSP page using the web service methods. But the problem is the entire report is displayed. Is there any way to display the report based on the particular item search. Suppose, if search is made on "Australia" in the coulumn Country, the report should contain only Australian related data. Currently the search is based on the report name itself.

    bobz wrote:
    jschell wrote:
    bobz wrote:
    Is there any book on SQL Reporting services with Java
    [http://www.javaworld.com/javaworld/jw-01-2005/jw-0110-sqlrs.html]
    This looks hopeful.I have already developed a java EE for calling reports with the help of ---"MSDN Virtual Lab: Implementing SQL Server Reporting Services with a Java Enterprise Edition (EE) Application (ID:1032315323)". Now I need to find out the parametrized reports(passing parameters to the report calls and more customization using java). In .NET, reportviewer controller is available for this purpose. I want to achieve the same type of thing using java.The protocol of controlling the Report Server is a feature of the Report Server.
    To control it you learn the protocol. To use it you program it in java.
    The first has nothing to do with java. The second obviously does.

  • Sub query with conditions

    Hi,
    Is it possible to run a sub query with conditions? I keep receiving an error 'Registration Data' -2006.
    For example, here is a simplified query which gives the error...
    SELECT T1.CardCode FROM
    SELECT T0.CardCode FROM OCRD T0 WHERE T0.CardCode = '[%0]'
    ) T1
    FOR BROWSE
    Thanks for any help,
    Robin

    SBO SQL-parser sometimes kidding. My solution is to use temptables/views/storedprocedures.
    It's faster then "unbugging" parser <b>:)</b>
    in your case that can be like the following:
    SELECT T0.CardCode INTO #temp FROM OCRD T0 WHERE T0.CardCode = N'[%0]'
    SELECT qq.CardCode FROM #temp qq FOR BROWSE
    BTW: registration data error is usially says us about %-argument reason

  • Performance of APD with source as 'Query with conditions'

    Hi,
    I have a question regarding the performance of an APD query with conditions when it is run in the background.
    I have an infocube with 80 million records.I have a query to find Top 15 (Condition In query) Customers per territory.
    With the help of an APD Query (Source) i wanted to populate the details (customer category , etc) of the Top 15 Customers into a DSO (Target)
    Right now it takes 6 minutes to run the query in web.
    I wanted to know how feasible it is to use an APD (run in backgrnd) to dump the results of the BEx query (which has conditions Top 15) into DSO.
    Also , what other options do i have ?
    Appreciate your answers.
    Regards

    Thomas thanks for the response.  I have checked the file on the app server and found that the lines with more than 512 characters are being truncated after 512 characters.  Basis team is not aware of any such limits on the app server.  I am sure few on the forum would have extracted data to a file on the application server using APD.  Please note that the file extraction to the client workstation is working as expected (posts lines more than 512 characters).

  • SQL Azure - query with row_number() executes slow if columns with nvarchar of big size are included

    I am linking my question from Stack Overflow here. The link: http://stackoverflow.com/questions/27943913/sql-azure-query-with-row-number-executes-slow-if-columns-with-nvarchar-of-bi
    Appreciate your help!
    Gorgi

    Hi,
    Thanks for posting here.
    I suggest you to check this link and optimize your query on sql azure.
    http://www.sqlusa.com/articles/query-optimization/
    http://sqlblog.com/blogs/paul_white/archive/2011/02/23/Advanced-TSQL-Tuning-Why-Internals-Knowledge-Matters.aspx
    Also check this blog which had similar issue.
    https://social.msdn.microsoft.com/Forums/en-US/c1da08b4-265d-4ec8-a252-8d7090234e3e/simple-select-query-takes-long-time-to-execute-with-nvarchar-columns?forum=transactsql
    Girish Prajwal

  • Report query with multiple selects

    On some of my Report Queries (that have multiple selects) it sometimes changes the rowset when I edit the specific SQL.
    For example, I have 2 selects in my Report Query andnd when I download the XML my first select’s data goes into <ROWSET1> and my second select’s data goes into <ROWSET2>. I then make my template and everything is good.
    But, sometimes when I edit the SQL in the report it changes the ROWSET number of the data so now my first select’s data in ROWSET2. This blows up the report. Is this a bug? Why is it switching the rowsets back and forth?

    I'm referring to the Report queries under shared components.
    My first query is like this:
    select A.emp_id
    from tab1 AC4, tab2 AC3, tab3 AC2, tab4 AC1, tab5 A
    where A.year = :page_year
    and C.FK_SCHOOL IN (SELECT c001
    FROM apex_collections AC1
    WHERE AC1.collection_name = 'SIS_REPORTS_SCHOOLS')
    and nvl(C.ACTIVE,'NONE') IN (SELECT decode(c001,'NONE',nvl(C.ACTIVE,'NONE'),C001)
    FROM apex_collections AC2
    WHERE AC2.collection_name = 'SIS_REPORTS_ACTIVES')
    and nvl(C5.CALENDAR_NO,'NONE') IN (SELECT decode(c001,'NONE',nvl(C5.CALENDAR_NO,'NONE'),C001)
    FROM apex_collections AC3
    WHERE AC3.collection_name = 'SIS_REPORTS_SCHOOL_CALENDAR_NOS')
    and nvl(C10.CLUSTER_CODE,'NONE') IN (SELECT decode(c001,'NONE',nvl(C10.CLUSTER_CODE,'NONE'),C001)
    FROM apex_collections AC4
    WHERE AC4.collection_name = 'SIS_REPORTS_CLUSTER_CODES')
    My second query needs to select the detail info from other tables, but I only want to do it for the (master) records that were returned in the first query.

  • UPDATE multiple columns with conditional SET parameters

    I have a procedure that updates multiple columns of a table using the procedure's parameter. Is it possible to have one update statement with conditional SET parameter?
    CREATE TABLE TEMP
    (POL_NUM NUMBER,
    OED DATE,
    TERM NUMBER,
    TRANS_CD CHAR(2));
    INSERT INTO TEMP VALUES (1, '1 AUG 2009', 12, 'NB');
    INSERT INTO TEMP VALUES (2, '4 AUG 2009', 12, 'XL');
    INSERT INTO TEMP VALUES (3, '2 AUG 2009', 12, 'RN');
    COMMIT;
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM NUMBER,
      pOED IN DATE,
      pTERM IN NUMBER,
      pTRANS_CD CHAR2)
    AS
    BEGIN
      IF pOED IS NOT NULL THEN
        UPDATE TEMP SET OED = pOED WHERE POL_NUM = pPOL_NUM;
      END IF;
      IF pTERM IS NOT NULL THEN
        UPDATE TEMP SET TERM = pTERM WHERE POL_NUM = pPOL_NUM;
      END IF;
      IF pTRAN_CD IS NOT NULL THEN
        UPDATE TEMP SET TRANS_CD = pTRANS_CD WHERE POL_NUM = pPOL_NUM;
      END IF;
      COMMIT;
    EXCEPTION
      WHEN OTHERS THEN
         NULL;
    END;Is it possible to replace multiple IFs from the code to have only one UPDATE statement with condition that update the column only if the passed parameter is not null? In real scenario I have more than 3 columns and I don't want to write many IF blocks.
    Please help Gurus!!
    Edited by: Kuul13 on Sep 18, 2009 1:26 PM

    Hi,
    You certainly don't want to issue separate UPDATE statements for every column; that will be really inefficent.
    SQL has several ways to implement IF-THEN-ELSE logic. CASE is the most versatile, but NVL will do everything you need for this job. You can use one of those to set a column to itself (and therefore not really update that column) when appropriate.
    For example:
    CREATE OR REPLACE PROCEDURE TMP_PROC (
      pPOL_NUM   IN       NUMBER,
      pOED          IN   DATE,
      pTERM          IN   NUMBER,
      pTRANS_CD  IN       CHAR
    AS
    BEGIN
         UPDATE  temp
         SET     oed      = NVL (poed,       oed)
         ,     term      = NVL (pterm,       term)
         ,     trans_cd = NVL (ptrans_cd, trans_cd)
         WHERE     pol_num      = ppol_num;
      COMMIT;     -- Maybe
    END    tmp_proc;"EXCEPTION WHEN OTHERS THEN NULL" is almost always a bad idea. If there's an error, don't you want to know about it? Shouldn't you at least log a message in a warnings table or something?
    Think careflully about whether or not you want to COMMIT every time you call this procedure.
    Just as it's inefficient to issue a separate UPDATE statement for every column, it's also inefficient to issue a separate UPDATE statement for every row. If efficiency is important, it should be possible to UPDATE several rows in a single UPDATE statement, using NVL (or CASE, or COALESCE, or NULLIF, or NVL2, or ...).
    This was a very well-written question! Thanks for providing the CREATE TABLE and INSERT statements, and such a clear explanation.

  • Report query with bind variable

    Trying to create a report query for xsl-fo print. For output format I pick "derive from item" then pick the item name from the list, on the next screen, I paste the query with the bind variable. on the next step test query, I always get "data not found" regardless what value I type in. This is the same query that I ran under sql commands without any issues.
    Does anyone run into the same issue as I have when attempted to create a query with bind var ? There is no problem creating a query without bind varibles. . thanks.
    Munshar

    Hi, please did you get any solution to this issue? I am having similar challenge right now.
    select     EMP.DEPTNO as DEPTNO,
         DEPT.DNAME as DNAME,
         EMP.EMPNO as EMPNO,
         EMP.ENAME as ENAME,
         EMP.JOB as JOB,
         EMP.MGR as MGR,
         EMP.HIREDATE as HIREDATE,
         EMP.SAL as SAL
    from     SCOTT.DEPT DEPT,
         SCOTT.EMP EMP
    where EMP.DEPTNO=DEPT.DEPTNO
    and      DEPT.DNAME =upper(:dname)
    This run perfectly in sql developer, toad, and even inside publisher if I login directly to publisher to create report.
    Generating this same query in shared component query builder and testing it returns no data found. If I remove the last line, it works. but with the last line, it return no data found. It seems no one has been able to provide solution to this issue

  • How To Use a Hidden Page Item within an SQL Report Query without Submitting

    Hi,
    Using: Oracle ApEx 3.0.1
    I have an sql report region that contains a hidden page item as part of the "where clause". My problem is, based on a value entered by the user, I need to assign this value enetered to my hidden item, so that it can be used within the where condition of my sql but this would need to be done without actually submitting the form.
    At the moment, I can set the value via an on-demand process but my SQL is still not returing any values as the hidden page item within the query is not set (as page has not been submitted).
    Can anybody please assist as I am not sure how to do this and whether in actual fact, this is possible to do, without having submitted the page.
    Thanks.
    Tony.
    Edited by: Tony F. on Nov 12, 2011 1:39 AM

    You can set a session value using a dummy ajax call e.g:
    Add the following to the 'Function and Global Variable Declaration' region
    function f_set_item(pThis){
      var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=dummy',1);
      get.add('P1_ID',pThis.value)
      gReturn = get.get();
      get = null;
    }Where P1_ID is the session value to be set. Then call the function in the usual way e.g.
    javascript:f_set_item(this);
    I hope that helps
    Shunt

  • Missing Result Rows on Query with Conditions

    I have a query that has a condition to show only items over $2500.00.   We have a result row that shows for plant when the condtions is not on but once the condition is set that result row goes away.  Does anyone know how to get a result row to show up on reports with conditions?  Thank you.
    Caroline

    Hi Caroline,
    In BI 7.0, you goto do this in Query Designer.
    Select any of your characteristic in the designer and choose Display Properties to always display result.
    Then run the query.
    Assign Points if Helps !!
    Regards,
    Naveen Rao Kattela

  • Passing sql report query field value to hidden item in javascript

    I have sql report which has in each row one html button. Let us say that query SHOULD look like (two columns, to be easy to get the point):
    select 1 SECURITY_ID
      , '<input type="BUTTON" value="Top10" onClick="javascript:Top10Click ('||SECURITY_ID||');" >' BTN
    FROM DUAL;
    function Top10Click (vValue) {
      html_GetElement('P31_PROCESS_VALUE').value = vValue;
      doSubmit('GO_BACK');
    } <br><br>
    where P31_PROCESS_VALUE is hidden item where i want to store value of row where click happened.
    <br><br>
    In every button i want to pass row value "SECURITY_ID" to Top10Click function for each row differently.
    <br><br>
    Problem is that when I place double qoute then js is not working, else js is ok but "SECURITY_ID" is passed as constant not as live SQL value.
    <br><br>
    Any help...THX!
    <br>
    Demo is on oracle:
    http://htmldb.oracle.com/pls/otn/f?p=26216:1
    Workspace entry:
    WK: FUNKY
    UN: [email protected]
    PW: qwertz

    I have tried to unify the solution, so it looks like:
    select 1 SECURITY_ID
      , '<input type="BUTTON" value="Top10" onClick="javascript:Top10Click ('||'&quot_X;'||SECURITY_ID||'&quot_X;'||');"  >' BTN
    FROM DUAL;change '&quot_X;' (remove "_X" part ... so it can be seen in HTML properly!
    THX Denes for great ideas...

  • Using SQL reporting services with java

    how can i use Microsoft SQL Server reporting services with java? The idea is that we create the reports using Microsoft SQL Server reporting services. Then we have our web application where user will select one of those report, pass 0 or more arguments and then we will show the report.

    nobody is using Microsoft SQL Server reporting
    services with java?Found this in 0.01 seconds with Google http://www.javaworld.com/javaworld/jw-01-2005/jw-0110-sqlrs.html
    Handy tool that Google.

  • SQL Reporting Services with Visual Studio 2012

    Hi
    I would like to know if there will be any release to improve on the placeholder feature in SQL reporting services. Currently, I have users who uses HTML editor to input data and tables. However, the table in html format cannot be read.
    I do understand that currently the placeholder feature can only have limited html tag recognised. However, is there any plan to improve it so that <table> tag can also be recognise?
    Or if there is any workaround to show the table format in the reports?
    Sorry but this is urgent as it is used for business application.
    Many thanks

    Hi DotNeTEngineeR,
    According to description, you want to display the content of table tag (<tag>) in a report. Right?
    In Reporting Services, it only has the supported HTML Tags below:
    Hyperlinks: <A HREF>
    Fonts: <FONT>
    Header, style and block elements: <H{n}>, <DIV>, <SPAN>,<P>, <DIV>, <LI>, <HN>
    Text format: <B>, <I>, <U>, <S>
    List handling: <OL>, <UL>, <LI>
    For your requirement, we suggest you use <div> to replace <table> tags in your embedded HTML. Please see the article below:
    Embedded HTML using <div> to replace <table> tags in ssrs 2008
    Reference:
    Importing HTML into a Report (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

Maybe you are looking for