Select Query where multiple col1+col2 in ('value1','value2','value3')

hello,
i've table :
month year .. other columns
1 2012
2 2012
1 2013
2 2013
1 2014
2 2014
I've multi select filter years, then months of these years as
1-year checkcombobox - all available years on the table. ex(2012,2013..)
2-month checkcombobox - all months for selected years above. ex(1-2013,2-2013..)
i want to select from my table where month & year = selected month & year. 
i used to do it like this : but i think i've problem with performance with this solution:
i use stored procedure with @monthyear nvarchar(max) parameter of selected months and year as text like '1-2012,2-2012,6-2013'
-i use 'uf_ParseDelimitedString2' function to extract above string into table of string.
the query:
select from mytable where convert(nvarchar(10),mytable.month) + '-' + convert(nvarchar(10),mytable.year) in (select string from uf_ParseDelimitedString2(@monthyear))
-function i used on above query to Parse Delimited String and return table of string.
ALTER FUNCTION [dbo].[uf_ParseDelimitedString2](@strToParse VARCHAR(MAX)) RETURNS @tblStrToParse TABLE
(string nvarchar(max))
AS
BEGIN
DECLARE @pos int
DECLARE @piece nvarchar(max)
-- Need to tack a delimiter onto the end of the input string if one doesn't exist
IF RIGHT(RTRIM(@strToParse),1) <> ','
SET @strToParse = @strToParse + ','
SET @pos = PATINDEX('%,%' , @strToParse)
WHILE @pos <> 0
BEGIN
SET @piece = left(@strToParse, @pos - 1)
-- You have a piece of data, so insert it, print it, do whatever you want to with it.
INSERT INTO @tblStrToParse VALUES(@piece)
SET @strToParse = STUFF(@strToParse, 1, @pos, '')
SET @pos = patindex('%,%' , @strToParse)
END
RETURN
END
thank your in advance ..

hi.. 
review this after i created a function:
create FUNCTION [dbo].[uf_ParseDelimitedString2Col](@t VARCHAR(MAX))
RETURNS @tblStrToParse TABLE
([1] int ,[2] int)
AS
BEGIN
insert into @tblStrToParse
SELECT [1], [2]
FROM (
SELECT
t2.id
, t2.name
, rn2 = ROW_NUMBER() OVER (PARTITION BY t2.id ORDER BY 1/0)
FROM (
SELECT
id = t.c.value('@n', 'INT')
, name = t.c.value('@s', 'nvarchar(20)')
FROM (
SELECT x = CAST('<t s = "' +
REPLACE(token + '-', '-', '" n = "' + CAST(rn AS VARCHAR(10))
+ '" /><t s = "') + '" />' AS XML)
FROM (
SELECT
token = t.c.value('.', 'VARCHAR(100)')
, rn = ROW_NUMBER() OVER (ORDER BY 1/0)
FROM (
SELECT x = CAST('<t>' + REPLACE(@t, ',', '</t><t>') + '</t>' AS XML)
) r
CROSS APPLY x.nodes('/t') t(c)
) t
) d
CROSS APPLY x.nodes('/t') t(c)
) t2
WHERE t2.name != ''
) t3
PIVOT (
MAX(name) FOR rn2 IN ([1], [2])
) p
Return
END
then 
i used this code.. 
select * from mytable st cross apply dbo.uf_ParseDelimitedString2Col('1-2014,3-2014') x where st.month = x.[1] and st.year = x.[2]
how about that..
thank you.

Similar Messages

  • Select Query where multiple column in multiple values (cant use in clause)

    I can use (in clause) with on column like this:
    Select code from table where code in(1,2,3)
    -------------------------------My case:-------------------------------------------------
    I’ve 4 columns PK of table as below 
    I need to :
    select
    where (code, month, year) in ((1,1,2013) and (2,1,2014) and (2,2,2015))
    i can't write it this way :
    select where code in (1,2) and month in (1,2) and year in (2013,2014,2015)
    case i'll get my rows but others included like (1,1,2015) , (1,1,2014),(2,1,2013) .. etc
    I’m terribly want to solve this problem
    Please help me
    Code (pk)
    Month (pk)
    Year (pk)
    emp_code(pk)
    1
    1
    2013
    101
    1
    1
    2013
    102
    2
    1
    2013
    101
    2
    1
    2013
    102
    1
    2
    2013
    101
    1
    2
    2013
    102
    2
    2
    2013
    101
    2
    2
    2013
    102
    1
    1
    2014
    101
    1
    1
    2014
    102
    2
    1
    2014
    101
    2
    1
    2014
    102
    1
    2
    2014
    101
    1
    2
    2014
    102
    2
    2
    2014
    101
    2
    2
    2014
    102
    1
    1
    2015
    101
    1
    1
    2015
    102
    2
    1
    2015
    101
    2
    1
    2015
    102
    1
    2
    2015
    101
    1
    2
    2015
    102
    2
    2
    2015
    101
    2
    2
    2015
    102
    thank you

    In T-SQL you have to use OR-ed predicates. 
    In full ANSI Standard SQL youcan write row comparisons  (a,b,c) = (1,2,3) etc! but not in T-SQL dialect. Ignoring that problem, what you have is a design flaw called attribute splitting; you have put one unit of measurement
    in two columns. 
     I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the
    ISO-8601 data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • SELECT query from multiple databases

    Hi,
    Is it possible to run a SELECT query using multiple DBs' tables, like outer joining them. One of the DBs is Sybase.
    Thanks in advance

    A TopLink session can span multiple databases if they can be accessed through a single connection. A single select would require the database to handle the aggregation as mentioned in the other post.
    Alternatively TopLink's session broker will support making a single session present persistent types from multiple independent databases. This approach will not support a single SELECT spanning the databases though.
    Doug

  • Slow Select Query - Where clause contains Seconday index field +other flds

    Hi friends,
    The below query is taking about an Hour to execute in production server when there are about 6 Million records in PLAF table. I have verified the trace in ST05 and the correct secondary index (Material Matnr + Plant Plwrk) is being selected.
    SELECT plnum
                 matnr
                 plwrk
                 pedtr
                 dispo
                 rsnum  FROM  plaf
                INTO TABLE it_orders
                WHERE ( ( matnr  IN r_mat1 )  OR
                                 matnr IN r_mat2  AND dispo IN s_mrp1 ) AND
                 pedtr IN s_date AND   
                 obart = '1'.
    Will it be a good idea to have only MATNR (secondary index field) in the where condition of the select query and delete the internal table entries for the other where conditions ?
    Edited by: Shruthi Seth on Feb 1, 2009 10:10 AM

    Hello.
    Creating a range r_mat = r_mat1 + r_mat2, I would do something like:
    READ TABLE s_mrp1 TRANSPORTING NO FIELDS INDEX 1.
    IF sy-subrc EQ 0.
      SELECT plnum matnr plwrk pedtr dispo rsnum
        FROM plaf
        INTO wa_orders
       WHERE matnr IN r_mat
         AND pedtr IN s_date
         AND obart = '1'.
        IF wa_orders-matnr IN r_mat2.
          CHECK wa_orders-dispo IN s_mrp1.
        ENDIF.
        APPEND wa_orders TO it_orders.
      ENDSELECT.
    ELSE.
      SELECT plnum matnr plwrk pedtr dispo rsnum
        FROM plaf
        INTO TABLE it_orders
       WHERE matnr IN r_mat1
         AND pedtr IN s_date
         AND obart = '1'.
    ENDIF.
    Regards,
    Valter Oliveira.

  • Pure SQL of Select query on multiple tables in DB Adapter

    I am trying use pure sql approach for a custom sql query on multiple tables for a DB adapter by modifying toplink_mappings.xml. But i am not getting other tables in my xsd. Please help.

    hi Ravi,
    can you pls be a bit clear? what is this about? where you are using?
    thanks,
    sneha.

  • Select query where codn

    Hi in my requirement in a select query i have to place a where codn using asset value date.Actually the asset value date has from date and end date.The from date is present in a table and end date is present in another table so now how to put the where codn.Please give some suggestions.

    Hi hema,
    Use subquery as follows;
    Select.....
    .....Where asset_date BETWEEN (Select single asset_fromdate from fromdate_table where key_field = value) AND (Select single asset_todate from todate_table where key_field = value)
    Hope this helps you...
    Regards
    Karthik D

  • Running a Select query against multiple sql servers using SSIS script task.

    Hi Guys,
    I need to fetch data from multiple sql servers using  SSIS scirpt task inside a foreach container.
    is there anyway i can build dynamic sql connections using ssis variables inside SSIS script task in each loop
    Please guide me or refer any blogs so that i will try..
    Thanks in advance.

    Your only options is using .net code, then it will be no different than using a console app in a loop.
    using (SqlConnection connection = new SqlConnection(connectionString))
    connection.Open();
    Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
    Console.WriteLine("State: {0}", connection.State);
    and so forth for each connection string
    the connection string would come from the ForEach loop
    Arthur My Blog

  • 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.

  • URGENT: To change the where condition in select query at runtime ?

    Hi,
    I have to develop a report, 4 which I have created a selection screen with 7 Input Parameters whose value is to be filled by the user while executing the report.
    On the basis of this I do the desired selection of output.
    But the problem is that how do I write my select Query(where condition) if the user enetrs only 2 Input parameters or 3 or whatever he feels like.
    Pls help me out...

    hi,
    check this sample code.
    Here i am populating where condition at runtime.
    DATA: V_WHERE TYPE STRING.
    SELECTION-SCREEN BEGIN OF BLOCK INPUT WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN,
                     S_ERDAT FOR VBAK-ERDAT.
    SELECTION-SCREEN END OF BLOCK INPUT.
    START-OF-SELECTION.
      PERFORM POPULATE_WHERE.
      PERFORM GET_VBAK_DATA.
    *&      Form  POPULATE_WHERE
    *       Populate Where
    FORM POPULATE_WHERE .
      IF NOT S_ERDAT[] IS INITIAL.
        CONCATENATE 'VBELN IN S_VBELN'
                    'AND'
                    'ERDAT IN S_ERDAT'
              INTO V_WHERE
              SEPARATED BY SPACE.
      ELSE.
        V_WHERE = 'VBELN IN S_VBELN'.
      ENDIF.
    ENDFORM.                    " POPULATE_WHERE
    *&      Form  GET_VBAK_DATA
    *       GET VBAK DATA
    FORM GET_VBAK_DATA .
      SELECT VBELN
             ERDAT
             VBTYP
             NETWR
             WAERK
             VKORG
             VTWEG
             SPART
        INTO CORRESPONDING FIELDS OF TABLE IT_VBAK
        FROM VBAK
        WHERE VBELN IN S_VBELN
        AND   ERDAT IN S_ERDAT.
       WHERE (V_WHERE).
    endform.
    Regards
    Sailaja.

  • How to filter rows where multiple columns meet criteria, ignoring rows where only some columns meet criteria

    Hi All,
    Question: How do I filter rows out of a query where multiple columns are equal to a single question mark character?
    Background: I'm using SQL 2008 R2.  Furthermore, the part of my brain that helps me create less-than-simple queries hasn't been working for the last 4 days, apparently, and now I need help.
    We have about 4,000 rows in a table.  This data set was generated from an exported report, and many of the rows in the detail table were not actual data rows but were simply "header" rows.  For those table rows, most of the columns have
    a single question mark as the value.
    Some of the detail rows have one or more question mark values, too, so it's important that these rows don't get filtered out.
    When I include criteria like "WHERE col1 <> '?' AND col2 <> '?' AND col3 <> '?' AND col4 <> '?'", all rows with a question mark value for even a single one of those columns get filtered out.  How do I filter out rows
    where all columns 1-4 contain a question mark value?
    Thanks for your help,
    Eric

    I just tried to create to create a scenario for you. Please see ig you're looking for something like this.
    Create table test_Question_mark
    RecordID INT identity(1,1),
    Col1 varchar(10),
    Col2 varchar(10),
    Col3 varchar(10),
    Col4 varchar(10),
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','?','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','??','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','??','??','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','??','??','??')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','?','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','test ??','??','??')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','test ?','??','??')
    --drop table test_Questio_mark
    select * from test_Question_mark
    select * from test_Question_mark 
    WHERE 
    (CHARINDEX('?', Col1,1) > 0 AND CHARINDEX('?', Col1, CHARINDEX('?', Col1,1)+1) = 0) AND 
    (CHARINDEX('?', Col2) > 0 AND CHARINDEX('?', Col2, CHARINDEX('?', Col2,1)+1) = 0) AND 
    (CHARINDEX('?', Col3,1) > 0 AND CHARINDEX('?', Col3, CHARINDEX('?', Col3,1)+1) = 0) AND 
    (CHARINDEX('?', Col4,1) > 0 AND CHARINDEX('?', Col4, CHARINDEX('?', Col4,1)+1) = 0) 
    --drop table test_Questio_mark
    I hope above solution will help.
    Thanks!
    Ashish.

  • Strange results with Insert statement having select query

    Hi all,
    I am facing a strange issue with Insert statement based on a select query having multiple joins.
    DB- Oracle 10g
    Following is the layout of my query -
    Insert into Table X
    Select distinct Col1, Col2, Col3, Col4, Function(Col 5) from Table A, B
    where trunc(updated_date) > = trunc(sysdate-3)
    and join conditions for A, B
    Union
    Select Col1, Col2, Col3, Col4, Function(Col 5) from Table C, D
    trunc(updated_date) > = trunc(sysdate-3)
    and join conditions for C, D
    Union
    .... till 4 unions. all tables are residing in the local Database and not having records more than 50,000.
    If I execute above insert in a DBMS job, it results into suppose 50 records where as if I execute the select query it gives 56 records.
    We observed following things-
    a) no issue with size of tablespace
    b) no error while inserting
    c) since query takes lot of time so we have not used Cursor and PLSQL block for inserting.
    d) this discrepancy in number of records happens frequently but not everytime.
    e) examined the records left out from the insert, there we couldn't find any specific pattern.
    f) there is no constraint on the table X in which we are trying to insert. Also tables A, B, C....
    I went through this thread -SQL insert with select statement having strange results but mainly users are having either DB Links or comparison of literal dates, in my case there is none.
    Can somebody explain why is the discrepancy and what is the solution for it.
    Or atleast some pointers how to proceed with the analysis.
    Edited by: Pramod Verma on Mar 5, 2013 4:59 AM
    Updated query and added more details

    >
    Since I am using Trunc() in the where clause so timing should not matter much. Also I manually ruled out records which were updated after the job run.
    >
    The first rule of troubleshooting is to not let your personal opinion get in the way of finding out what is wrong.
    Actually this code, and the process it represents, is the most likely CAUSE of the problem.
    >
    where trunc(updated_date) > = trunc(sysdate-3)
    >
    You CANNOT reliably use columns like UPDATED_DATE to select records for processing. Your process is flawed.
    The value of that column is NOT the date/time that the data was actually committed; it is the date/time that the row was populated.
    If you insert a row into a table right now, using SYSDATE (8am on 3/5/2013) and don't commit that row until April your process will NEVER see that 3/5/2013 date until April.
    Here is the more typical scenario that I see all the time.
    1. Data is inserted/updated all day long on 3/4/2013.
    2. A column, for example UPDATED_DATE is given a value of SYSDATE (3/4/2013) in a query or by a trigger on the table.
    3. The insert/update query takes place at 11:55 PM - so the SYSDATE values are for THE DAY THE QUERY BEGAN
    4. The data pull begins at 12:05 am (on 3/5/2013 - just after midnight)
    5. The transaction is COMMITTED at 12:10 AM (on 3/5/2013); 5 minutes after the data pull began.
    That data extract in step 4 will NEVER see those records! They DO NOT EXIST when the data pull query is executed since they haven't been committed.
    Even worse, the next nights data pull will not see them either! That is because the next pull will pull data for 3/5/2013 but those records have a date of 3/4/2013. They will never get processed.
    >
    Job timing is 4am and 10pm EST
    >
    Another wrinkle is when data is inserted/updated from different timezones and the UPDATED_DATE value is from the CLIENT pc or server. Then you can get even more data missed since the client dates may be hours different than the server date used for the data pull process.
    DO NOT try to use UPDATED_DATE type columns to do delta extraction or you can have this issue.

  • Nested table collection in select query "in clause" taking long time

    create or replace type t_circuitids is table of varchar2(100);
    --Below anonymous block keeps on running and never ends
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (v_circuitid));
    END;
    --I got the issue, query "SELECT COLUMN_VALUE FROM TABLE (v_circuitid)" which is used in above code is responsible for this.
    --Same code works fine in Development and Test environments, But in prod it keeps on running
    --I solved this issue by creating a temp table, loading all values in collection into the temp table and using that temp table in "in clause"    "
    --Can any one answer why its behaving like this when i use collection in where clause?
    --I am using Oracle 9i

    Below is the code i used
    DECLARE
       v_circuitid    t_circuitids;
       v_count number;
       l_circuitids   VARCHAR2 (4000)
          := 'value1,value2,value3,value4,value5';
    BEGIN
    --Below query converts comma concatinated output to list and stores in nested table collection v_circuitids
       WITH a AS
            (SELECT ',' || l_circuitids || ',' AS circuitid
               FROM DUAL)
       SELECT DISTINCT TRIM (SUBSTR (circuitid,
                                     INSTR (circuitid, ',', 1, LEVEL) + 1,
                                       INSTR (circuitid, ',', 1, LEVEL + 1)
                                     - INSTR (circuitid, ',', 1, LEVEL)
                                     - 1
                            ) cid
       BULK COLLECT INTO v_circuitid
                  FROM a
            CONNECT BY LEVEL <
                             LENGTH (circuitid)
                             - LENGTH (REPLACE (circuitid, ','));
       SELECT COUNT (1)
         INTO v_count
         FROM table
        WHERE name IN (SELECT COLUMN_VALUE
                                          FROM TABLE (ccard(v_circuitid)));
    END;
    And got below error
    ORA-06550: line 27, column 5:
    PL/SQL: ORA-00906: missing left parenthesis
    ORA-06550: line 24, column 4:
    PL/SQL: SQL Statement ignored

  • Problem in select query in QUERY INFOSET

    Hi All
    I have requirement to find the sales text maintained for sales order in mass in production. By using the FM READ_TEXT i can pass the necessary values to get the sales text. We dont want to write a program and then transprot to P01. So what i did in SQ02 i create a infoset and worte code in the infoset. Here i am facing the problem that in the select query where clause what ever  on the selection screen values, for that the query need to fetch the records. But selection screen is dymically selected based on SQVI t-code.
    In select query if i write like this
    SELECT TDOBJECT TDNAME TDID TDSPRAS
           FROM STXH
           INTO TABLE IT_TEXT_DETAIL
           WHERE TDOBJECT     EQ C_KNMT .
    Here i have hardcoded KNMT so it will fetch only that value irrespective of any values on the selection screen. How to get the values based on the selection screen. I debugged the query it automatically generates the code for selection screen which i am not able to pass in the program.
    SAP has generated this code
    select-options SP$00004 for STXH-TDOBJECT.
    select-options SP$00005 for STXH-TDNAME.
    select-options SP$00006 for STXH-TDID.
      If i pass SP$00004 on where clause its giving me error. So how to pass it dynamically. Waiting for experts answer.
    Regards
    Vijay

    Hi Vijay,
    In this case concatenate 'TDOBJECT' 'EQ' C_KNMT INTO V_WHERE (Say) SEPERATED BY SPACE.
    DATA : v_where(90) type c.
    clear v_where.
    CONCATENATE  'TDOBJECT'
                               'EQ'
                               C_KNMT
                               INTO V_WHERE
                               SEPERATED BY SPACE.
    SELECT TDOBJECT TDNAME TDID TDSPRAS
           FROM STXH
           INTO TABLE IT_TEXT_DETAIL
           WHERE (V_WHERE) .
    Try to do this and let me know in case of any.
    Regards,
    SRinivas

  • Dynamic From statement in select query and/or outer join not working

    Dear Experts, I have a select query where the select columns are dynamic, the where condition is also dynamic. It is of the below format:
    Select (dynamic columns) INTO <wa>
    FROM a inner join b on af1 = bf1
    inner join c on af2 = cf2......
    WHERE (dynamic conditios)
    ORDER BY ( dynamic sort condition).
    Now I have to include some tables (dynamically depending on the user input) in the inner join statement which will give description for the selected fields. And these database tables may or may no be empty. So in this case, my select query will not return any data if these tables are empty. And I dont want that.
    I tried using outer join for the extra tables but it gave me a runtime error. I also tried forming the inner join statement dynamically but it was not supporting.
    Kindly give me pointers.
    Thanks

    Hey thanks for the reply, but the problem is not solved.
    I am already using  ( fileds, value) like table in my where condition and the select statement was working properly.
    the problem is that now I have to include some tables in the join statement which can be empty and so i want to use Outer join.
    But I am getting a runtime error as below:
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SYNTAX', was not
         caught in
        procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a
         RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        The running ABAP program wanted to execute a SELECT statement whose
        WHERE condition was (partly) specified dynamically. The part that is
        specified in an internal table at runtime is compared to a field of the
        right table of an LEFT OUTER JOIN. Such comparisons are not supported by
         all database systems and are therefore not allowed.

  • Varray in the select query

    Hi ,
    Can we write a select query where we can pass varray in the where condition.
    I have this query in my stored procedure.
    eg :
    SELECT * from emp
         WHERE deptno in l_data1;
    where l_data is varray of type varchar2(40) where I have all the deptno in l_data.
    Thanks.

    This is business requirement.
    Here is my code.
    create or replace PROCEDURE getAttribute (p_product_model varchar2)
    AS
    l_data pattern_str_type := pattern_str_type();
    l_count NUMBER;
    l_child_name VARCHAR2(200);
    l_product_model VARCHAR2(40);
    l_data1 getAttrforModel := getAttrforModel();
    i NUMBER;
    BEGIN
    i := 1;
    l_data :=getattr();
    for i in 1 .. l_data.count loop
    l_data.extend;
    l_data1.extend;
    if(l_data(i).child_type = 'Attribute' and l_data(i).product_model_name <> p_product_model)THEN
    l_data1(i):=l_data(i).child_name;
    dbms_output.put_line(l_data1(i));
    END If;
    end loop;
    SELECT count(*) into l_count from
         WOC_ATTRIBUTE_CATEGORY WHERE category_name = 'Software' and Attribute_Name in l_data1;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE;
    END ;
    CREATE OR REPLACE FUNCTION getAttr RETURN pattern_str_type
    IS
    l_data pattern_str_type := pattern_str_type();
    l_count NUMBER;
    l_child_name VARCHAR2(200);
    l_product_model VARCHAR2(40);
    i NUMBER;
    cursor getattr IS select child_name,child_type, product_model_name from woc_pattern_Structure;
    BEGIN
    i := 1;
    for rec in getattr loop
    l_data.extend;
    l_data(i) := temp_table(rec.child_name,rec.child_type,rec.product_model_name);
    --dbms_output.put_line(l_data(i).child_name||' '||l_data(i).child_type||' '||l_data(i).product_model_name);
    i := i + 1;
    end loop;
    RETURN l_data;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE;
    END ;

Maybe you are looking for

  • Create PDF document from Word with hyperlink index entries

    Hello, I'm having a MS Word 2010 document with a content and index directory, both directories were created with the official Word functions and their page numbers are updated automatically. If I convert this document to a PDF file with Acrobat 9 Pro

  • Can't print a pdf file

    I have a all in one HP 6700 printer and I can't print a pdf file

  • How to put a variable column value in a "vlookup"

    Hello there, I am trying to put a variably chosen column value in a "vlookup" function. Logically this should work, but it does not, and I cannot figger out why.: "=vloookup("a", B5:Z28, {=MATCH(4, B4:Z4, 0)})" (replaced brackets with {} for this pos

  • Where is the SOAP Payloads of XI Message in host?

    Hi to all,    I'm trying to find the XML documents(SOAP Payloads of XI Message) in PI host. Anybody knows which file include this files?     Look forward your help!    Thanks!

  • How can I update LabView6.0 to LabView6.1 in the website?

    Hi, I have purchased LabView6.0 and created a project successfully.In my opinion,LabView is a useful software for engineers.But I have met with some problem these days.I find some examples in the website but their version is LabView6.1.Must I purchas