Dynamic query with wildcard

Hello

I have a table1 as below

ID (NUMBER), keyword (VARCHAR2)
----------------------------------------------------
1, HAS
2, B
3, C

Another table2

Name (VARCHAR2)
--------------------------
Alice
Bob
Jack

I need to write a stored procedure to check if the 2 mactched of the char keyword table1 table name. How to write the dynamic query in my PL/SQL in a stored procedure so that I can generate query similar to

SELECT * from table2 where name like '%x %' where I need to replace X by the tank in table1

Help, please.

Thanks in advance,
Marry

I need to write a stored procedure to check if the 2 mactched of the char keyword table1 table name

You could simply join the tables:

SQL> with table1  as
(
 select 1 id, 'A' keyword from dual union all
 select 2 id, 'B' keyword from dual union all
 select 3 id, 'C' keyword from dual
),
table2 as (
 select 'Alice' name from dual union all
 select 'Bob' name from dual union all
 select 'Jack' name from dual
)
--
--
select * from table1, table2 where name like '%' || keyword  || '%'

        ID KEYWORD NAME
---------- ------- -----
         1 A       Alice
         2 B       Bob  

2 rows selected.

Tags: Database

Similar Questions

  • Data model - dynamic query with parameters

    Hi friends, is it possible to dynamically call a query using the parameters of the data models?

    I try to have a BEEP report with data model something like that

    Data model
    Param1

    Q1 = Select * from table 1
    Q2 = Select * from table 2

    If Param1 = X then
    FinalQuery = Q1
    On the other
    FinalQuery = Q2
    End

    Any help is greately appreciated.

    Thank you
    SAI.

    Take a look at the following:

    http://www.Oracle.com/global/de/community/BIP/tipps/dynamische_queries/index_en.html

    http://blogs.Oracle.com/XmlPublisher/files/BIPublisher_dynamic_column%20Blog.PDF

    Thank you!

  • dynamic query problem

    Hello

    I am trying to understand the procedure and on the inside, I have a dynamic query with where clause:

    "Select."

    tables

    where 1 = 1

    and instr (decode (nvl (' | nvl(pCATEG,'') |))) (("*"), "*", pb.categ, upper (' | nvl(pCATEG,'') |), pb.categ) > 0'

    || NVL(pEMP_GROUP_CODE,'') |

    "and p.emp_group_code = g.emp_group_code';"

    For it, clause make sense (parameter pEMP_GROUP_CODE is not connected to any condition, or I missed something)?

    The procedure is works and connected to the application.

    Please notify

    Thank you

    Daniel

    Has been confused by "p.emp_group_code".

    What you see is probably a lexical parameter, for example the value passed on s pEMP_GROUP_CODE a condition itself as 'and table.column = 'constant', which can be zero, so if you have a value, it adds a condition, otherwise just empty space and the condition is spared.

  • How to map Dynamic Query columns on variables of forms.

    Dear all,
    This is a correct code for executing a dynamic query and display data.
    In this program that I have defined variables ("BOLD" of police) later I binds these with the query (in the second code "BOLD").

    How I can map a column in the query, in which case I don't know that the surveyed fields type?



    GetData PROCEDURE IS
    EXEC_SQL connection_id. PORT;
    cursorID EXEC_SQL. CURSTYPE;
    sqlstr VARCHAR2 (1000);

    loc_ename VARCHAR2 (30);
    loc_eno NUMBER;
    loc_hiredate DATE;

    nIgn PLS_INTEGER;

    BEGIN
    connection_id: = EXEC_SQL. DEFAULT_CONNECTION;
    cursorID: = EXEC_SQL. OPEN_CURSOR (connection_id);
    --
    -assuming empno is a primary key for the table emp, where clause ensures
    -only 0 or 1 row is returned
    --
    sqlstr: = "select ename, empno, hiredate from emp;
    -sqlstr: = sqlstr. 'where empno =' | input_empno;

    EXEC_SQL. PARSE (connection_id, cursorID, sqlstr, exec_sql. V7);
    -EXEC_SQL. Bind_variable (connection_id, cursorID, ': bn', input_empno);

    EXEC_SQL. DEFINE_COLUMN (connection_id, cursorID, 1 loc_ename, 30);
    EXEC_SQL. DEFINE_COLUMN (connection_id, cursorID, 2, loc_eno);
    EXEC_SQL. DEFINE_COLUMN (connection_id, cursorID, 3, loc_hiredate);

    --
    -do execute_and_fetch after the analysis of the statement and calling bind_variable and
    -If necessary define_column
    --

    nIgn: = EXEC_SQL. EXECUTE_AND_FETCH (connection_id, cursorID);
    IF (nIgn = 0) THEN
    TEXT_IO. Put_line ('not Rec');
    ELSE IF (nIgn = 1) THEN
    TEXT_IO. Put_line ('found an employee');

    END IF;
    --
    -get the values of this line
    --
    WHILE (EXEC_SQL. FETCH_ROWS (connection_id, cursorID) > 0) LOOP
    -nRows: = nRows + 1;
    EXEC_SQL. COLUMN_VALUE (connection_id, cursorID, 1, loc_ename);
    EXEC_SQL. COLUMN_VALUE (connection_id, cursorID, 2, loc_eno);
    EXEC_SQL. COLUMN_VALUE (connection_id, cursorID, 3, loc_hiredate);

    MESSAGE(loc_ename||) e '|| loc_eno | » '|| loc_hiredate);

    END LOOP;
    END IF;
    END;

    If you want to use EXEC_SQL and a dynamic query with unknown data types, but the known table name,
    Then you can declare a rowtype variable
    for example;

     NOT TESTED ---A ROUGH IDEA
    m_emp_row employee_master%rowtype;
    m_col_cnt number := 0;
    So when you define collumn, create a procedure to find the column name and its width if it is varchar2 with respect to the column name .
       Find the column details from the user_tab_columns table ...
    ---------------------------------------------------------------------------------------------------------------------------------------------------
      while m_col_cnt < 3 loop
           m_col_cnt  := m_col_cnt +1;
           proc_find_col_name_width(p_qry ,p_col_no=>m_col_cnt , p_col_name,p_col_width);
    
          If p_col_name = 'EMPCODE' then
             EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, m_col_cnt , m_emp_row.empcode , p_col_width);
          elsif p_col_name ='EMPNAME' then
             EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, m_col_cnt , m_emp_row.empname , p_col_width);
           -----
            -------
           end if;
      end loop;
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------
    --Your procedure will look like this
     procedure proc_find_col_name_width(p_qry  varchar2,p_col_no number, p_col_name out varchar2,p_col_width out number) is 
    
     m_col_name varchar2(30);
     Cursor c1 is
     Select  data_length
     from user_tab_columns
     where table_name = 'yr_tab_name'
     and column_name = m_col_name;
     m_lastpos number ;
     m_nxtpos number ;
     Begin
      m_lastpos := instr(p_qry,',',1,p_col_no-1);
      m_nxtpos := instr(p_qry,',',1,p_col_no);
      If m_lastpos = 0 then --- if only one col
         m_col_name := substr(p_qry,instr(upper(P_QRY),'SELECT') + 6, instr(upper(P_QRY),'FROM') -1);
      else
           If m_nxtpos = 0 then ---if last column
                 m_nxtpos := instr(upper(P_QRY),'FROM') -1;
           end if;
    
        m_col_name := substr(p_qry,m_lastpos+1,m_nxtpos);
      End if;
      m_col_name := ltrim(rtrim(m_col_name));
      open c1;
      fetch c1 into p_col_width;
      close c1;
      p_col_name := m_col_name;
    END;
    

    same thing you must apply when retrieving values using exec_sql.column_value
    concerning
    Dora

    Published by: Dora on December 7, 2009 12:20

    Published by: Dora on December 7, 2009 12:20

  • Dynamic problem with lookup-query for the purpose of resource request

    Hi all
    I need to set up several IOM user exchange mailboxes, I can set up AD account and account of the mailbox without any problem, but only for the first ad and Exchange account. For the second and third, etc. I get the error: "Invalid login name" during Exchange of account provisioning. I discovered that this problem exists with Exchange Connector - it is not able to collect correct GUID. So in my xml Dataset I use dynamic query Lookup to select manually correct Alias, the login name and GUID. The query for the GUID is the sequel (I cloned RO for AD and Exchnage):

    AttributeReference available-in-bulk = "true" length = "32" widget = 'search query' type = 'String' attr-ref = "Object GUID" name = "Object GUID" >
    * < lookupQuery search-query = "select distinct UD_KFUSER_OBJECTGUID GUID, ud_KFUSER_uid like UD_KFUSER UD_KFUSER, orc orc Login, sta sta where UD_KFUSER.orc_key = orc.orc_key and orc.usr_key = ' $Form data." Take ' and UD_KFUSER. "UD_KFUSER_AD = 27 and orc.orc_status = STA.sta_status AND STA.sta_bucket! = 'Cancelled'" display-field = "GUID" save-field = "Object GUID" / > *.
    * < / AttributeReference > *.


    My questions are:

    1. I have to type * to run the query in the user interface, without * I got error:

    + < 17 February 2012 11:12:22 THIS > < error > < oracle.adfinternal.view.faces.config.ric +.
    h.RegistrationConfigurator > < BEA-000000 > < ADF_FACES - 60096:Server Exception durin
    PPR, #10 g
    oracle.iam.platform.canonic.base.NoteException: an error occurred during executin
    g the search query.
    to oracle.iam.platform.canonic.agentry.GenericEntityLookupActor.perform)
    GenericEntityLookupActor.java:337)
    Is this right?

    2. when I got correct values (from the search query) - they are missing on the details of the application and form of RO - what Miss me?

    I use OIM 11.1.1.5, in my xml dataset I use correct attr-Ref (labels), when I type the values manually, they are propagated to form RO and Exchange mailbox is created.
    Best
    MP

    I not had no problem when writing search query.
    This works very well for me.
    The request will be filled for the field, so why choose *?
    I used as

  • SQL query with dynamic exercise

    Hello

    I wrote this query with static exercise and exercise, I need info on making the dynamic variables

    Exercise: starts from July1st. This year up to June 30 is "2011" and July ' 1's '2012'
    Exercise: July1st his '1' and June ' 1 his '12'

    Query:

    Select distinct o.c_num, o.ac_num, s.sub_ac_num, o.fiscal_year, o.ac_exp_date, s.sub_ac_ind
    of org_account o
    outer join left sub_account s
    on o.c_num = s.c_num and o.ac_num = s.ac_num
    where (o.ac_exp_date > = CURRENT_DATE or o.ac_exp_date is null)
    and o.fiscal_year = * '2011' * -> need to be dynamic
    and o.fiscal_period = * '12' * -> need to be dynamic

    Thank you
    Mano

    Published by: user9332645 on June 2, 2011 18:55

    Hi, Mano,

    Welcome to the forum!

    Whenever you have a question, please post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.
    Always tell what version of Oracle you are using.

    Since this is your first thread, I will post some examples of data for you:

    CREATE TABLE     table_x
    (     dt     DATE
    );
    
    INSERT INTO table_x (dt) VALUES (DATE '2010-12-31');
    INSERT INTO table_x (dt) VALUES (DATE '2011-01-01');
    INSERT INTO table_x (dt) VALUES (DATE '2011-06-02');
    INSERT INTO table_x (dt) VALUES (DATE '2011-06-30');
    INSERT INTO table_x (dt) VALUES (DATE '2011-07-01');
    

    What is the output you can from these data?

    DT          FISCAL_YEAR     FISCAL_PERIOD
    ----------- --------------- ---------------
    31-Dec-2010 2011            06
    01-Jan-2011 2011            07
    02-Jun-2011 2011            12
    30-Jun-2011 2011            12
    01-Jul-2011 2012            01
    

    If so, here's a way to get it:

    SELECT       dt
    ,       TO_CHAR ( ADD_MONTHS (dt, 6)
                , 'YYYY'
                )     AS fiscal_year
    ,       TO_CHAR ( ADD_MONTHS (dt, 6)
                , 'MM'
                )     AS fiscal_period
    FROM       table_x
    ORDER BY  dt
    ;
    

    Since your exercise begins 6 months prior to the calendar year, you must add 6 months to the actual date for the fiscal year and month.

    The above query produces strings for fiscal_year and fiscal_period. If you prefer to have the numbers, then use EXTRACT instead of TO_CHAR:

    SELECT       dt
    ,       EXTRACT (      YEAR
                FROM     ADD_MONTHS (dt, 6)
                )     AS fiscal_year
    ,       EXTRACT (      MONTH
                FROM     ADD_MONTHS (dt, 6)
                )     AS fiscal_period
    FROM       table_x
    ORDER BY  dt
    ;
    

    The first query will work in Oracle 6 (and more).
    I don't know when EXTRACT was introduced. Certainly, it works in Oracle 10 and may be available in older versions too.

  • dynamic update with vars query

    Hello

    I have a dynamically generated, with x input fields, generated from x days
    so, if I have 3 days and each day contains 3 fields, I appoint dynamic my fields

    field1_1
    field1_2
    field1_3

    field2_1
    field2_2
    field2_3

    and so on...

    in my result page, I can capture these areas by

    < cfloop 1 to 3 of the index I have >
    < name cfparam = field1_ #i # >
    < / cfloop >

    but then I don't know how to upgrade my request, because I would have to use this syntax, which is not correct...

    < cfloop 1 to 3 of the index I have >
    UPDATE... 1(1)(a) field SET = field1_ # i # #.
    < / cfloop >

    is there another way?


    TNX for all help!

    Scoring table to use. Assume you are using POST:

    UPDATE... 1(1)(a) field SET = form [' field1_ #i # "]

  • Dynamic region with several task page fragment flow isn't refreshing VO

    JDeveloper version is 12.1.3 and Weblogic Server is 12.1.3.

    We have a dynamic region with several task page fragment flow.  We have created a menu that will open on the workflow task in the dynamic region. Before defining the workflow id in the bean, we execute query on the original Version after setting the bind variable. When we click on the menu is open the flow of relevant tasks in the region and showing the Original data table.

    But when we open the same request again to a different browser session, it shows all the data in the original Version when the user clicks on the relevant menu item...

    I have attached the code used to navigate to the different workflow tasks written in the bean from the back of the home page.

    We have no idea why anyone what happens, if it's a server problem or a code issue. Because unless and until we open the target application in a new browser it works fine.

    We tried and deployed on a remote server as well, but it gives the same question...

    Would be really grateful for the help...

    The user, the code you posted has some serious problems. Never, I repeat never store a reference to an application module in a static variable in a bean. That is why you see only data once. After that, the second session reuses the application module from the first to the configuration data, but to display data it uses a module different application.

    The way you try to configuration data is too bad. You must pass the parameters to the workflow and init data in the default action of the workflow instead of doing before installing the new workflow id. A workflow is a unit of work that is kind of a black box. You may not assume that the stuff you do outside of this black box can be seen inside the box. This is only true if the workflow share the same control of data as it's parent (share of data control).

    I suggest you read some documents on the workflow and how they work. A good start is to look at this video https://www.youtube.com/watch?v=A3CmDhWHaG0

    or work through this tutorial 12 c (12.1.3) Oracle JDeveloper tutorials - working with bounded task flows, regions and routers

    Timo

  • Need help tuninng a dynamic query

    Hello

    We have following question

    Select s.* s bose_sites.registration_crm_serial_number

    R2 bose_sites.registration_crm_serial_number left on join

    s.serialnr = r2.shipserialnr

    where s.shipserialnr is null

    and (r2.serialnr = ' 052378332000138AE' or (s.serialnr =)

    (( "052378332000138AE" and s.shipserialnr is null))

    which takes about 40 seconds to execute with the values highlighted in bold being dynamic values

    If anyone can help reduce the run time on this request.

    There are indexes created on table

    INDEX_NAME INDEX_TYPE

    ------------------------------ ---------------------------

    IDX_REG_CRM_SER_NUM_CPC NORMAL

    IDX_REG_CRM_SER_NUM_SHIPDATE NORMAL

    IDX_REG_CRM_SER_NUM_PARENT_ID NORMAL

    IDX_REG_CRM_SER_NUM_ID NORMAL

    is it possible that we can capture a dynamic query using DBMS_SQLTUNE

    all suggestions will be useful.

    Hello

    You have one table here

    -------------------------------------------------------------------------------

    Schema name: SYS

    SQL ID: cf2875zz4q4nd

    SQL text: select s.* bose_sites.registration_crm_serial_number s

    R2 bose_sites.registration_crm_serial_number left on join

    s.serialnr = r2.shipserialnr

    where s.shipserialnr is null

    and (r2.serialnr = '052378332000138AE' or (s.serialnr =

    S.shipserialnr and "052378332000138AE" is null))

    -------------------------------------------------------------------------------

    then why don't you go for a simple query

    HTH

  • dynamic query for package does not work

    Dear members,

    I have problems with a package in the creation and analysis of a dynamic query in the WHERE clause. Here is an example of what I'm trying to do:

    PROCEDURE test_status_proc)
    wtd_cursor ON cur_type
    date_1 IN date
    date_2 IN DATE
    status in VARCHAR2,
    flag in VARCHAR2)

    IS

    status_sql VARCHAR2 (250): = NULL;
    flag_sql Varchar2 (100): = NULL;

    BEGIN


    Status of the IF = 'A' THEN
    lv_status_sql: = 'A ';
    lv_flag_sql: = 'Y ';
    END IF;
    Status of the 'I' = IF THEN
    lv_status_sql: = 'A ';
    lv_flag_sql: = 'n';
    END IF;

    Status of the 'R' = IF THEN
    lv_status_sql: = "R";
    lv_flag_sql: ='* ';
    END IF;

    Status of the IF = n THEN
    lv_status_sql: = 'n';
    lv_flag_sql: ='* ';
    END IF;

    IF status_code = 'IRN' THEN
    "lv_status_sql: = '('' N'','' R'');
    lv_status_sql: = lv_status_sql | ' OR (s.status = s.flag = "A" AND "N")';
    lv_usecalc_sql: ='* ';
    END IF;

    Status of the = IF'* ' THEN
    lv_status_sql: ='* ';
    lv_flag_sql: ='* ';
    END IF;

    OPEN FOR Test_cursor

    SELECT * from test_status s
    WHERE
    s.Daytime BETWEEN date_1 AND date_2
    S.status AND decode (lv_status_sql,'* ', s.status, lv_status_sql)
    S.flag AND decode (lv_flag_sql,'* ', s.flag, lv_flag_sql);

    The problem I have is especially with the condition 'IRN '. The suite WHERE the part of the clause looks like the following in the lv_status_sql, but the query returns all the values:

    -(', 'R') OR (s.status = 'A' AND s.flag =' only)

    Any help would be much appreciated.

    Kind regards

    dreporter wrote:

    Thanks for your reply and I completely understand your frustration. The problem is sometimes it is very difficult to describe all of the problem due to several reasons. Please take a look at my last post to see if that makes sense.

    If you really need SQL dynamic - true dynamic SQL which includes dealing with dynamic number of bind variables - then DBMS_SQL are an excellent interface to use.

    You can generate the dynamic SQL statement based on the question of whether the filter criteria is null (do not use) or not null (use as a predicate). For example

    if someParam10 is not null then
      // someParam10 needs to be used as a filter predicate
      dynamicSQL := dynamicSQL || ' and some_col_10 = :someParam10 ';
    end if;
    

    This statement can then be analyzed using the DBMS_SQL interface. The binding of values uses the same logic that was used to create predicates. For example

    if someParam10 is not null then
      // someParam10 is used and needs to be bound
      DBMS_SQL.Bind( myCursor, 'someParam10', someParam10 );
    end if;
    

    So, with this approach simplistic, you can easily create a dynamic SQL with variable predicates, dynamically bind these and run the slider.

    Bind variables are used in the dynamic SQL statements, as there are very few threats of SQL injection. And the basic principles observed for shareable SQL creation - the same set of parameters not null to filter, will result in the same SQL statement, which allows the cursor within the Pool shared for this SQL statement to be reused.

    So, technically, dynamic SQL is not a major problem (if used correctly). The major problem is that if really necessary to address the requirements of the business at hand.

    The problem I have with many comments here want to use dynamic SQL statements, is that it is used as one would use a file i/o interface.

    For file IO you want standard Open(), Read(), Write() and Close() calls. And you, the appellant, simply pass the name of the file and the data to write or to receive the data read.

    Similarly, these posters want to use SQL to open a table and read and write the data column - and do it by calling simply (and dynamically) by specifying the name of the table and column. Approaches to dynamic SQL based on one such concept is wrong. And shows that much of the ignorance of what a RDBMS is and how to use an RDBMS.

  • Dynamic action with refreshment area interactive report

    Hello!

    I use APEX 4.02

    I have a page with 2 regions.
    Region1 is a form (of entry)
    Region.2 is an interactive report on the same table as region 1

    When you enter values in the form I'm trying dynmically similar research records in the table with the interactive report.

    I made a dynamic action on the change of form fields that must refresh the interactive report region. I can see this one fires if I add an alert to debug if it fires.
    The dynamic report is based on a query with bind variable pointing to the fields in the form, for example
    where
    Field1 =: P2_FIELD1


    It works fine on the page loading, so no action is triggered, but I see the lines in the region of report are the ones I'm looking for.
    The updating of the report area does not work, but it is never nice and/or showing the correct data after a change of form fields, if it looks like the dynamic action "refresh the region" does not work on the interactive report.

    Any ideas why it can go wrong?
    I want to solve this problem using standard dynamic actions and preferably not via PL/SQL or JS, should be possible if I believe documentation... ;)

    See you soon
    Bottom

    Published by: bklerk on 26-apr-2011 03:07

    Hello

    Check this example application
    http://Apex.Oracle.com/pls/OTN/f?p=39830:38

    You can download and check the source

    Kind regards
    Jari

  • Sort on dynamic query problem!

    Hello

    I have a dynamic query written in pl/sql, when I check "Sort" for each field in the report attribute, error message resurrected as "ORA-01785: ORDER BY item must include the number of an expression in the SELECT list.
    If I do not check sort, it works very well. In my applications, I need all the fields sorted by user, how do I solve this problem?

    My query as below:

    declare
    Ask varchar2 (2000): = "select";
    s_class varchar2 (1000);
    cursor c1 is select * from demo_preference;
    Start
    for c1_val looping c1
    If c1_val.login is not null then
    query: query = | » ' || 'login ' | ',';
    end if;
    If c1_val.id is not null then
    query: query = | » ' || 'id ' | ',';
    end if;
    .......
    end loop;
    query: = SUBSTR (query, 1, length (query)-1);

    s_class: = ' (NVL (: P2_class, "%" |)) ''null%'') = ''%'' || "zero percent" OR
    EXISTS (SELECT 1 FROM apex_collections WHERE collection_name = "P2CLASSCOL" AND class = c001))';

    query: query = | » ' || ' from ming.reg_report_view1 where '.
    || ' ' || s_class;
    Return (Query);
    end;

    Maybe the internal column used when you clicked the sort is not indicated in the report. Try to use aliases when you build the query string, it might help apex internally to identify a column even if its order is changed to another user. After all, the order of the columns in the code is dynamic and I assume that even the number of displayed columns can vary that could sort on a column that is identified by a number not valid.

    How about somewhere, displaying the report query so that you know what is the exact query processing, it could give you the best information on the problem.

    If the problem persists, use a collection that is extracted these record using the same query string, then replace the report to view the collection and then set the sort column on. This way Summit could get confused about which columns are being sorted and it would just sort on a c001... C050 column as if it were a string (Yes problems with the number of sort columns when you do this).

  • 30EA2 - UNIT TESTING - value dynamic query truncating dates time.

    So I use the installation of SQL Developer Unit Testing (very nice by the by) for a bit now and just recently upgraded to the latest beta version (3.0.02.83). Looks like a bug has been introduced by which the dynamic query of value are truncate all time of all DATE data type information.

    This causes sadness serious for my current test cases and for me since I have to go back to the previous beta version :)

    I noticed that, in the new 30EA2 parameter:

    AddVMOption - Doracle.jdbc.mapDateToTimestamp = false

    has been introduced by default in

    [SQLDEveloper_install_dir]/sqldeveloper/bin/sqldeveloper.conf

    Perhaps it has something to do with the behavior of incorrect date, try to remove the parameter and check again.

  • Dynamic report with LOV SelectLists

    I like to create a dynamic report with Select-Lists(LOV based).

    My Source (according to PL/SQL returning SQL query) region:
    declare
      q varchar2(4000);
    begin
     
      q := 'SELECT R_ID, R_TSO_NO';
    
      For i in (SELECT * FROM USER_TAB_COLUMNS
      WHERE table_name = 'TAB_REPORTS'
      AND column_name like '2%')
      loop
        q := q || ', ';
        q := q || 'HTMLDB_ITEM.SELECT_LIST(1, ';
        q := q || i.column_name;
        q := q || ', ';
        q := q || chr(39);
        q := q || 'LOV_QER';
        q := q || chr(39);
        q := q || ', null, ';
        q := q || chr(39);
        q := q || 'Y';
        q := q || chr(39);
        q := q || ') "';
        q := q || i.column_name;
        q := q || '"';
      end loop;
       
      q := q || ' FROM TAB_REPORTS ';
    
      return q;
    
    END;
    This is the return value, which seems to be OK:
    SELECT R_ID, 
    R_TSO_NO, 
    HTMLDB_ITEM.SELECT_LIST(1, 2008_05, 'LOV_QER', null, 'Y') "2008_05", 
    HTMLDB_ITEM.SELECT_LIST(1, 2008_03, 'LOV_QER', null, 'Y') "2008_03", 
    HTMLDB_ITEM.SELECT_LIST(1, 2008_08, 'LOV_QER', null, 'Y') "2008_08", 
    HTMLDB_ITEM.SELECT_LIST(1, 2008_11, 'LOV_QER', null, 'Y') "2008_11", 
    HTMLDB_ITEM.SELECT_LIST(1, 2009_02, 'LOV_QER', null, 'Y') "2009_02", 
    HTMLDB_ITEM.SELECT_LIST(1, 2009_05, 'LOV_QER', null, 'Y') "2009_05", 
    HTMLDB_ITEM.SELECT_LIST(1, 2009_08, 'LOV_QER', null, 'Y') "2009_08", 
    HTMLDB_ITEM.SELECT_LIST(1, 2009_11, 'LOV_QER', null, 'Y') "2009_11", 
    HTMLDB_ITEM.SELECT_LIST(1, 2010_02, 'LOV_QER', null, 'Y') "2010_02", 
    HTMLDB_ITEM.SELECT_LIST(1, 2010_05, 'LOV_QER', null, 'Y') "2010_05", 
    HTMLDB_ITEM.SELECT_LIST(1, 2010_08, 'LOV_QER', null, 'Y') "2010_08", 
    HTMLDB_ITEM.SELECT_LIST(1, 2010_11, 'LOV_QER', null, 'Y') "2010_11" 
    FROM TAB_REPORTS
    And this is my error msg, I do not understand:

    * Failed to parse the SQL query:
    ORA-00911: invalid character *.

    Where is this invalid character, please?

    THX 4 help,
    Chris

    Hello

    As part of HTMLDB_ITEM. This is a parameter of function - it should be a tank. In addition, if you use a recent version of the APEX, you should use the synonym APEX_ITEM reference HTMLDB_ITEM.

    Here is the statement of HTMLDB_ITEM parameter. SELECT_LIST...

        p_idx         in number,
        p_value       in varchar2 default null,
        p_list_values in varchar2 default null,
        p_attributes  in varchar2 default null,
        p_show_null   in varchar2 default 'NO',
        p_null_value  in varchar2 default '%null%',
        p_null_text   in varchar2 default '%',
        p_item_id     in varchar2 default null,
        p_item_label  in varchar2 default null,
        p_show_extra  in varchar2 default 'YES'
    

    You will see that it is a VARCHAR2 parameter.

    See you soon

    Ben

  • Dynamic query for a report

    Hello
    I have to generate a report that contains a query with the database link. This database link is not pre-programmed and would be taken up in another report which contans a link to this report. If this link value of database for the query could be. Can someone guide me hot to write a dynamic select statement so that I could add value of binding of database running.
    Thank you

    Salman

    Hello Salman,

    You must create a report of "query SQL (PL/SQL function body return SQL query. If you create a normal report of SQL query (using any SQL statement you like - example 1 SELECT FROM DUAL), you can then change the Type of report to this parameter.

    Once this is done, you can then create a string that will build the SQL query, you must - what is done when entering the parameter Source in the region in the region to replace the PL/SQL code. How this string is constructed depends on where your data is and so on, but it's just a case of gettnig correct information and concatenated into a single string that forms the SELECT statement.

    For example:

    DECLARE
     vTABLE VARCHAR2(100);
     vSQL VARCHAR2(1000);
    BEGIN
     vTABLE := 'MYTABLE@OTHERDB';
     vSQL := 'SELECT * FROM ' || vTABLE;
     RETURN vSQL;
    END;
    

    The PL/SQL above to build a string:

    SELECT * FROM MYTABLE@OTHERDB
    

    who then returned to Apex to generate the report. Also you should probably select the option "use generic column names (analysis of query runtime only)" under this.

    Andy

Maybe you are looking for

  • Satellite L655 - 130G: what is the 130 GB partition for?

    You are not sure if it's ok to ask here?There are a score of 130 GB not used not drank the system? and I think that it is not for the recovery software,What it is? Can I use it?

  • Machine learning toolkit - KNN 91 error

    Hello I am currently using TRM for KNN classification and I get an error: Error 91 occurred in the variant for the data in NILabs_MLT.lvlib:ml_Distance_L1 Norm.vi:280001-> Test_KNN.vi... Possible reasons: LabVIEW: The variant data type is not compati

  • Update Windows SP3 official website there is a banker virus

    I have download 02/05/2012 windows SP3 update on the official website and the virus scanner... and find virus banker... How do you explain it? where we get a version without virus?

  • Can MS gives the type of my OS serial key?

    I forgot to watched my type of XP' its my laptop. But I have the serial number. Can this series gives information on my type of BONE? What is Home or Pro Edition...

  • Light red Internet WAG160N

    Hi, what it is. I am installing a WAG160N to my Win 7 32 bit Pro system and I have a red internet light and im not getting on the internet. I know that my internet is ok, because I reinstalled my BT home hub to get on this forum. Anyone know what is