Where clause with XMLExists and join to another table

Hello

We have table as:

drop table xml_tbl;

create table xml_tbl)
whole xml_msg_id
xmltype xml_msg_text
);

insert into xml_tbl values
(1, "< principal > < id > 1 < /ID > < / hand > '");

insert into xml_tbl values-(xml_msg_id, xml_msg_text)
(1, "< principal > < id > 2 < /ID > < / hand > '");


Another table like:

create the table1 Table:
(id1 int);

Insert into Table1 values (2);
Insert into Table1 values (3);

We need to have a view on top of the table xml_tbl where/hand/IDs should only have the values located in id1 column of the Table1 table.

Something like

CREATE OR REPLACE VIEW V_xml_tbl
(
xml_msg_text
)
AS
SELECT T.xml_msg_text
OF xml_tbl T
WHERE (XMLEXISTS)
' declare namespace Namesp1 = "Abc: Set";
Let $Results as XS: Boolean: = fn:exists($p/main/id_in_(Select_id1_from_Table1))-now, here I know that I can't select id1 of

Table 1
return if ($Results) then true() (else)"
PASSAGE T.xml_msg_text AS 'p');


In fact, in the scenario real Table1 will have several IDs and xml_tbl a lot of XML files...
So I'm stuck on how to do it. Help, please.

Thank you...

Published by: user8941550 on November 20, 2012 19:19

One of these two:

SQL> select t.xml_msg_text
  2  from xml_tbl t
  3  where exists (
  4    select null
  5    from table1 t1
  6    where t1.id1 = xmlcast(
  7                     xmlquery('/main/id' passing t.xml_msg_text returning content)
  8                     as integer
  9                   )
 10  );

XML_MSG_TEXT
--------------------------------------------------------------------------------
2

SQL> select t.xml_msg_text
  2  from xml_tbl t
  3     , xmltable('/main' passing t.xml_msg_text
  4         columns id integer path 'id'
  5       ) x
  6  where exists (
  7    select null
  8    from table1 t1
  9    where t1.id1 = x.id
 10  );

XML_MSG_TEXT
--------------------------------------------------------------------------------
2

And a third, using XMLExists:

SQL> select t.xml_msg_text
  2  from xml_tbl t
  3  where xmlexists (
  4    'fn:collection("oradb:/DEV/TABLE1")/ROW[ID1=$d/main/id]'
  5    passing t.xml_msg_text as "d"
  6  );

XML_MSG_TEXT
------------------------------------------------------------------------------------------------------------------------
2
Execution Plan ---------------------------------------------------------- Plan hash value: 3633580934 ------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 2 | 116 | 8 (0)| 00:00:01 | |* 1 | FILTER | | | | | | | 2 | TABLE ACCESS FULL | XML_TBL | 2 | 116 | 3 (0)| 00:00:01 | | 3 | NESTED LOOPS | | 1 | 5 | 5 (0)| 00:00:01 | | 4 | TABLE ACCESS FULL| TABLE1 | 2 | 6 | 3 (0)| 00:00:01 | |* 5 | XPATH EVALUATION | | | | | | ------------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter( EXISTS (SELECT 0 FROM "DEV"."TABLE1" "SYS_ORAVW_2",XPATHTABLE('/main/id' PASSING :B1 COLUMNS "C_00$" XMLTYPE PATH '.', "C_01$" XQEXVAL CHAR PATH '.') "P" WHERE TO_BINARY_DOUBLE("ID1")=TO_BINARY_DOUBLE("P"."C_01$"))) 5 - filter(TO_BINARY_DOUBLE("ID1")=TO_BINARY_DOUBLE("P"."C_01$"))

The plan is similar to that of the second query above (XMLTable/EXISTS).

Still using XMLExists, a plan similar to the first query (EXISTS, XMLCast, XMLQuery) can be achieved by id of casting to an integer data type:

SQL> select t.xml_msg_text
  2  from xml_tbl t
  3  where xmlexists (
  4    'fn:collection("oradb:/DEV/TABLE1")/ROW[ID1=xs:int($d/main/id)]'
  5    passing t.xml_msg_text as "d"
  6  );

XML_MSG_TEXT
------------------------------------------------------------------------------------------------------------------------
2
Execution Plan ---------------------------------------------------------- Plan hash value: 1149640166 ------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 61 | 7 (15)| 00:00:01 | |* 1 | HASH JOIN SEMI | | 1 | 61 | 7 (15)| 00:00:01 | | 2 | TABLE ACCESS FULL| XML_TBL | 2 | 116 | 3 (0)| 00:00:01 | | 3 | TABLE ACCESS FULL| TABLE1 | 2 | 6 | 3 (0)| 00:00:01 | ------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 1 - access("ID1"=SYS_XQ_ATOMCNVCHK(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQ EXVAL(SYS_XQEXTRACT(SYS_MAKEXML(0,"T"."SYS_NC00003$"),'/main/id'),1,50,3 3792,8192),50,1,0)),2,37)) Note ----- - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)

Check each on your real-world scenario to see that present better performance.
(I would say those involving streaming of assessment)

Published by: odie_63 on 5 nov. 2012 12:24

Published by: odie_63 on 5 nov. 2012 12:38

Tags: Database

Similar Questions

  • Add a simple table without one logical join to another table (OBIEE 10 g)

    Sometimes I want to just show a simple table without a logical join to another table in the repository. However, every time I move the layer Business model and mapping and an audit of overall coherence, he tells me that he has a logical join and I am forced to create another table to join her. Creating a dimension-fact relationship. There are times where I need this relationship and I want to just display some data. Is anyway to circumvent this?

    Thanks in advance!

    Yes, you must create a join. You can't take one table to MDB layer. You can create an alias for the table. Join this alias and the base through any common column table and take the two tables in MDB and table you want to the presentation layer.

    Another way is to create a view in the physical layer. Write a select statement as

    Select Table primary_key

    Where primary_key is the primary key of the base table. Join the base table of view ith and repeat the steps defined for the Alias.

    Kind regards
    Sandeep

  • "Invalid column" on the place where several clauses with subqueries and cfqueryparam

    I see a behavior in the cfquery coldfusion I would like to find an exmplanation for.  I have a query that performs a subquery in the select part and if I have several where lines, I get a message 'invalid column name' to find out where my second article, but only when I'm with cfqueryparam

    For example, on what follows, I get "invalid column name «position_id»»

    SELECT department_staff_tbl.*,
    (SELECT max (bookmark_id)
    OF bookmarked_items_tbl
    WHERE item_id = department_staff_tbl.staff_id

    ) AS bookmark_id
    OF department_staff_tbl
    WHERE department_id = < cfqueryparam value = "" #arguments.deptid # "cfsqltype ="cf_sql_integer">"
    AND position_id = < cfqueryparam value = "" #arguments.posid # "cfsqltype ="cf_sql_integer">"
    AND staff_id = < cfqueryparam value = "" #arguments.staffid # "cfsqltype ="cf_sql_integer">"

    If I change the order of my where clause staff_id is first, and then he said "department_id" is an invalid column.

    If I don't have a where clause, it works.  (i.e. WHERE position_id = < cfqueryparam value = "" #arguments.posid # "cfsqltype =" cf_sql_integer">).

    If I remove the where clause of my subquery (WHERE item_id = department_staff_tbl.staff_id) it works.

    This also works if I remove the cfqueryparam where my article so that my query looks like this:

    SELECT department_staff_tbl.*,
    (SELECT max (bookmark_id)
    OF bookmarked_items_tbl
    WHERE item_id = department_staff_tbl.staff_id

    ) AS bookmark_id
    OF department_staff_tbl
    WHERE department_id = #arguments.deptid #.
    AND position_id = #arguments.posid #.
    AND staff_id = #arguments.staffid #.

    Any thoughts?

    A more conventional way to enter your data is without the subquery.  Something like that

    Select fields, the bookmarkid max (bookmark_id)

    from bookmarked_items__tbl join department_staff_tbl on staff_id = bookmark_id

    When etc.

    Some field group

  • Passing the value of the where clause with the page

    Dear friends,

    I have a requirement like when I select a selection list value I should pass this value to sql query where clause without submitting the page

    ex I have a select like: P1_Dept guess I selects the value 10 in this

    then I have a query select * from emp where deptno =: P1_Dept.

    DB. ORACLE 11G

    APEX 4.1.1.00.23

    is this possible? can someone help me please in this topic

    Thanks and greetings

    Vballeda

    Suppose we have the selection list with the name P1_DEPT and query for report

    select * from emp where deptno = :P1_DEPT
    

    We create dynamic Action on the evolution of the P1_DEPT point. We will need two real actions:

    1-> set value action

    Set the Type - > body of the PL/SQL function

    The function of body - > return 1;

    Page item to submit-> P1_DEPT

    Change to delete-> Yes event

    Selecttion Type-> trigger element

    2. action-> Refresh

    Selecttion Type-> region

    Region-> your region of report

  • Faced with subqueries and JOINS - possible syntax error.

    Hi all

    I'm having a nightmare getting this query to run in Oracle SQL Developer.
    REM (HIGHEST EARNING EMPLOYEE in each LOCATION excluding MANAGERS/SALESPEOPLE/PRESIDENT)
    
    
    CREATE OR REPLACE VIEW HIGHEST_EARNER_PER_LOCATION
    AS
       SELECT EMPLOYEE_NAME, L.REGIONAL_GROUP AS REGIONAL_GROUP, E.SALARY AS SALARY, J.JOB_ID AS JOB_ID
         FROM (  SELECT E.FIRST_NAME || ' ' || E.LAST_NAME AS EMPLOYEE_NAME,
                        L.REGIONAL_GROUP REGIONAL_GROUP
                   FROM EMPLOYEE E
                        LEFT OUTER JOIN DEPARTMENT D
                           ON D.DEPARTMENT_ID = E.DEPARTMENT_ID
                        LEFT OUTER JOIN LOCATION L 
                           ON L.LOCATION_ID = D.LOCATION_ID
                        LEFT OUTER JOIN JOB J 
                           ON J.JOB_ID = E.JOB_ID
               GROUP BY E.FIRST_NAME || ' ' || E.LAST_NAME)
        WHERE JOB_ID != '670' AND JOB_ID != '671' AND JOB_ID != '672'
    ;
    SELECT
      EMPLOYEE_NAME,
      REGIONAL_GROUP,
      SALARY
    FROM
      HIGHEST_EARNER_PER_LOCATION
    ORDER BY REGIONAL_GROUP DESC
    ;
    She just keeps throwing the error:
    Error at Command Line:17 Column:50
    Error report:
    SQL Error: ORA-00904: "JOB_ID": invalid identifier
    00904. 00000 -  "%s: invalid identifier"
    *Cause:    
    *Action:
    Any suggestions would be greatly appreciated...

    Thanks in advance.

    OK here goes hand in hand with the DDL

    Sorry - I will just ignore all the copious statements you just took the trouble to stick and I hope that that is what you want

    Show me the employees who earn the most in their location, excluding all employees who work IDs 670-672

    Then, it is probably more like this:

    SELECT x.employee_name, x.regional_group, x.salary, x.job_id
    FROM   (SELECT e.first_name ||' '||e.last_name AS employee_name
            ,      l.regional_group
            ,      e.salary
            ,      j.job_id
            ,      RANK() OVER (partition by l.regional_group order by e.salary desc) rnk
            FROM employee e
            ,      department d
            ,      location l
            ,      job j
            WHERE d.department_id (+) = e.department_id
            AND    l.location_id (+) = d.location_id
            AND    j.job_id (+) = e.job_id
            AND    j.job_id NOT IN (670,671,672) --<-- i.e. move this exclusion to before the rank
           ) x
    WHERE  x.rnk = 1;
    
  • where clause with reg_exp

    Hello

    My query is...

    The string is "1,2,3"...

    output must be '1', ' 2 ', ' 3',

    Please help me...!

    Concerning
    SA


    The guru gave the solution...
    select REGEXP_REPLACE('1, 2, 3', '([0-9]+)', '''\1''') from   dual;
    But, I have to use this condition in Where clause on my request. If I put in which the value of the clause does not appear. Any help on that...! Please, I beg you.

    Concerning
    SA

    Hello

    Query: SELECT "' | REPLACE ('1,2,3',',' "',"'). "' val FROM DUAL;

    will convert '1,2,3' string '1', ' 2 ', 3'.

    Run the sub queries first and then run a select statement.

    CREATE TABLE sample_table
    (
    col_a VARCHAR2 (3)
    );

    INSERT INTO sample_table
    VALUES ('1');

    INSERT INTO sample_table
    VALUES ('2');

    INSERT INTO sample_table
    VALUES ('3');

    INSERT INTO sample_table
    VALUES ('4');

    INSERT INTO sample_table
    VALUES ('5');

    COMMIT;

    SELECT col_a
    OF sample_table
    WHERE INSTR ((SELECT ''' ||)) REPLACE ('1,2,3',',' "',"'). "' val
    THE DOUBLE).
    col_a
    ) > 0;

    The select statement above will give you the desired result of "sample_table" as below.

    COL_A
    1
    2
    3

    Kind regards
    Big Boss

  • Using the Case statement in Where clause with operator

    Hi all

    I'm doing the following work (this is just a simple version of what I'll eventually need):

    Sorry, I forgot how to use the code tags...

    and li. MAJOR_ACCT in case
    When: prompt = 'Energy' then ('9320906 ', ' 9321471')
    end


    Problem is that I get a missing closing parenthesis error.

    Wouldn't - that evaluate against a value(as below) it works fine:

    and li. MAJOR_ACCT in case
    When: prompt = 'Energy' then ('9320906')
    end


    Any thoughts? Is it possible to use a box (or decode) in an In clause with multiple values? I tried to use decode as well and get the same results.

    Thank you.

    Darren.

    What:

    and ( case
            when :prompt = 'Energy' and li.MAJOR_ACCT in ('9320906', '9321471') then 1
            when :prompt = 'Vehicle' and li.MAJOR_ACCT in ('9812180', '9812320')  then 1
            when :prompt = 'Meals' and li.MAJOR_ACCT in ('983120', '983452') then 1
          end
        ) = 1
    
  • ORA-01417: a table can be external joined as another table

    Hi, I use Oracle 8i and could not use LEFT JOIN. So I need to use (+) instead.
    But I encounter ORA-01417 for = G.COL5 of I.COL3 (+)

    Complete the order as follows:
    SELECT *.
    B, A, C, D, J, K, L, E, F, G, H, I
    WHERE B.COL1 = 'ABC'
    AND B.COL1 = A.COL1 AND B.COL2 = A.COL2 AND B.COL3 = A.COL3
    AND C.COL1 = B.COL1 AND C.COL2 = B.COL6 AND C.COL3 = B.COL7
    AND B.COL1 = D.COL1 (+) AND D.COL2 (+) = B.COL6
    AND A.COL1 = J.COL1 (+) AND A.COL2 = J.COL2 (+)
    AND B.COL1 = K.COL1 (+) AND (+)-K.COL2 AND B.COL11 = B.COL6 = K.COL3 (+) AND B.COL12 = K.COL4 (+)
    AND A.COL1 = L.COL1 (+) AND L.COL2 (+) = A.COL2 AND A.COL3 = L.COL3 (+)
    AND E.COL1 = 'ABC' AND E.COL2 (+) (+) = C.COL20 AND E.COL3 (+) = C.COL21
    AND F.COL1 (+) = 'ABC' AND F.COL2 (+) = C.COL20
    AND G.COL1 = 'ABC' AND G.COL2 (+) (+) = B.COL11 AND G.COL3 (+) = B.COL12
    AND H.COL1 (+) = 'ABC' AND H.COL2 (+) = "PINCH" AND H.COL3 (+) = G.COL5
    AND I.COL1 (+) = 'ABC' AND I.COL2 (+) = "PINCH" AND I.COL3 (+) = G.COL5* AND = A.COL5 I.COL4 (+) AND I.COL5 (+) = "0001"

    Please notify.
    Thanks in advance.

    Hello

    981637 wrote:
    ... How to re-write the script according to your suggestion?

    Maybe something like:

    SELECT  *
    FROM      (     -- Begin in-line view abc
              SELECT     b.col4      AS b_col4
              ,     c.col4      AS c_col4
         --     ,     ...      -- Whatever columns you want to display in the main query
              FROM     a
              ,      b
              ,      c
              WHERE      b.col1          = a.col1
              AND     b.col2          = a.col2
              AND     b.col3          = a.col3
              AND     c.col1 (+)      = 'ABC'
              AND     c.col2 (+)      = a.col4
              AND     c.col3 (+)      = a.col5
         ) abc     -- End in-line view
    ,     d
    WHERE     d.col1 (+)     = 'ABC'
    AND     d.col2 (+)      = 'LOC'
    AND     d.col3 (+)      = abc.c_col4
    AND     d.col4 (+)      = abc.b_col4
    ;
    

    I can't say with certainty without examples of data (CREATE TABLE and INSERT statements) and the results desired from these data.

    In your real problem, the other tables can be joined to the a, b and c of the subquery (I assume it will be the most convenient way to do so), or they can be reached at abc in the main query.

  • Table 2 join vs inline view join to another table

    Hi, I was wondering if it makes a difference of 2 tables to join directly vs join of a table to a view online. I ran a few tests of my own and looked like to explain plans. The costs appear to be identical between each method. But, I was wondering if there are situations where a method should be used on the other.

    Using Oracle version 11.2.0.2.0

    The tables are as follows.

    Table1 (varchar2 (20) col1, col2 number)
    Table2 (col1 number, col2, col3 number)

    insert into table1 values ('test1', 1).
    insert into table1 values ('test', 2)
    insert into table2 values (1, 2, 4)
    insert into table2 values (2, 2, 4)


    Here is an example that I use.

    Select a.col1, b.col3
    FROM table1, table2 b
    where a.col2 = b.col2
    and a.col1 = 'test '.

    Select a.col1, b.col3
    FROM table1, (select col2, col3 from table2) b
    where a.col2 = b.col2
    and a.col1 = 'test '.

    Published by: arizona9952 on December 29, 2012 12:49

    Hello

    arizona9952 wrote:
    Hi, I was wondering if it makes a difference of 2 tables to join directly vs join of a table to a view online. I ran a few tests of my own and looked like to explain plans. The costs appear to be identical between each method.

    About efficiency, it does not matter that you use. The online display will not necessarily be performed first. The optimizer chooses what it thinks is the best plan anyway.

    But, I was wondering if there are situations where a method should be used on the other. Here is an example that I use.

    Select a.col1, b.col3
    FROM table1, table2 b
    where a.col2 = b.col2
    and a.col1 = 'test '.

    Select a.col1, b.col3
    FROM table1, (select col2, col3 from table2) b
    where a.col2 = b.col2
    and a.col1 = 'test '.

    I can't imagine any situation where the choice between these two issues. But consder the query below:

    SELECT  a.col1
    ,      b.col3
    FROM     table1 a
    ,      (          -- Begin in-line view b
             SELECT  col2
             ,          col3
         --  ,         ROWNUM     AS r_n
             FROM    table2
             WHERE   col2_type     = 'NUMBER'
         ) b               -- End in-line view B
    WHERE     a.col2     = TO_NUMBER (b.col2)
    AND     a.col1      = 'test'
    ;
    

    Suppose table2.col2 is a VARCHAR2 and table2.col2_type correctly identifies if col2 can be converted to a NUMBER. The above query might get conversion errors, because the optimzer may decide to join first and evaluate the WHERE col2_type = 'NUMBER' later condition, how to make sure that doesn't happen is different depending on whether you use a subquery or not. If you use a sub0 query (such as display online above) you can add a reference to ROWNUM in the subquery, as displayed if commnet line.

  • Copy the result of a join to another table

    Hi all

    I want to copy the join of two tables in another table. I tried the following approach, but I have error

           insert into new_copy  values (ID,name,na_name)   
           SELECT
             name
            FROM
              country u
            INNER JOIN
              (
                SELECT
                 na_name
                FROM
                  country2 st
              )
              s
            ON
              u.id = s.ID;
    
    1. insert into new_copy (ID, name, na_name)
    2. SELECT i.id, u.name, s.na_name
    3. COUNTRY u
    4. INNER JOIN s countries2 ON u.id = s.id

    must be done

  • Simple conditional SQL WHERE Clause with two Subselects

    Hi SQL Experts,
    I need some quick help with a query.
    It is a ' select ' for a data source object repository phyiscal table OBI.
    So, I can't put in PL/SQL or in stored procedures. I just need
    have two conditions / selects different according to the user's role (this information comes
    of the session).
    The above does not work:

    -ORA00905. 00000 - 'lack the key word'
    SELECT OFFICENO FROM orgunit
    WHERE

    BOX WHEN "SESSION_VARIABLE' LIKE '% globalmanager %' THEN
    ASSIGNEDOFFICES =
    (
    SELECT DISTINCT ASSIGNEDOFFICES
    FROM USERSTABLE INNER JOIN orgunit WE
    OrgUnit. KEY = USERSTABLE. OFFICE
    WHERE USERSTABLE. USERNAME ='VALUEOF (NQ_SESSION. THE USER)"
    )
    ON THE OTHER
    OFFICENO =
    (
    SELECT DISTINCT USERSTABLE OFFICENO
    INNER JOIN orgunit WE
    OrgUnit. KEY = USERSTABLE. OFFICE
    WHERE USERSTABLE. USERNAME ='VALUEOF (NQ_SESSION. THE USER)"
    )
    END;

    Can anyone help?

    Hello

    I can't tell what you want to do by looking at the code that do not do. Maybe:

    SELECT officeno

    For orgunit

    WHERE (session_variable LIKE '% globalmanager %'

    AND IN assignedofficies

    (

    SELECT assignedoffices

    UserTable U1

    JOIN orgunit o1 ON o1.officekey = u1.officekey

    WHERE u1.username = ' VALUEOF (NQ_SESSION. THE USER)"

    )

    )

    OR (NVL (session_variable

    , '?'

    ) NOT LIKE '% globalmanager % '.

    AND IN officeno

    (

    SELECT officeno

    Of u2 usertable

    JOIN orgunit o2 ON o2.officekey = u2.officekey

    WHERE u2.username = ' VALUEOF (NQ_SESSION. THE USER)"

    )

    )

    ;

    There might be a simpler and more efficient way in function your tables and your limit.

    The condition u2.username = ' VALUEOF (NQ_SESSION. The USER) "almost certainly not what you really want.

    .

    Whenever you have any questions, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • some computers are not authenticated successfully with ISE and join comments vlan

    Hello

    We have deployed ISE in a company and set the workstations for authentication of the computer. When jobs are authentication, they are placed in the VLAN Data (5), if they fail, then they must be placed in the VLAN (50). WiredAutoConfig service as supplicant is set with gpo to all the workstations have the same settings.

    Certificate of the ISE is signed by our internal CA and workstations have also imported CA in their trusted CA list.

    The problem is that few jobs are placed in the VLAN. Previously on these workstations, we got a pop-up as below. When you click on 'connect' work stations have been placed properly in the data VLAN (5). We do not get this security alert more on these machines and they just join them VLAN that is don't want we want.

    However, most of the workstations is authenticated successfully.

    switchports configuration:

    switchport access vlan 5
    switchport mode access
    switchport voice vlan 6
    authentication event fail following action method
    action of death event authentication server allow vlan 5
    action of death event authentication server allow voice
    no response from the authentication event action allow vlan 50
    living action of the server reset the authentication event
    multi-domain of host-mode authentication
    authentication order dot1x mab
    authentication priority dot1x mab
    Auto control of the port of authentication
    periodic authentication
    authentication violation replace
    MAB
    MLS qos trust dscp
    dot1x EAP authenticator
    dot1x tx-time 10
    spanning tree portfast
    spanning tree enable bpduguard

    Journal of ISE authentication;

    Everyone is in a similar situation?

    I guess that the machines in the domain have the root CA certificate checked under the 'Protected EAP Properties' window?

  • Oracle OFA customization list of values (LOV) mapping in Where clause with variables

    Hi all

    I have a requirement to add the condition of the UOM LOV I don't understand under conditions in LOV for example mcc.inventory_item_id =: 1 what: 1 means? and how the system look at the value in: 1? if I have to add the condition to the middle which number should I use?

    SELECT * FROM (SELECT distinct muc.unit_of_measure unit_meas_lookup_code, muc.unit_of_measure_tl unit_meas_lookup_code_tl, muc.description, muc.uom_class, muom.uom_code FROM mtl_uom_conversions_val_v muc, mtl_units_of_measure muom WHERE (muc.uom_class IN (SELECT mcc.to_uom_class CMC mtl_uom_class_conv_val_v WHERE mcc.inventory_item_id =: 1) muc.uom_class = GOLD: 2), AND (muc.item_id =) ((: 3 GOLD muc.item_id = 0) AND muc.unit_of_measure = muom.unit_of_measure) QRSLT WHERE ((UPPER (UNIT_MEAS_LOOKUP_CODE_TL) like UPPER(:4) AND (UNIT_MEAS_LOOKUP_CODE_TL like: 5 OR UNIT_MEAS_LOOKUP_CODE_TL as: 6 OR UNIT_MEAS_LOOKUP_CODE_TL as: 7 OR UNIT_MEAS_LOOKUP_CODE_TL as: 8))) ORDER BY upper (unit_meas_lookup_code)

    LOV.png

    Concerning

    A.S.

    Hey A.S.,.

    Looking more closely at the image you included, it seems that it is already a custom code, it starts with "Xx".  You should see if you have the available custom code.

    To answer part of your original question ""mcc.inventory_item_id =: 1 what: 1 means? ' " The ': 1 ' is a variable binding in the SQL code.  This value is populated at run time by using the "setWhereClauseParam (Bind number, value).  You can see the details of the request and the variable linking using JDeveloper and a double-tap on the View object.  Again, this should be in the custom code of the object View 'atco.oracle.apps.po.lov.server.XxDocumentUomBothVo '.

    I hope this helps.

    Thank you

    Tim

  • Dynamic WHERE Clause with multiple ORs

    I need to build a dynamic SQL statement such as the clause WHERE looks / works as follows:

    WHERE x LIKE '%1% ' OR LIKE '%2% ' x OR x LIKE '%3%...

    I can do the above, no problem, but I wonder if there is a better way?

    Thank you

    Mark

    Hi, Mark,.

    You should not need dynamic SQL for that.

    For example, if you are still interested in substrings of characters suingle, and you get entry as a unique string called str (e.g. '123' it which means you want to find the rows where x contains '1', '2' or 3'), so you could say:

    ...

    WHERE (x REGEXP_LIKE

    , '[' || str || ']'

    )

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and INSERT statements), a few entries and also post the desired results of each input given the same data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • using where clause with value to hardcode in run immediately

    Dear Experts, I use below in the stored procedure make exception.

    RUN IMMEDIATELY "REMOVE CC. TB WHERE COL ='HG ";

    When the collar is varchar2 (30) DC. TB

    Please guide how to use above the statement in the stored procedure


    Thank you

    DBA wrote:
    Dear Experts, I use below in the stored procedure make exception.

    RUN IMMEDIATELY "REMOVE CC. TB WHERE COL ='HG ";

    When the collar is varchar2 (30) DC. TB

    Please guide how to use above the statement in the stored procedure

    Thank you

    Why you use dynamic SQL? DELETE statement is a DML statement and its valid inside a PL/SQL block.

    So, you can remove the immediate execution and write your DELETE statement directly.

    begin
      delete from cc.tb where col = 'HG';
    end;
    

Maybe you are looking for