SQL Query : Getting specific datatype in select clause

Hi
I want to write one query that returns me the values inside a table based on the datatype of column(s) of the table. For e.g. I need only those columns of the table in select clause where the datatype of the column is VARCHAR.
Can you please help me on this?

Use the "user_tab_columns" Data Dictionary to get the columns and build the SQL Dynamically.
Thanks,
Karthick.

Similar Messages

  • SQL query in SQL_REDO Logminor showing where clause with ROWID

    SQL query in SQL_REDO Logminor showing where clause with ROWID. I dont wanted to use rowid but wanted to use actual value.
    OPERATION SQL_REDO SQL_UNDO
    DELETE delete from "OE"."ORDERS" insert into "OE"."ORDERS"
    where "ORDER_ID" = '2413' ("ORDER_ID","ORDER_MODE",
    and "ORDER_MODE" = 'direct' "CUSTOMER_ID","ORDER_STATUS",
    and "CUSTOMER_ID" = '101' "ORDER_TOTAL","SALES_REP_ID",
    and "ORDER_STATUS" = '5' "PROMOTION_ID")
    and "ORDER_TOTAL" = '48552' values ('2413','direct','101',
    and "SALES_REP_ID" = '161' '5','48552','161',NULL);
    and "PROMOTION_ID" IS NULL
    and ROWID = 'AAAHTCAABAAAZAPAAN';
    DELETE delete from "OE"."ORDERS" insert into "OE"."ORDERS"
    where "ORDER_ID" = '2430' ("ORDER_ID","ORDER_MODE",
    and "ORDER_MODE" = 'direct' "CUSTOMER_ID","ORDER_STATUS",
    and "CUSTOMER_ID" = '101' "ORDER_TOTAL","SALES_REP_ID",
    and "ORDER_STATUS" = '8' "PROMOTION_ID")
    and "ORDER_TOTAL" = '29669.9' values('2430','direct','101',
    and "SALES_REP_ID" = '159' '8','29669.9','159',NULL);
    and "PROMOTION_ID" IS NULL
    and ROWID = 'AAAHTCAABAAAZAPAAe';
    Please let me know solution/document which will convert SQL redo rowid value with actual value.
    Thanks,

    Please enclose your output within tag so that people here can read it easily and help you. Also the reason that why you want to remove rowid?
    Salman
    Edited by: Salman Qureshi on Mar 20, 2013 3:53 PM                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • SQL Query help ( On connect By level clause)

    Hi all,
    I have this query developed with data in with clause.
    With dat As
      select '@AAA @SSS @DDD' col1 from dual union all
      select '@ZZZ @XXX @TTT @RRR @ZZA' col1 from dual
    Select regexp_substr( col1 , '[^@][A-Z]+',1,level) Show from dat
    connect by level  <= regexp_count(col1, '@');Current output :-
    SHOW
    AAA
    SSS
    DDD
    RRR
    ZZA
    TTT
    RRR
    ZZA
    XXX
    DDD
    RRR
    SHOW
    ZZA
    TTT
    RRR
    ZZA
    . . .1st row comes fine, But next row data is getting duplicated. And total record count = 30. I tried with some but didn't work.
    Expected output :-
    SHOW
    AAA
    SSS
    DDD
    ZZZ
    XXX
    TTT
    RRR
    ZZAI need some change on my query and I am not able to find that. So anybody can add on that or can also provide some different solution too.
    Thanks!
    Ashutosh

    Hi,
    When you use something like "CONNECT BY LEVEL <= x", then at least one of the following must be true:
    (a) the table has no more than 1 row
    (b) there are other conditions in the CONNECT BY clause, or
    (c) you know what you are doing.
    To help see why, run this query
    SELECT     SYS_CONNECT_BY_PATH (dname, '/')     AS path
    ,     LEVEL
    FROM     scott.dept
    CONNECT BY     LEVEL <= 3
    ;and study the results:
    PATH                                     LEVEL
    /ACCOUNTING                                  1
    /ACCOUNTING/ACCOUNTING                       2
    /ACCOUNTING/ACCOUNTING/ACCOUNTING            3
    /ACCOUNTING/ACCOUNTING/RESEARCH              3
    /ACCOUNTING/ACCOUNTING/SALES                 3
    /ACCOUNTING/ACCOUNTING/OPERATIONS            3
    /ACCOUNTING/RESEARCH                         2
    /ACCOUNTING/RESEARCH/ACCOUNTING              3
    /ACCOUNTING/RESEARCH/RESEARCH                3
    /ACCOUNTING/RESEARCH/SALES                   3
    /ACCOUNTING/RESEARCH/OPERATIONS              3
    /ACCOUNTING/SALES                            2
    /ACCOUNTING/SALES/ACCOUNTING                 3
    84 rows selected.

  • Form on a SQL Query - doesn't work with SELECT * - bug or feature ?

    When I do this,
    Create Page -> Page with Component -> Form -> Form on a SQL Query -> SELECT * FROM EMP
    I do not get any items displayed and it creates a simple HTML region / page. Do we have to necessarily specify the column names ?
    Iam looking at a way to see if any addition of columns in the table does not involve IT intervention in recreating the form.
    When we try to create with Form on a SQL Query, then shouldn't it be similar to the Report where the same thing works, if I give SELECT function_returning_columns() from DUAL even then the same thing happens where it creates an ITEM called functions_returning_columns() it creates HTML region
    I asked a related question with no answer :-( in
    Dynamic Creation of Items in Runtime through Application UI

    Hi Marc,
    Thanks. I just tried something like this. Taking the EMP table example, (it doesn't matter which table), I created a region based on a Pl/Sql function returning SQL query
    ( I selected the vertical report template including nulls to display it like a form ) :
    DECLARE
    v_sql VARCHAR2(3000) ;
    mn_idx NUMBER := 1 ;
    BEGIN
    v_sql := 'SELECT ' ;
    FOR recs IN (SELECT * FROM ALL_TAB_COLUMNS WHERE TABLE_NAME = 'EMP' ORDER BY COLUMN_ID)
    LOOP
    v_sql := v_sql || 'HTMLDB_ITEM.TEXT(' || mn_idx || ',' ||
    recs.column_name || ') ' || recs.column_name || ', ' ;
    mn_idx := mn_idx + 1 ;
    END LOOP ;
    v_sql := SUBSTR(v_sql, 1, LENGTH(v_sql) -2) ;
    v_sql := v_sql || ' FROM EMP WHERE EMPNO = 7369 ORDER BY 1 ' ;
    RETURN v_sql ;
    END ;
    This allowed me to do my updates etc.., Then I created a button called 'Apply' and a process called 'update_changes' on button click and defined this:
    DECLARE
    v_sql varchar2(1000) ;
    mn_ctr NUMBER := 1 ;
    BEGIN
    v_sql := 'BEGIN UPDATE EMP SET ' ;
    FOR recs IN (select COLUMN_ID, COLUMN_NAME, DATA_TYPE
    from all_tab_columns where table_name = 'EMP'
    ORDER BY COLUMN_ID) loop
    -- Make changes here if required- this is assuming 9 columns --
    v_sql := v_sql || recs.column_name || ' = HTMLDB_APPLICATION.G_F0' || mn_ctr || '(1),' ;
    mn_ctr := mn_ctr + 1;
    end loop ;
    v_sql := substr(v_sql, 1, length(v_sql) - 1) ;
    v_sql := v_sql || ' WHERE EMPNO = 7369; END ;' ;
    execute immediate (v_sql) ;
    END ;
    Since this is for example, I didn't include code for Checksum and hardcoded empno = condition and have provision for 9 columns. I made some changes and tried saving it and I was able to do it.
    I altered the table to add a column / drop a column and when I relogin, Iam able to see the changes.
    Can you tell me if there could be any drawbacks in this approach ?.

  • SQL query optimization by changinf the WHERE clause

    Hi all,
    I need to know about the SQL query performance improvement by changing the WHERE clause. Consider a query :
    select * from student where country ='India' and age = 20
    Say, country = 'India' filters 100000 records and age = 20 filters 2000 records if given one by one. Now can anyone tell if the performance of the query can be changed by changing the query like this :
    select * from student where age = 20 and country ='India'
    as first where clause will give 2000 results and next filter will be applicable on only 2000 rows. While in the former query first where clause would give 100000 rows and seconde filter, hence, would be applicable on 100000 rows???
    Kindly explain.
    Thanks in advance.
    Abhideep

    in general the order of the where condition should not be important. However there are a few exeptions where sometimes it might play a role. Sometimes this is called order of filter conditions. Among others it depends on RBO or CBO used, Oracle Version, Indexes on the columns, statistic information on the table and the columns, CPU statistics in place etc.
    If you want to make this query fast and you know that the age column has much better selectivity then you can simply put an index on the age column. An index on the country column is probably not useful at all, since to little different values are in this column. If you are already in 11g I would suggest to use a composite index on both columns with the more selective in first position.
    Edited by: Sven W. on Nov 17, 2008 2:23 PM
    Edited by: Sven W. on Nov 17, 2008 2:24 PM

  • Error while executing SQL query -' Must Specify Table to select from'

    Hi all,
    While executing query using query generator
    it shows error message
    [Microsoft][SQL Native Client][SQL Server]Must specify table to select from.
    2). [Microsoft][SQL Nativ
    SELECT T1.ItemCode, T1.Dscription AS 'Item Description', T1.Quantity, T1.Price, T1.LineTotal,
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum) as 'BEDAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-60 AND T1.LineNum=T2.LineNum) as 'ECSAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=7 AND T1.LineNum=T2.LineNum) as 'HECSAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=1 AND T1.LineNum=T2.LineNum) as 'VATAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=4 AND T1.LineNum=T2.LineNum) as 'CSTAmt'
    FROM dbo.[OPCH] T0  INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PCH4 T2 ON T2.DocEntry=T0.DocEntry
    WHERE T0.DocDate >='[%0]' AND  T0.DocDate <='[%1]' AND T0.DocType = 'I'
    GROUP BY T1.ItemCode,T1.Dscription,T1.Quantity, T1.Price, T1.LineTotal,T0.DocEntry,T1.DocEntry,T1.LineNum,T2.LineNum
    It's executing fine in MS SQL Server Studio Management.
    Please give y'r ideas to solve the problem.
    Jeyakanthan

    try this, it works fine in my B1:
    SELECT T1.ItemCode, T1.Dscription AS 'Item Description', T1.Quantity, T1.Price, T1.LineTotal,
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum) as 'BEDAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-60 AND T1.LineNum=T2.LineNum) as 'ECSAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=7 AND T1.LineNum=T2.LineNum) as 'HECSAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=1 AND T1.LineNum=T2.LineNum) as 'VATAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=4 AND T1.LineNum=T2.LineNum) as 'CSTAmt'
    FROM dbo.OPCH T0  INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PCH4 T2 ON T2.DocEntry=T0.DocEntry
    WHERE T0.DocDate >='[%0]' AND  T0.DocDate <='[%1]' AND T0.DocType = 'I'
    GROUP BY T1.ItemCode,T1.Dscription,T1.Quantity, T1.Price, T1.LineTotal,T0.DocEntry,T1.DocEntry,T1.LineNum,T2.LineNum
    B1 don't like brackets!
    Regards

  • VERY URGENT: problem in sql query with long datatype in weblogic

    I have a problem while tryind to retrieve a column value with a long datatype using servlet and oci driver and the server is weblogic5.1 .I have used prepared statement the problem comes in the
    preparedStatement.executeQuery().
    The sql Query is simple query and runs well in all cases and fails only when the long datatype column is included in the query.
    The exception that comes on the weblogic server is that :
    AN UNEXPECTED EXCEPTION DETECTED IN THE NATIVE CODE OUTSIDE THE VM.

    Did you try changing the driver then?
    Please use Oracle's thin driver instead of the oci driver.
    There are many advantages of using the type 4 driver. the first and foremost being that it does not require oracle client side software on your machine. Therefore no enteries to be made in tnsnames.ora
    The thin driver is available in a jar called classes112.zip the class which implements the thin driver is oracle.jdbc.driver.OracleDriver
    the connection string is
    jdbc:oracle:thin:@<machine name>:1521:<sid>
    please try out with the thin driver and let me know.
    regards,
    Abhishek.

  • Pass Multiple Parameters to SQL query in Drop down or Select Boxes

    Post Author: JasonW
    CA Forum: Data Connectivity and SQL
    Hello all- I am using CR XI and SQL server 2000.I have written a SQL statement and used that statement as a 'command' in the Database Expert, to pull data into a report.  There are two issues I have that I need some help/advice on.-. The report needs 4 parameters.  A, B, C, D.-. I can create Parameters in the Database Expert that will prompt me for the data when I refresh the report. However,-. I need to be able to select those parameters in drop down boxes based on data in the SQL database.  The problem is that the parameter cannot pull the data without the criteria - so a drop down box seems impossible.  OR is it?  That is part of my question.  The other part is - Even if it is possible, can Crystal do this somehow?  NOTE: The query is selecting the data rather than Crystal - so Creating a Parameter field IN the report is futile. -. The other half of this problem is that users would like the ability to select multiple values from Field A and from Field B.  

    Post Author: JasonW
    CA Forum: Data Connectivity and SQL
    I ended up using a stored procedure.  This queries the proper data, and allows me to use Dynamic Parameters to make multiple selections on the data.  (I query out a large portion of the data in the stored procedure, then pair it down using Dynamic Parameters in Crystal.) Here is the new problem this has created:My Dynamic Parameters are not pulling all the values from the query.  Ex.  One field in the query is a "directory" listing.  It has 227 unique values in it.  (It has multiple values, it is not constrained.)  When I create a Dynamic Parameter off of this field, I only get 18 of the 227 as available selections in the drop down box.  However, I can type in any of the 227 values into the field manually, I pull the proper data.  So the data is there, its just not showing up in the drop down box.   Anyone have any ideas on this?

  • SQL Query: Getting timestamp

    Hi,
    I have a table with out having a date/time field as one of the columns. But is there any way I can have the date or time stamp of the row inserted into that table.
    I looked for that in the documentation, but its not there. I think it is not possible. I trying hard to get if there is any way to do that.
    Thanks in advance.
    Regards,
    KP

    LordEricO wrote:
    I need to query a database from my java program for the time of each entry, but all that's in there is a timestamp. I haven't been able to query it. It was suggested that I convert it to a date in the sql database, but I don't know how to do this. Any suggestions?Question is not precise.
    Do you want to query for a timestamp? Or do a query which returns a timestamp.
    For the first it is unlikely that you want to query for an exact value. It is more likely that you want a range.
    In either case you would be using prepared statements and Timestamp though.

  • Tuning SQL query with similar subqueries for select columns

    Hi all,
    My query is something like below:
    1> SELECT
    2> A.COL1,
    3> SUM(CASE WHEN A.flag=100 AND NVL(B.flag,0)=0 AND
    4> EXISTS (
    5> SELECT 'ROW_EXISTS'
    6> FROM A A0
    7> WHERE A0.COL2=100 AND NVL(A0.flag,0)=0 AND 0.DIRN<>A.DIRN)
    8> THEN 1
    9> ELSE 0
    10> END) SUM_COLUMN1,
    11>SUM(CASE WHEN A.flag=100 AND
    12> EXISTS (
    13> SELECT 'ROW_EXISTS'
    14> FROM A A0
    15> WHERE A0.COL2=100 AND A0.DIRN<>A.DIRN)
    16> THEN 1
    17> ELSE 0
    18>END) SUM_COLUMN2
    19>FROM A,B
    20>WHERE A.COL=B.KEY_COL
    21>GROUP BY A.COL1
    My problem is that I need to index scan the tables A aliased as A0 in the two exist queries. Lines: 5-7 and 13-15.
    The major performance degradation i see with the query is that it has to scan A0 twice to compute SUM_COLUMN1 and SUM_COLUMN2.
    Is there any way by which i can use the same subquery to scan the table just once to compute the columns.
    The table A has more than a 100million records. So i need to improve performance of this query though it is a small issue.
    Please feel free to ask me more if i'm not clear with the example.
    Thanks in advance,
    Raj

    Also you could use analytic functions:
    SQL> select deptno, sum(case when e.mgr is not null and
      2  exists (select 1 from emp e1 where e1.empno <> e.empno
      3  and e1.deptno = 10 and e1.sal >= 1500)
      4  then 1 else 0 end) sum1,
      5  sum(case when e.mgr is not null and e.sal >= 1200 and
      6  exists (select 1 from emp e1 where e1.empno <> e.empno and e1.deptno = 10)
      7  then 1 else 0 end) sum2
      8  from emp e
      9  group by deptno
    10  /
        DEPTNO       SUM1       SUM2
            10          2          2
            20          5          3
            30          6          5
    SQL> select deptno, sum(case when mgr is not null and
      2  (d12 != empno or empno !=d11) then 1 else 0 end) sum1,
      3  sum(case when mgr is not null and (d21 != empno or empno !=d22)
      4  and sal >= 1200 then 1 else 0 end) sum2
      5  from (
      6  select deptno, empno, mgr, sal,
      7  min(case when deptno = 10 and sal >= 1500
      8  then empno else -1 end) over(order by null) d11,
      9  max(case when deptno = 10 and sal >= 1500
    10  then empno else -1 end) over(order by null) d12,
    11  min(case when deptno = 10 then empno else -1 end) over(order by null) d21,
    12  max(case when deptno = 10 then empno else -1 end) over(order by null) d22
    13  from emp e
    14  )
    15  group by deptno
    16  /
        DEPTNO       SUM1       SUM2
            10          2          2
            20          5          3
            30          6          5In your case it could be something like
    SELECT COL1,
    SUM( CASE WHEN a_flag = 100 and nvl(b_flag,0)=0 and
    (DIRN != MIN_A OR DIRN != MAX_A) THEN 1 ELSE 0 END) SUM_COLUMN1,
    SUM( CASE WHEN a_flag = 100 and
    (DIRN != MIN_B OR DIRN != MAX_B) THEN 1 ELSE 0 END) SUM_COLUMN2
    FROM (
    SELECT A.COL1, A.FLAG A_FLAG, B.FLAG B_FLAG, A.DIRN,
    MIN(CASE WHEN A.COL2=100 and NVL(A.flag,0) = 0 THEN A.DIRN ELSE null END) OVER(order by null) MIN_A,
    MAX(CASE WHEN A.COL2=100 and NVL(A.flag,0) = 0 THEN A.DIRN ELSE null END) OVER(order by null) MAX_A,
    MIN(CASE WHEN A.COL2=100 THEN A.DIRN ELSE null END) OVER(order by null) MIN_B,
    MAX(CASE WHEN A.COL2=100 THEN A.DIRN ELSE null END) OVER(order by null) MAX_B
    FROM A,B
    WHERE A.COL=B.KEY_COL
    GROUP BY COL1
    Rgds.

  • Getting Exception in the select clause - Very Urgent

    Hi,
        I have given the below statement but it is showing the exception.
      SELECT *
             FROM (lv_tab_name)
             INTO CORRESPONDING FIELDS OF TABLE <fs_1>.
    If I execute the above select statement it is showing the below exception.
    Exception CX_SY_NO_HANDLER triggered.
    An exception with the type CX_SY_OPEN_SQL_DB occurred.
    It is working very well if I mention the few field names.
    Please let me know the possible reasons.
    Thanks,
    Suvin

    Thanks much for your quick response.
    I have tried with what you mentioned but it is not working.
    Please find my code below.
    *Declarations
    DATA: ddfields TYPE STANDARD TABLE OF ddfield.
      DATA: ls_ddfields TYPE ddfield.
      DATA: lt TYPE lvc_t_fcat.
      DATA: ls TYPE lvc_s_fcat.
      DATA: lv_tab_name TYPE dd02l-tabname.
    Data References
      DATA: lt_data TYPE REF TO data.
      DATA: new_line TYPE REF TO data.
    Field Symbols
      FIELD-SYMBOLS: <fs_1> TYPE ANY TABLE.
      FIELD-SYMBOLS: <fs_data> TYPE REF TO data.
      FIELD-SYMBOLS: <fs_2> TYPE ANY,
                     <l_field> TYPE ANY.
    Get the fields of the database table, here i am passing the table name
      CALL FUNCTION 'DD_NAMETAB_TO_DDFIELDS'
        EXPORTING
      KEYFIELDS       = 'X'
      NULLABLE        = 'X'
            tabname        = lv_tab_name
        TABLES
            ddfields        = ddfields.
      LOOP AT ddfields INTO ls_ddfields.
        ls-fieldname = ls_ddfields-fieldname.
        APPEND ls TO lt.
      ENDLOOP.
    *Assigning Field-Symbol to our dynamic internal table
      ASSIGN lt_data TO <fs_data>.
    Calling the method CREATE_DYNAMIC_TABLE
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = lt
        IMPORTING
          ep_table                  = <fs_data>
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc EQ 0.
        ASSIGN <fs_data>->* TO <fs_1>.
    Create a work area for the dynamic table.
        CREATE DATA new_line LIKE LINE OF <fs_1>.
    A field-symbol to access that work area
        ASSIGN new_line->*  TO <fs_2>.
      ENDIF.
    Selecting the Data from the respective table.
      SELECT *
             FROM (lv_tab_name)
             INTO CORRESPONDING FIELDS OF TABLE <fs_1>.
    Please advise..it is very urgent.
    Thanks,
    Suvin

  • SQL Query for specific vendor

    Hi Experts,
                     The user has requested to prepare reports with specific vendor name in PO. Please guide me with this.
    Edited by: shaichandan on Sep 27, 2011 9:48 AM

    Hi,
    Check this if it helps :
    select t0.DocNum as 'PO Num', t0.DocStatus as 'Status', t0.DocDate as 'Date',
    t0.CardCode as 'BP Code', t0.CardName as 'BP Name', t0.DocTotal as 'Document Amount',
    t1.ItemCode as 'Item', t1.Dscription as 'Item Description',t1.Quantity as 'Qty',
    t1.ShipDate as 'Shiping Date'
    from OPOR t0 inner join POR1 t1 on t0.docentry = t1.docentry
    where t0.cardname in ('Almats Printing Solution','Safe Offset')
    Order By t0.cardname
    Kind Regards,
    Jitin
    SAP Business One Forum Team

  • Attempting to Get Specific Items Selected from a JList

    Hello all, back again...
    I'm working on a simple interface that can run an SQL query with specific settings, and these settings can be altered by choosing one or multiple options from a JList to the side of the table that displays the results. My problem is, currently, not being able to figure out how to get the accursed thing to tell me what items in the JList are selected!
    I've tried using:
    int multiselect[] = cmbSystems.getSelectedIndices();...but it inevitably returns an array with a size of 1. Frustrating. I know I'm missing something, but I have no idea what. What am I doing wrong? Thanks!
    ~ Matt

    Mystrunner wrote:
    Hmm, okay... give me a bit to figure that out, and I will. :)Sure. Your SSCCE should probably only consist of a JList that prints out the selected items when the selection changes, or something like that. I would bet that you figure out what's going wrong in the process of boiling your code down to the SSCCE.

  • Setting current values in Multiple Select List in SQL Query based Report

    Hi,
    I have a report based on a sql query that contains a multiple select list. Unfortunately I cannot get the multiple select list to display the current values (p_value) correctly. I have created a page item, :p311_current_versions, that is set using a pre-header process and it returns a value with a colon delimited format e.g. '10.1.2.1.0:10.1.2.2.0'. Then this item is used in the sql query to set the current value (p_value) of the apex_item.select_list_from_query function. However when the table is displayed, instead of having two entries, 10.1.2.1.0 and 10.1.2.2.0 selected, it has an extra entry '10.1.2.1.0:10.1.2.2.0' selected.
    Here is my code:
    select distinct a.product, a.version from (
    select distinct
    apex_item.display_and_save(2,product)||apex_item.hidden(1,env_product_id) PRODUCT,
    APEX_ITEM.SELECT_LIST_FROM_QUERY(3,decode(product, 'HTTP Server' , :p311_current_versions, version), 'SELECT distinct version d, version r FROM ebs_tech_stack where
    product ='''||PRODUCT||'''',
    decode(PRODUCT, 'HTTP Server' ,'multiple="multiple" style="width:170px"','style="width:170px"'),
    'NO') as version
    from ebs_environment_tech_stack
    where environment_id = :p311_umgebung_id) a order by a.product
    If anyone can help me figure out how to set the current values correctly I'd be really grateful!!
    Thanks in advance,
    Jean

    Jean,
    I don't think this is possible using the apex_item package. The select_list_from_query function accepts only a single value for the second parameter.
    Scott

  • SQL Query to fetch a specific field in xml

    Hi,
    Below is my sample Xml file.
    <?xml version = "1.0" encoding = "UTF-8"?>
    <methodCall xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd">
    <methodName>rBatchFile </methodName>
    <params>
    <param>
    <value>
    <struct>
    <member>
    <name>filename</name>
         <value>
         D:\test.txt
         </value>
    </member>
    <member>
    <name>batchId</name>
    <value>
         L1
    </value>
    </member>
    </struct>
    </value>
    </param>
    </methodName>
    </methodCall>
    I want to query a "value" field based on the "name" field. I tried with the following query which didnt work.
    SELECT a.extract('//value/text()' , 'xmlns:="http://www.tibco.com/schemas/CS4_new1/Schema.xsd" ')
    FROM ( SELECT t.customerinfo.extract('//member[name="filename"]','xmlns:="http://www.tibco.com/schemas/CS4_new1/Schema.xsd" ')
    FROM cust_order t ) a;
    Please do provide the SQL query ASAP.

    with tab as (
    select xmltype('<?xml version = "1.0" encoding = "UTF-8"?>
    <methodCall xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd">
    <methodName>rBatchFile </methodName><params>
    <param>
    <value>
    <struct>
    <member>
    <name>filename</name>
    <value>
    D:\test.txt
    </value>
    </member>
    <member>
    <name>batchId</name>
    <value>
    L1
    </value>
    </member>
    </struct>
    </value>
    </param>
    </params>
    </methodCall>
    ') a from dual
    --end of sample data
    SELECT
      extractvalue(column_value,'/member/name') name,
      extractvalue(column_value,'/member/value') value
    from tab t,xmltable('xmlns = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.tibco.com/schemas/CS4_new1/Schema.xsd Schema_new.xsd"','for $i in //member return $i' passing t.a)An example...but i tweaked the xml...check the xml namespace once before executing...
    without adding the namespaces...code will be like...
    with tab as (
    select xmltype('<?xml version = "1.0" encoding = "UTF-8"?>
    <methodCall >
    <methodName>rBatchFile </methodName><params>
    <param>
    <value>
    <struct>
    <member>
    <name>filename</name>
    <value>
    D:\test.txt
    </value>
    </member>
    <member>
    <name>batchId</name>
    <value>
    L1
    </value>
    </member>
    </struct>
    </value>
    </param>
    </params>
    </methodCall>
    ') a from dual
    --end of sample data
    SELECT
      extractvalue(column_value,'/member/name') name,
      extractvalue(column_value,'/member/value') value
    from tab t,xmltable('for $i in //member return $i' passing t.a)Ravi Kumar

Maybe you are looking for

  • How to segragate correct and incorrect records in a msg

    Hi All, I am working on a file-XI(BPM)-Oracle scenario. My input file has a field 'Applicant No', which is mandatory in the Oracle table. In my BPM, I have a transformation generating two message types, one for the corect msg and the other for the er

  • Is it possible to create round shape button in java

    i have following questions, if possible plz. help me. 1) is it possible to create round shape i.e circular shapes button using java program. 2) is it possible to access the floppy and format it using java program. (if it is not possible to format it

  • Question Mark / not reading hard drives

    I have a flashing question mark /apple icon on the attempts to startup my G4 . Not reading the drives . I have used the startup disk & checed the profile & it reads the drives in the extensions, however not on startup

  • Pop-up Buy Adobe Acrobat 8 Professional

    I have installed and re-installed Adobe Reader 8.1.2 multiple times on my Windows Vista operating system computer. When I open PDF files, I receive a message/pop-up to Buy or Register Adobe Acrobat 8 Professional. I do not want to purchase Adobe Acro

  • Find views defined on tables

    I am trying to create a prebuilt MV on a table. but it some up with the error: ORA-32334: cannot create prebuilt materialized view on a table already referenced by a MV Just wondering how to find the list of views defined on teh table. I am using ora