Multiple values in where clause(IN) of select query in Cisco Cloud Portal using single field

I can actually pass multiple values in the IN statement of select query using multiple dictionary fields in the data retrieval rule of the AFC in Cisco cloud portal like
#dictionary.field1# = 1 and
#dictionary.field2#=2
select col1,col2 from table1 where col3 in (#dictionary.field1#,dictionary.field2#).
but I want to pass mutiple values in a single field as
#dictionary.field1#=1,2
select col1,col2 from table1 where col3 in (#dictionary.field1#) and the query gives no data because it is taking as '1,2' instead of '1','2'.
Please give the solution for passing multiple values in a single variable to use in IN operator of WHERE clause

Ok, I now understand what you are trying to do. Unfortunately, you cannot inject parts of a SQL statement into a DDR through a dictionary field, which always represents a specific value (the comma in your case is attempting injection of a SQL construct to refer to multiple values). One possible solution is to arbitrarily consolidate your list of values using a delimiter that you know will not be in the values themselves such as a colon (:). Let's use 3 values as it serves as a better example.
Set your dictionary field to a single reference to all 3 values of interest, say 'a', 'b', 'c' as:
:a:b:c:  (you can use javascript to create this consolidated dictionary field)
Now your query would look something like the following:
select col1,col2 from table1 where #dictionary.field1t# like '%:'+col3+':%'
This should achieve the desired result.

Similar Messages

  • Where clause priority in Select Query

    Hi All,
    I have one doubt, Pls clarify
    SELECT empno, ename, sal, comm
    FROM emp E, dept D -- (deptno is pk for DEPT)
    WHERE D.deptno = E.deptno
    AND E.sal >= 3000
    In WHERE clause which one will execute first (right to left or left to right
    OR[b] First join conditions then after filter conditions or vice versa)
    D.deptno = E.deptno
    OR
    E.sal >= 3000
    (this is the example tables)
    Because I have large volume of data with 5 tables with joins
    so, pls. kindly give me the sugession for where clause.
    Thanks
    Naresh

    It depends, the order the where clause is written in makes no difference to how the statement is processed.
    In the section on Developing Efficient SQL Statements in the Performance Tuning Guide changing the order of statements in the where clause is notably missing.
    There is more information in the Understanding Joins section of the same manual.

  • Can we use concatenate in where clause of a select query

    I have a select query as follows....
        SELECT ebeln ebelp belnr vgabe bwart DMBTR
                                 FROM ekbe
                                 INTO TABLE i_ekbe
                                 FOR ALL ENTRIES IN i_blck
                                 WHERE ebeln =  i_blck-ebeln AND ebelp =                                                                               
    i_blck-ebelp.
    Now i want to retrieve data from BKPF ..can i write a select query something like....
    select * from BKPF into itab
                FOR ALL ENTRIES IN i_ekbe
                where awkey = ( conatenate i_ekbe-belnr i_ekbe-gjahr )
    OR ELSE...is there any other way to link table ekbe and bseg ???

    Hi Poonam,
    SELECT ebeln ebelp belnr vgabe bwart DMBTR
    FROM ekbe
    INTO TABLE i_ekbe
    FOR ALL ENTRIES IN i_blck
    WHERE ebeln = i_blck-ebeln
    AND ebelp = i_blck-ebelp.
    select *
    from BKPF
    into  table itab
    FOR ALL ENTRIES IN i_ekbe
    where belnr = i_ekbe-belnr.
    If u want to check with AWKEY concatenate into seperate field and then use to check in where condition.
    data: lw_awkey(20) type c.
    CONCATENATE  i_ekbe-belnr  i_ekbe-gjahr  INTO lw_awkey.
    select *
    from BKPF
    into  table itab
    FOR ALL ENTRIES IN i_ekbe
    where awkey = lw_awkey
    Best regards,
    raam

  • Values from a Multi-Select in the where clause of a Select statement

    I have a web page that solicits query parameters from the user.
    The selections that the user makes will populate the WHERE clause of a Select statement.
    One of the controls on the page is a multi-select control.
    When this page posts, I would like to execute a Select statement wherein the selected values from this control appear in the .. Column IN ( <list here> ) portion of the WHERE clause.
    This is an extremely common scenario, but I cannot seem to locate a how-to or message thread that addresses this specific case.
    I have an idea that it may involve dynamic SQL or Execute Immediate, but cannot seem to pin down the answer.
    Any help would be greatly appreciated!

    anonymous - As illustrated here: Re: Search on a typed in list of values
    Scott

  • Parsing an input parameter for the where clause or record select value

    In my limited CR experience, I've always used a command database connection so that I can write my own SQL.  However, now I have to parse a  pipe delimited parameter to get my value for the where clause, so I'm selecting several tables and joining them through the Database Expert Links tab.  All works fine, but after doing that and then parsing the parameter with the below formula in the Select Expert, I notice that there is no where clause in the SQL query, and although the report eventually displays the proper values, it runs through thousands of records first.  Here is my Select Expert - Record formula:
    StringVar array Parm1;
    Parm1 := Split({?DATA_AREA}, "|");
    {SO_ORDERS.CASE_ID} = Parm1[2]
    If I change "Parm1[2]" on the last line to a valid Case ID, then there is a where clause in the SQL and the report generates immediately. 
    It seems like the record select formula is applied AFTER all of the records (without a where clause) are searched when I use the parsed parameter value, but when I hard code a valid value, it places that into the where clause BEFORE the sql is executed.  Is there a way to get the parameter parsed first and then use that parsed value in the SQL where clause?
    Thanks.
    Bill

    Yes crystal will run the query first to get 100% data and then applies record selection condition. To increase the performance you need to pass the where condition at the command level instead of report level. So you need to create a report using add command like this
    select * from tablename where field={?Parameter}
    {?Parameter} is a command level parameter.
    Now insert this report as a subreport in another report which has no connection but has a parameter
    {?DATA_AREA} and create a formula like this in the main report
    Split({?DATA_AREA}, "|")[2]
    Now right click on the subreport and go to change subreport links and add this formula from main report and link this to sub report parameter {?Parameter} without linking any database field from the subreport.
    Now your subreport runs with the where clause to get the data.
    Regards,
    Raghavendra

  • How can I pass multiple condition in where clause with the join table?

    Hi:
    I need to collect several inputs at run time, and query the record according to the input.
    How can I pass multiple conditions in where clause with the join table?
    Thanks in advance for any help.
    Regards,
    TD

    If you are using SQL-Plus or Reports you can use lexical parameters like:
    SELECT * FROM emp &condition;
    When you run the query it will ask for value of condition and you can enter what every you want. Here is a really fun query:
    SELECT &columns FROM &tables &condition;
    But if you are using Forms. Then you have to change the condition by SET_BLOCK_PROPERTY.
    Best of luck!

  • Using multiple dates in WHERE clause

    I have a multiple select box in a form. I am trying to select
    records in SQL using the list that this form field produces. They
    are dateTime values. How do I use this list in the WHERE clause of
    my select statement?

    Man, I really hate posting anywhere near Dan - I've been
    watching his mastery for years. (Talk about the big leagues) But
    here goes anyway...
    I've gotten my little behind kicked by more than a view date
    issues, and I have basically gotten away from exact matches (unless
    you really need them).
    I'd probably do something like this:
    SELECT field1,field2...
    WHERE datetime_column_in_db > (OR LTE,OR GT/LT)
    '#datetimeformatyoulike(form.datetimevalue1)#
    Basically, finding records in RELATION to the form's datetime
    value has always been much easier for me.
    And God (and Dan) have mercy on my soul...

  • Call a function in a where clause of a select

    hello,
    is it possible to call a function in a where clause of a select????
    ex: select col1, col2
    from my_table
    where my_package.my_function(32199, 2008, col3, 'P');
    and i have error message "ORA-00920: invalid relational operator"
    FUNCTION my_function(v_matricule IN NUMBER,
              v_Year IN NUMBER,
              v_date IN DATE,
              v_type IN CHAR DEFAULT 'P')
    RETURN BOOLEAN;
    @+Rosagio

    user10225229 wrote:
    hello,
    is it possible to call a function in a where clause of a select????
    ex: select col1, col2
    from my_table
    where my_package.my_function(32199, 2008, col3, 'P');
    and i have error message "ORA-00920: invalid relational operator"
    FUNCTION my_function(v_matricule IN NUMBER,
              v_Year IN NUMBER,
              v_date IN DATE,
              v_type IN CHAR DEFAULT 'P')
    RETURN BOOLEAN;You can call a function if it returns a datatype that is supported by SQL. BOOLEAN is NOT supported by SQL.

  • How do I modify the WHERE clause in my SQL query?

    This seems like such a straight-forward part of the report design, but I'm fairly new to Crystal Reports and I only have experience with modifying reports someone else has already written.  In this particular case, I just need to modify the WHERE clause of the SQL query.  I can select Show SQL Query and see what statement is being used to select data, but I can't find where to modify it since it's grayed out.  I see how to change the selection criteria, parameters, grouping, etc...just not the WHERE clause.  The report is linked to a database used for reporting with a table created and populated by a stored procedure.  I don't need to modify the stored procedure because the data I want to filter by is currently in the table--I just don't know how to filter by what I need.  Here's part of the query:
    SELECT "rpt_dist"."startdate", "rpt_dist"."transtype", "rpt_dist"."laborcode", "rpt_dist"."crewid", "rpt_dist"."regularhrs" FROM   "Reporting"."dbo"."rpt_dist" "rpt_dist"
    WHERE  (rpt_dist."transtype" <> 'WORK' AND rpt_dist."transtype" <> 'WMATL') AND rpt_dist."laborcode" LIKE 'S%' AND (rpt_dist."crewid" = 'HOUS' OR rpt_dist."crewid" = 'HOUS2' ...
    I would like to add another crewid to the WHERE clause.  Thanks for any input.

    1.Open the report in the crystal designer
    2.Go to the field explorer(if hidden go to view menu->field explorer)
    3.Rt. click on the database fields->choose database expert
    4.Now you will see 2 columns-Available DataSource  and Selected Tables
    5.Rt. click on the object(ex.command) available in the Selected Tables column->Choose Edit command
    6.A new Modify Command window will appear,here you can edit your SQL Query
    I get to step 4 and I see the two columns including my database and the report table, but there is no command object available.  If I right-click on my table, I can just view the Properties. ??
    As for the other tip to modify the record selection:  I don't see anywhere the other crewid values are set and if I add the one I'm missing, it doesn't modify the existing SQL Query and when I preview the report it throws off the results so that no data displays??
    I'm using Crystal Reports 11.5 if that makes a difference.  Thanks again.

  • How to dynamically update columns in a where clause to a SQL query in OSB?

    Hi Gurus,
    I have a requirement where in we need to dynamically update a where clause to a SQL query in OSB(11.1.1.6.0).
    For example:
    If the JCA sql string is "select * from emp where emp_id = 100 and emp_status ='Permanent'" now i want to change this where clause and the new query has to be like "select * from emp where emp_name like 'S%' and emp_dept like 'IT' ". basically we need to change the where clause dynamically.
    We can also use "fn-bea:execute-sql()" in a xquery but I don't want to use this function as creates a new connection.
    I have done some home work and found out --> as per the DOC "http://docs.oracle.com/cd/E23943_01/dev.1111/e15866/jca.htm#OSBDV943" section: "25.5.2 JCA Transport Configuration for Proxy and Business Services", when a business service is created by using JCA, we can see Interaction Spec Properties under JCA Transport Tab. This will have a property "SqlString' and we can over ride it. But I am unable to figure out how to over ride the value. I have tried by using Transport Headers activity but no luck. Please guide me how to achieve this?
    Thanks in advance
    Surya

    I solved my problem.
    In my header renderer, I simply added a line to set the text to the object value "label.setText( (String) value );" (where label is an instance of a JLabel.
    Thank you to who took some time to think about it.
    Marc

  • Count all values with a special WHERE clause in a select for a group?

    Hello,
    I have the following table1:
    code, month, value
    *1,1,40*
    *1,2,50*
    *1,3,0*
    *1,4,0*
    *1,5,20*
    *1,6,30*
    *1,7,30*
    *1,8,30*
    *1,9,20*
    *1,10,20*
    *1,11,0*
    *1,12,0*
    *2,1,10*
    *2,2,10*
    *2,3,20*
    *2,4,20*
    *2,5,20*
    *2,6,30*
    *2,7,40*
    *2,8,50*
    *2,9,20*
    *2,10,20*
    *2,11,20*
    *2,12,20*
    This is a table with 3 columns, first column is a code, second one is the number of month, third one is a value.
    Now I want to select the records for each code. For example all records for code=1.
    I want to count how much values=0 for this code=1. After this counting I want to update the value with this count of 0.
    For my example:
    For code 1 there are 4 fields with value 0. Therefore I want to update all values of code1 to 4.
    For the second code=2 there are no value=0. Therefore I want to update the values of code2 to 0.
    This should be the result:
    code, month, value
    *1,1,4*
    *1,2,4*
    *1,3,4*
    *1,4,4*
    *1,5,4*
    *1,6,4*
    *1,7,4*
    *1,8,4*
    *1,9,4*
    *1,10,4*
    *1,11,4*
    *1,12,4*
    *2,1,0*
    *2,2,0*
    *2,3,0*
    *2,4,0*
    *2,5,0*
    *2,6,0*
    *2,7,0*
    *2,8,0*
    *2,9,0*
    *2,10,0*
    *2,11,0*
    *2,12,0*
    My question is:
    Is there any possibility in oracle to count in a select (or in a insert/update statement) all values=0 for one group (in this example named CODE) and do an update in the same statement for this group?
    Hope anyone can give me a hint if this is possible?
    Thanks a lot.
    Best regards,
    Tim

    Here's the select:
    SQL> select code, month
      2        ,count(decode(value,0,1,null)) over (partition by code) ct
      3  from   t
      4  order by code, month
      5  ;
                    CODE                MONTH                   CT
                       1                    1                    4
                       1                    2                    4
                       1                    3                    4
                       1                    4                    4
                       1                    5                    4
                       1                    6                    4
                       1                    7                    4
                       1                    8                    4
                       1                    9                    4
                       1                   10                    4
                       1                   11                    4
                       1                   12                    4
                       2                    1                    0
                       2                    2                    0
                       2                    3                    0
                       2                    4                    0
                       2                    5                    0
                       2                    6                    0
                       2                    7                    0
                       2                    8                    0
                       2                    9                    0
                       2                   10                    0
                       2                   11                    0
                       2                   12                    0

  • Return multiple values from a function to a SELECT statement

    I hope I've provided enough information here. If not, just let me know what I'm missing.
    I am creating a view that will combine information from a few tables. Most of it is fairly straightforward, but there are a couple of columns in the view that I need to get by running a function within a package. Even this is fairly straightforward (I have a function named action_date in a package called rp, for instance, which I can use to return the date I need via SELECT rp.action_date(sequence_number).
    Here's the issue: I actually need to return several bits of information from the same record (not just action_date, but also action_office, action_value, etc.) - a join of the tables won't work here as I'll explain below. I can, of course, run a separate function for each statement but that is obviously inefficient. Within the confines of the view select statement however, I'm not sure how to return each of the values I need.
    For instance, right now, I have:
    Table1:
    sequence_number NUMBER(10),
    name VARCHAR(30),
    Table2:
    Table1_seq NUMBER(10),
    action_seq NUMBER(10),
    action_date DATE,
    action_office VARCHAR(3),
    action_value VARCHAR(60),
    I can't simply join Table1 and Table2 because I have to do some processing in order to determine which of the matching returned rows I actually need to select. So the package opens a cursor and processes each row until it finds the one that I need.
    The following works but is inefficient since all of the calls to the package will return columns from the same record. I just don't know how to return all the values I need into the SELECT statement.
    CREATE VIEW all_this_stuff AS
    SELECT sequence_number, name,
    rp.action_date(sequence_number) action_date,
    rp.action_office(sequence_number) action_office,
    rp.action_value(sequence_number) action_value
    FROM table1
    Is there a way to return multiple values into my SELECT statement or am I going about this all wrong?
    Any suggestions?
    Thanks so much!

    Hi,
    What you want is a Top-N Query , which you can do using the analytic ROW_NUMBER function in a sub-query, like this:
    WITH     got_rnum     AS
         SELECT     action_seq, action_dt, action_office, action_type, action_value
         ,     ROW_NUMBER () OVER ( ORDER BY  action_date
                                   ,            action_seq
                             ,            action_serial
                           ) AS rnum
         FROM     table2
         WHERE     action_code     = 'AB'
         AND     action_office     LIKE 'E'     -- Is this right?
    SELECT     action_seq, action_dt, action_office, action_type, action_value
    FROM     got_rnum
    WHERE     rnum     = 1
    ;As written, this will return (at most) one row.
    I suspect you'll really want to get one row for each group , where a group is defined by some value in a table to which you're joining.
    In that case, add a PARTITION BY clause to the ROW_NUMBER function.
    If you'd post a little sample data (CREATE TABLE and INSERT statements), I could show you exactly how.
    Since I don't have your tables, I'll show you using tables in the scott schema.
    Here's a view that has data from the scott.dept table and also from scott.emp, but only for the most senior employee in each department (that is, the employee with the earliest hiredate). If there happens to be a tie for the earliest hiredate, then the contender with the lowest empno is chosen.
    CREATE OR REPLACE VIEW     senior_emp
    AS
    WITH     got_rnum     AS
         SELECT     d.deptno
         ,     d.dname
         ,     e.empno
         ,     e.ename
         ,     e.hiredate
         ,     ROW_NUMBER () OVER ( PARTITION BY  d.deptno
                                   ORDER BY          e.hiredate
                             ,                e.empno
                           ) AS rnum
         FROM     scott.dept     d
         JOIN     scott.emp     e     ON     d.deptno     = e.deptno
    SELECT     deptno
    ,     dname
    ,     empno
    ,     ename
    ,     hiredate
    FROM     got_rnum
    WHERE     rnum     = 1
    SELECT     *
    FROM     senior_emp
    ;Output:
    .    DEPTNO DNAME               EMPNO ENAME      HIREDATE
            10 ACCOUNTING           7782 CLARK      09-JUN-81
            20 RESEARCH             7369 SMITH      17-DEC-80
            30 SALES                7499 ALLEN      20-FEB-81 
    By the way, one of the conditions in the query you posted was
    action_office     LIKE 'E'which is equivalent to
    action_office     = 'E'(LIKE is always equivalent to = if the string after LIKE doesn't contain any wildcards.)
    Did you mean to say that, or did you mean something like this:
    action_office     LIKE 'E%'instead?

  • Binding multiple values for a clause in a PreparedStatement

    Is there a way to bind multiple values for the same variable?
    Example: select * from catalog where catnum = ?
    and cat_num can be 12340-56, 23451-21 43211-00 etc.
    so the where condition really is:
    catnum in ('12340-56', '23451-21', '43211-00')
    Thanks for a lead!

    I've not been able to do this in a way I'd call clean. You might think you could do something like:// create a PreparedStatment with
    // the following String: select * from catalog where catnum in (?)"
    ps.setString(1, "'12340-56', '23451-21', '43211-00'");But the driver tends to escape the stuff you want to go "straight in" to your where clause. So I end up using Statement and building the SQL manually.
    I'd be interested in anyone else's solution
    Lee

  • Using if logic in the where clause of a select statement

    I have a select clause. And in the select clause there is a variable all_off_trt that can be 'Y' or 'N'.
    In the where clause I want to make it so that if a form variable is checked and all_off_trt is 'Y' then
    exclude it else if the form variable isn't checked then select it no matter what all_off_trt is.
    Is there any way to include either and if statement or a case statement within the where clause to acheive this? If not is there another way of doing it?
    Basically I am looking for a case statement like this
    case
    when all_off_trt = 'Y' and mail_para.code = 'Y' then false
    else true
    end
    Message was edited by:
    Tugnutt7

    Ok, so that really doesn't solve my problem. I have 3 different fields that I need to do that with. Each combining in a select statement to print an email list, as well as other thing limiting the where clause.
    This is currently what I have, tested and working 100%.
    cursor email_cur is
         select unique p.email,s.all_off_trt,s.all_deceased,s.no_enroll
    from participant p, trialcom t, ethics s
    where p.status='A'
    and p.surname=t.surname
    and p.initials=t.initials
    and s.trial_cd = t.tricom
    and s.centre = t.centre
    and p.email is not null
    and (t.centre in (select code from mail_parameters where user_name=user and mail_para='CENTRE')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='CENTRE'))
    and (t.tricom in (select code from mail_parameters where user_name=user and mail_para='TRIAL')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='TRIAL'))
    and (t.role in (select code from mail_parameters where user_name=user and mail_para='ROLE')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='ROLE'))
    and (p.country in (select code from mail_parameters where user_name=user and mail_para='COUNTRY')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='COUNTRY'))
    and (t.represent in (select code from mail_parameters where user_name=user and mail_para='REPRESENT')
    or 'XX' in (select code from mail_parameters where user_name=user and mail_para='REPRESENT'));
    This is in a program unit that runs when a button is clicked. At the end of that I need to add on the 3 case statements that help further narrow down the selection of emails to be printed. Then it prints the emails selected from this statement into a file. So it has to be done right in the select statement. The three table variables are the all_off_trt, all_deceased, and no_enroll. The form has 3 checkboxes. One for each, that when checked (giving the variable associated with the checkboxes a value of 'Y') excludes all emails that have a 'Y' in the coresponding table variable.

  • Referencing Aggregated Column Value in Where Clause

    Hello -
    I'm trying to determine how I can accomplish the following in the most straightforward, efficient way.
    Among other things, I'm selecting the following value from my table:
    max(received_date) as last_received_dateI also need to evaluate the "last_received_date" value as a condition in my where clause. However, I can't reference my aliased "last_received_date" column value, and when I try to evaluate max(received_date) in the where clause, I get the "group function is not allowed here" error.
    Does anyone know of a good workaround?
    Thanks,
    Christine

    Hi,
    Column aliases can be used in the ORDER BY clause: aside from that, they cannot be used in the same query where they are defined. The workarounds are
    (a) define the alias in a sub-query, and use it in a super-query, like Someoneelse did, or
    (b) repeat the aliased expression, as in the HAVING-clause, below.
    Aggregate functions are computed after the WHERE-clause. (That explains why you can do things like
    SELECT  MAX (received_date) last_received_date_2008
    FROM    table_x
    WHERE   TO_CHAR (received_date, 'YYYY')  = '2008';).
    The HAVING-clause is like the WHERE-clause, but it is applied after the aggregate functions are computed, e.g.
    SELECT    deptno
    ,         MAX (recieved_date)  AS last_received_date
    FROM      table_x
    GROUP BY  deptno
    HAVING    MAX (received_date)    > SYSDATE - 7   -- Only show deptartments with activity in the last week
    ;

Maybe you are looking for

  • Como alterar o título dos menus Drag & Relate? (Urgente)

    Prezados, Alguém poderia me auxiliar se é possível ou não alterar o título das linhas do menu Drag & Relate? Uma vez que eles não são tratados como Menu, ou sejam, não possuem um MenuID, para fazer a alteração como a de um menu padrão. Alguém já pass

  • Travel Adapter Over Heating to 121 degrees F.

    Hello, has anyone else had problems with an HP EnVY overheating?  The first machine I ordered burned up in 20 days.  So 42 days later I recieved another.   Now, the power adapter is overheating to 128 degrees.    It is called "Travel Adapter" HP part

  • Master data extraction from R/3

    hi all, i'm getting issue while activating master data for listing conditions. under RSA5 in R/3, i've activiated and transferred 0RT_WLK1_ATTR datasource. In RSA6 same is transported. but when i check for data in RSA3 0 records are found. the extrac

  • Adobe 9 standard print preview not updating

    I am having a issue with Adobe 9 stardard on win7 64bit. The issue is happening on more then on pc. The issue is, when the page size is changed in the print menu, by clicking the properties button. The preview of the document does not update to the p

  • ITunes will only play 1 song

    Downloaded 10.2.2 iTunes yesterday. Now, when I open iTunes, click on a song, that's the only song that will play. If I highlight another song to play it, the song will highlight in blue , but will never play. If I close and reopen iTunes, I can clic