Storing data filters to construct a SQL query

Hi, this is the picture:
I have list or table of data object, they are shown in more detail in another panel as an action occurs (mouse / keys). The objects of that list or table are fetch from a db. What I would like to do is create some user based filters of many fields to the fetch data and also store the filters so other users may use them. To add some more complexity I would also like to be able to group various filters.
The approaches that I am thinking about would be to store a hash table<db Filed, Criteria> for each filter (a filter may have many criterias). Based on the hashtable a SQL Query can be build.
To join or group various filters I would use union/except or sub queries (have not decided).
This brings me to ask for some advise, is their any patterns or libs for this and if someone else has done something similar and would like to share his approaches or logic they will be very welcomed.
Thanks
Billy

Hi Billy,
I have come across a similar scenario.
I need to develop a way to store, retrieve and use user defined filter criteria.
I see that you were developing a similar design in March this year.
Can you please let me know how did you do it.
Thanks,
Chetan Jindal.

Similar Messages

  • How to retrive the blob data from a table using sql query

    Hi gurus,
    I have a table which has " BLOB "content in a column .I want to view the data From BLOB column using sql query .It would be helpfull If some one share their idea.
    Regards,
    vardhani.

    You can use data templates.
    See this: http://blogs.oracle.com/xmlpublisher/entry/blob_clob_raw_and_looooong
    http://blogs.oracle.com/xmlpublisher/entry/inserting_blobs_into_your_repo
    Thanks,
    Bipuser

  • How to construct a sql query when field having single quote

    Hi all,
    I have been working on web application , here is my requirement:
    I'm constructing sql statement dynamically from dynamic user input (form data). In one of the field having single quote.
    while executing the query it is getting problem because of single quote .. so how do i resolve my problem.
    single quote should be there. (I'm using Ms-Access as my database).
    Thanks in advance
    abel

    Use PreparedStatement. Always. It not only eases setting Java objects in a SQL query, but also protects you against SQL injections.
    Prepare yourself: [http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html].

  • Default value of date picker not showing in sql query

    Hi,
    I have a tabular form page with a query similar to the following:
    select emp_name, salary from emp_table where trunc(hire_date)=trunc(to_date(:P42_START_DATE))
    where P42_START_DATE is the name of a date picker item.
    I set the source type of the date picker to be "Only when current value in session state is null" and the value to be "select trunc(next_day(sysdate,'MON')-7) from dual;" - basically the monday of the current week. I set the sequence of the date picker to be 5, and the sequence of the region to be 10. Now, when I open this page, no data gets pulled. I checked the page source, and the value of the date picker input is being set to "17-NOV-2008", but it somehow isn't reflected in the sql query.
    Data does get retrieved if I manually set the date in the date picker, but I'd like it to default to the monday of the current week. What am I doing wrong?
    Thanks

    nope, still same problem.
    I used javascript alerts to help debug, and here might be some useful information.
    The computation to set the value of :P42_START_DATE is set to run "before header", but when I put this following javascript in the header:
    <script language="javascript">
    var c = $v('P42_START_DATE');
    alert(c);
    </script>
    the alert box is blank (ie :P42_START_DATE is empty). Putting the same exact script in the footer gives 24-Nov-2008 in the alert box. Now, the SQL query is run sometime after the first alert and before the second alert, I believe. Why would the value of :P42_START_DATE not be getting set at the correct time?
    P42_START_DATE is a date picker item that belongs to the region SCHEDULE (which is where the sql query is). I set the sequence of the region to 10, and the sequence of the date picker and computation to be 5 and 6. Even so, does this mean that the sql query is executing before the call to the computation, because the region needs to be created before any items can be created that belong to the region?

  • Report data  does not reflect the SQL Query?

    Hi,
    I have a report which does not seem to be processing all records returned from the database. When I run the SQL Query produced by crystal manually against the SQL Server all data is returned correctly in crystal not. Does this mean my links are not set up correctly in the Database Expert? or is there another issue, I use a Crystal Syntax selection formulae which is based on a couple of paramters to filter the database records.
    Help is appreciated
    K

    <p>I agree with Rahul on checking the record count on the report vs. the record count from the query.  Conditional suppression and Group selection formula will hide records that are actually being returned.</p><p>It sounds like (from your question) that you are using the database linking expert in CR.  You can also check the SQL that CR is sending by going to Database -> Show SQL Query... compare this with the query you are using for validation, this will give you some clues as to whether your linking structure has an issue. </p>

  • CrystalRpts - Excel Data source, SQLServer2005 table. SQL Query behavior?

    Greetings - What should be a simple report (with Excel 2007 spreadsheet as primary data source linking to a SQLServer 2005 table ) returns incorrect results.  Query designed to select data from SQL Table with  'DATES >=' certain date, but data returned ignores the DATE qualifier.
    Running DATE query manually against the SQL Table proves the data is correct. 
    Anyone notice problems with SQL Query behavior when mixing data sources?  Thanks.

    Hello,
    Take the SQL that works outside of CR and then create a new report and add all data sources. Now use a Command Object and paste in your SQL. YOu may have to play with adding each data source in a different order. If that works great if not you'll have to figure out a way to get all the data into one source.
    I believe MS SQL Server can link multiple data sources and types. Check SQL Help file for more info it it is possible.
    Thank you
    Don

  • Facing problem in constructing a sql query

    I want a SQL Query through which I can Select all the values in a column of a table( which is Primary Key and another field in the table refers this field) I want to select all the values of the primary key which are either reffered by a particular value of the referring field or all the parents corrosponing to the value or their parents or their parents.... until I get a value which doen't refers any value.

    I want a SQL Query through which I can Select all the values in a column of a table( which is Primary Key and another field in the table refers this field) I want to select all the values of the primary key which are either reffered by a particular value of the referring field or all the parents corrosponing to the value or their parents or their parents.... until I get a value which doen't refers any value. Hi
    Did u try using Self Join
    I think that might solve the problem
    Sri

  • How to delete entire data from MDS UI using SQL query or Using SSIS

    Hi All,
    Using SSIS i loaded data in MDS UI(Subcription view),I want when i execute my package next time and load data in MDS it should be blank or data should not be in UI.

    Hi
    please checked following url to insert data  in your MDM
    http://msdn.microsoft.com/en-us/library/jj819772.aspx

  • SQL Query constructing  for searching values in Tables single Column

    I have Table USER_SERVICES with 2 Columns USER_NAME, Services. Please find below sample data on USER_SERVICES Table.
    A user can be assigned with multiple services(service1, service2 etc.,). So we store data as below :
    USER_NAME Services
    user1 service1
    user1 service2
    user1 service3
    user2 service1
    user2 service2
    user3 service3
    user4 service4
    I need to frame a SQL Query to 'select users assigned with Service A and Service B and Service n'.
    Note: 'And' condition is used when Searching for multiple services.
    Example: The SQL Query has to dynamically handle condition if i give Single Service, multiple Services(service1 and service2 e.t.c,)
    If i say select users assigned with service1 and service2, from the above Table, result should be user1 and user2
    If i say select users assigned with service1 and service2 and service3, from the above Table, result should be user1
    If i say select users assigned with service4 from the above table, result should be user4
    If i say select users assigned with service1 from the above table, result should be user2,user1
    If i say select users assigned with service1 and service2 from the above table, result should be user2,user1
    How do i construct the SQL Query. Any help will be appreciated.
    Thanks,
    Sathish
    Alternate email: [email protected]

    How it will be stored? In a string or a table or a collection type?
    If you have it in a table you can do like this.
    with t
    as
    select 'user1' user_name, 'service1' services from dual union all
    select 'user1', 'service2' from dual union all
    select 'user1', 'service3' from dual union all
    select 'user2', 'service1' from dual union all
    select 'user2', 'service2' from dual union all
    select 'user3', 'service3' from dual union all
    select 'user4', 'service4' from dual
    t1 as
    select 'service1' services from dual union all
    select 'service2' from dual
    select distinct user_name
      from (
    select t.user_name, t.services, t1.services, count(t1.services) over(partition by t.user_name) cnt, t1.cnt cnt_1
      from t
      left join (select t1.*, count(*) over() cnt from t1) t1 on t1.services = t.services
    where cnt = cnt_1

  • Data server switch in SQL query

    Hi guys,
    I have a question about data server switch in the sql query template. We have been developing all the sql queris pointing to the customer test db server say "TESTDB", now we have to change the db connection to "PRODUCTDB", do we need to change sql queries one by one or is there a better solution for this? I think this is a common requirement to change back and forth data server connection for a bulk number of queries
    Thanks,
    Tony.

    Tony,
    From a design perspective it is advisible to name your data servers in a more abstract way, since the query templates themselves only save the Name of the data server in them.  Data Servers also have a description field (typically overlooked) which will appear in the list and the workbench where you can be explicit or to even serve as a reminder that you are working with either test or production data.  The true 'switch' should happen when you reconfigure your data server settings for server url and user/pwd.
    TESTDB and PRODUCTDB might be better served with a meaningful name that provides a correlation to the data stored in the database.  In more mature system landscapes having a DEV/QA/PROD arrangement of MII servers, the ability to promote content comes from configuration and projects, not from actually changing the content on the same server.
    If you need to rapidly modify your content to adopt this practice then I would simply export the associated project and unzip it to a folder.  Then use windows explorer to do a search for files containing your data server name (they will appear in your query templates as Server="TESTDB").  With a text editor that can do search and replaces across multiple files (http://www.editplus.com is my personal favorite) you can easily change the data server name to a better convention.  Then zip up the folder content and reimport the project.  This will effectively switch your data servers (don't forget to create the new abstract data server in place of the TESTDB and PRODUCTDB).
    Regards,
    Jeremy

  • Different LOV behavior between SQL query data model and data template

    I have noticed different behavior when using parameters linked to list of values (LOV) of type menu with the multiple selection option enabled and a SQL query data model vs a data template. Here's the example because that first sentence was probably really confusing.
    SQL Query:
    select
    plmc.MonthCode, plmc.ModalityDim, plmc.ModalityName,plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(:modalityDim,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (:modalityDim)
    then 1
    else 0
    end
    end
    Putting BI Publisher into debug mode, defining a data model of type SQL Query, defining a parameter called :modalityDim linked to a LOV that allows multiple selections, and selecting a couple of values from the LOV the output of the prepared statement is:
    [081607_122647956][][STATEMENT] Sql Query : select
    plmc.MonthCode,
    plmc.ModalityDim,
    plmc.ModalityName,
    plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(?,?,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (?,?)
    then 1
    else 0
    end
    end
    [081607_122647956][][STATEMENT] 1:6
    [081607_122647956][][STATEMENT] 2:7
    [081607_122647956][][STATEMENT] 3:6
    [081607_122647956][][STATEMENT] 4:7
    [081607_122654713][][EVENT] Data Generation Completed...
    [081607_122654713][][EVENT] Total Data Generation Time 7.0 seconds
    Note how the bind variable :modalityDim was changed into two parameters in the prepared statement.
    When I use this same SQL Query in a data template the output is:
    [081607_012113018][][STATEMENT] Sql Query : select
    plmc.MonthCode,
    plmc.ModalityDim,
    plmc.ModalityName,
    plmc.RegionDim
    from
    DataOut.dbo.PatientLabMonthlyCross plmc
    where
    plmc.MonthCode = 200202
    and plmc.RegionDim = 1209
    and 1 =
    case
    when coalesce(?,null) is null
    then 1
    else
    case
    when plmc.ModalityDim in (?)
    then 1
    else 0
    end
    end
    [081607_012113018][][STATEMENT] 1:'6','7'
    [081607_012113018][][STATEMENT] 2:'6','7'
    [081607_012113574][][EXCEPTION] java.sql.SQLException: Syntax error converting the nvarchar value ''6','7'' to a column of data type int.
    Note the exception because it is trying to convert the multiple parameter values.
    Am I doing something completely wrong here? I really need to use a data template because I will need to link a couple of queries together from different database vendors.
    -mark

    This is for 10.1.3.4 - because in 11g every SQL query is automatially part of a data model.
    In 10g SQL query is for simple unrelated SQL queries.
    If you need to use advance features such as:
    a) multiple SQL queries that are joined in master-detail relation ships
    b) before/after report triggers
    Then you will need to use the data template, which is an XML description
    of the queries, links, and PL/SQL calls.
    hope that helps,
    Klaus

  • How to store data into database by reading sql statements from text file

    how to write java program for storing data into database by reading sql statements from text file

    Step 1: Create a property file to add various queries.
    Step 2: Read the properties file using ResourceBundle
    Step 3: Use the jdbc to execute the query read from the property file.
    So in future if you need to change query no need do any modifications in java program. But depends on how you use the property file.

  • Need Suitable Pure SQL Query

    Hi
    I have Pure SQL DataBase name of Table as per given Coloumn Name.
    User Name StartDate EndDate
    Mr.Jack 01/04/2010 05/04/2010
    Mr.Perlin 07/04/2010 10/04/2010
    Mr.Tinklin 01/05/2010 05/05/2010
    Mr.Kerlin 12/04/2010 15/04/2010
    Now I am using asp.net Form Using C#...
    Name --> TextBox
    StartDate -> TextBox
    EndDate --> TextBox
    Now User enter the Dates after Click Save Button....
    Here SQL Query Check Whether the User Dates Clause into Data Base Date's.
    For Examble..
    User Enter Start Date = 04/04/2010, EndDate =08/04/2010
    Now Query it check SQL DataBase, Already 01/04/2010 to 10/04/2010 Available so Dont allow Save.... only allow various dates...
    ---------------- This is task Condition -------
    i am using SQL Query
    DECLARE @StartDate DATETIME
    DECLARE @EndDate DATETIME
    SET @StartDate ='02/04/2010' --// This is User Start Date coming from Text Box
    SET @EndDate = '10/04/2010' --// This is User End Date coming from Text Box
    IF NOT EXISTS (SELECT PollID FROM Polls WHERE (StartDate<= CAST (CONVERT(VARCHAR,@StartDate,101) AS DATETIME) OR EndDate <= CAST (CONVERT (VARCHAR,@EndDate,101) AS DateTime)) AND STATUS<>'D')
    SELECT 'OK ALLLOW'
    ELSE
    SELECT 'NOT ALLOW'
    But it is not working Correctly....
    Pls give some correctful query for solve task Condition
    By
    Riyaz
    Edited by: 798225 on Sep 28, 2010 10:37 PM
    Edited by: 798225 on Sep 28, 2010 10:52 PM

    Now I am developing Polls Application in asp.net
    I am using Polls Concept,
    DateBase Name : Polls
    Fields : PollID          PollName                           StartDate                                     EndDate                     UserID
    In Asp.Form Having
    User Name :  TextBox
    PollName: TextBox
    StartDate: TextBox
    EndDate: TextBox
    Submit - Button
    Task Details
    Whenever User Click after fillup all data's... then SQL Query Check
    if StartDate or EndDate is exists in Between DataBase Date's.....
    Condition true means dont allow save.. else Save.....
    Examble:
    PollID PollName StartDate EndDate UserName
    01 Sample 23/09/2010 26/09/2010 Klit
    02 Sample 2 29/09/2010 30/09/2010 Jack
    Now User given follwing details and click Submit,
    User Name : James
    PollName: Test
    StartDate: 22/09/2010
    EndDate: 27/09/2010
    Submit - Button
    Here User StartDate: 22/09/2010 , EndDate: 27/09/2010
    SQL Query Check ,
    Condtion 1 : Those dates are avilable in Datebase???
    Result: Yes
    Because, Sample Poll date is 23/09/2010 to 26/09/2010, here Start Date is Not Exists, But End Date Exists.
    So dnt allow Save Operation....
    Now User Again given follwing details and click Submit,
    User Name : James
    PollName: Test
    StartDate: 27/09/2010
    EndDate: 28/09/2010
    Submit - Button
    Here User StartDate: 27/09/2010 , EndDate: 28/09/2010
    SQL Query Again Check ,
    Condtion 1 : Those dates are avilable in Datebase???
    Result: No
    Because, Sample Poll date is 23/09/2010 to 26/09/2010,
    Sample1 Poll Date is 29/09/2010 to 30/09/2010
    here Start Date is Not Exists, But End Date Not Exists.
    So Allow Save Operation....
    This a My Task....
    Could You give SQL Query for help to Check given condition??
    regd
    Riayz
    Edited by: Riyaz on Sep 30, 2010 1:08 AM

  • SQL query in some item.

    I have a string item with this example value:
    "SELECT 1 FROM dual"
    Yes, this is SQL query.
    Now I want to create PDF Report (Shared Components > Report Queries...) based on this SQL. I want to use this item (exactly, value from this item).
    How can I do it? Is this possible?
    regards,
    Jarek

    Hello,
    You can’t use “dynamic” SQL query within the Report Queries technique.
    You can use, as Luis suggested, a report region based on function returning query, in order to construct your SQL query. You can read some more details in the following:
    Re: ApEx PDF printing with Advanced support.
    Re: Dynamic Column in SQL-Statement
    Hope this helps,
    Arie.

  • Build essbase cube using Sql query.....

    Hi Team, Can we build dimensions as well as load data into essbase cubes using sql query generated from cognos cube. If so , please guide me the procedure

    I'm not sure about cognos, if you can create an ODBC connection you can try using that in SQL load rules and see if that works.
    Opening an SQL Database
    Regards
    Celvin
    http://www.orahyplabs.com

Maybe you are looking for