Bind the Variable Table name in the query of VO

I have a VO that must have its clause defined dynamically at run time.  I have a string bind variable defined with a default value that is referenced in the query of the VO.  However, JDeveloper allow me to leave the definition of the query of the view object when the from clause is a variable binding, even if the binding variable has the default value.

For example.

Select

« X »

Of

: TABLE

where

1 = 1

The variable binding TABLE is defined as a string with a default value of the 'double '.  Did I miss something in the definition of the VO?

Thank you

Hello

I suggest you to dynamically set the query of the view object.  This does not meet your requirements.

xxVo.setQuery ();

Tags: Oracle Applications

Similar Questions

  • How to use a value in a variable as a table name in a query?

    I fetch a value in a variable like:

    < select application_short_name in the fnd_application l_appl_nm where application_id =: p_appl_id >

    Now, I need to use the value retrieved in the variable "l_appl_nm" as a name of partition table in the following query.

    Anyone can guide me please on this concept.

    Expected answers as soon as possible!

    Create dynamic SQL statements with your variable, and then run this SQL with the "EXECUTE IMMEDIATE" command.

    Thank you

    Lokesh

  • Bind the Variable in a dynamic query

    The procedure below uses a variable binding for the deptno and run it with a ref cursor The expected result is to display the ename from EMP for the deptno passed for the p_deptno parameter, but the procedure fails with an exception.

    CREATE OR REPLACE PROCEDURE dynamic_query(p_deptno NUMBER)
    AS
        lv_deptno number(4);
    --    l_lookup_type    VARCHAR2(30):='PBAMERICAS_CO';
        lv_query VARCHAR2(15000) :=' SELECT  ename,''Year'' from emp where deptno='|| p_deptno;
        lv_cursor  SYS_REFCURSOR;
        lv_lookup VARCHAR2(20);
        lv_emp_rec emp%rowtype;
        lv_ename VARCHAR2(10);
        lv_year   VARCHAR2(10);
    BEGIN
        dbms_output.put_line(lv_query);
        OPEN lv_cursor FOR lv_query USING p_deptno ;
        Loop
            FETCH lv_cursor INTO lv_ename,lv_year;
            dbms_output.put_line(lv_ename || ',' ||lv_year);
          EXIT WHEN lv_cursor%NOTFOUND;
         END LOOP;
        CLOSE lv_cursor;
    END dynamic_query;       
    
    
    

    
    
    SQL> exec dynamic_query(10);
    SELECT  ename,'Year' from emp where deptno=10
    BEGIN dynamic_query(10); END;
    
    
    *
    ERROR at line 1:
    ORA-01006: bind variable does not exist
    ORA-06512: at "APPS.DYNAMIC_QUERY", line 13
    ORA-06512: at line 1
    
    
    
    
    
    
    

    I can change the code slightly and change the where clause to work but wanted to know what am I did wrong which makes the procedure fails with the above code.

    CREATE OR REPLACE PROCEDURE APPS.dynamic_query(p_deptno NUMBER)
    AS
        lv_deptno number(4);
       lv_query VARCHAR2(15000) :=' SELECT  ename,''Year'' from emp ' ;
        lv_cursor  SYS_REFCURSOR;
        lv_lookup VARCHAR2(20);
        lv_emp_rec emp%rowtype;
        lv_ename VARCHAR2(10);
        lv_year   VARCHAR2(10);
    BEGIN
    
    
        IF p_deptno IS NOT NULL THEN
            lv_query := lv_query || ' Where deptno =' || TO_CHAR(p_deptno);
         END IF;
             dbms_output.put_line(lv_query);
        OPEN lv_cursor FOR lv_query  ;
        Loop
            FETCH lv_cursor INTO lv_ename,lv_year;
            dbms_output.put_line(lv_ename || ',' ||lv_year);
          EXIT WHEN lv_cursor%NOTFOUND;
         END LOOP;
        CLOSE lv_cursor;
    END dynamic_query;
    /
    
    

    PS: I use the table EMP for this example includes so not CREATE TABLE and INSERT.

    The procedure below uses a variable binding

    No, it isn't.

    You're just concatenation of the value of p_deptno in the query, such as a literal.

    It's using a variable binding:

    lv_query VARCHAR2 (15000): = ' 'year', SELECT ename from emp where deptno =: 1';

    Then, the variable may be correctly bound (by post) via the USING clause.

  • the variable name of database query to SQL Server using the Oracle database link

    Hi all

    I have an ApEx 4.1 application running on x 64 (11.2.0.1) 11g on Windows Server 2008 x 64, and I have a few points of data integration with SQL (2005 and 2008) server that I need to create. I have configured the database with dg4odbc link and it works perfectly... I can run queries on the SQL Server database without any problem using the database link.

    However, there is a scenario where the SQL Server database name is dynamic, and I need to generate on the fly in a PL/SQL block and then use it in a query dynamic SQL (all this in the ApEx). It of wherever I meet problems... when I asked the default database that is based on the ODBC connection and I don't have to specify the name of the database, no problem. But when I need access to one of the several other databases by default, I received the error "invalid table.

    It works well:* (note that 'fv' is the name of my database link)

    v_query1: = "select 'Release Date' from dbo." Schedules@FV where dbo. Annexes. "" SchedID "=: calendar";
    EXECUTE IMMEDIATE v_query1 in rel_date using the grid.




    I then take this rel_date variable, convert a varchar2 (rel_date_char), then use it as the name of the database in the following query...


    _ It returns an error(error ORA-00903: invalid table name)

    v_query2: = "select"PARTNO": rel_date_char.dbo.ProdDetails@fv where 'SchedID' =: calendar and"UnitID"=: unit"
    and 'MasterKey' =: master and "ParentKey" =: parent';

    EXECUTE IMMEDIATE v_query2 in part_number using planning, master, parent unit;



    I also tried using all of the following conditions without result:

    "select"PARTNO"of" | : rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
    "select"PARTNO"of" | rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
    "select"PARTNO"of" | @rel_date_char | '.dbo. ProdDetails@fv where 'SchedID '...
    "select"PARTNO"in @rel_date_char.dbo.ProdDetails @fv where 'SchedID'..."


    Is it possible to do it in PL/SQL?

    Thanks for any help!
    -Ian C.

    Published by: 946532 on July 15, 2012 19:45

    Just did a test using passthrough:

    SQL > set serveroutput on
    SQL > declare
    2 val varchar2 (100);
    3 c whole;
    4 whole nr;
    5. start
    c: 6 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, "select count (*) from EMP");
    8 LOOP
    9 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    10 output when nr = 0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
    12 dbms_output.put_line (val);
    13 end of loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    15 end;
    16.
    24576

    PL/SQL procedure successfully completed.

    SQL > declare
    2 val varchar2 (100);
    3 c whole;
    4 whole nr;
    5. start
    c: 6 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    7 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, ' select count (*) from dbo.) EMP');
    8 LOOP
    9 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    10 output when nr = 0;
    11 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
    12 dbms_output.put_line (val);
    13 end of loop;
    14 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    15 end;
    16.
    24576

    PL/SQL procedure successfully completed.

    So all 3 ways work for me.

    Published by: kgronau on July 23, 2012 10:08

    Now, using the variables to make the selection:

    SQL > declare
    2 val varchar2 (100);
    3 c whole;
    4 whole nr;
    5 tabname varchar2 (20): = 'EMP ';
    6 ownr varchar2 (20): = "dbo."
    7 dbname varchar2 (20): = "door";
    Start 8
    c: 9 = dbms_hs_passthrough.open_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3;
    10 dbms_hs_passthrough.parse@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, ' SELECT count (*) FROM ': dbname: '.) ' || ownr | '.'|| tabname | ") ;
    11 LOOP
    12 nr: = DBMS_Hs_Passthrough.fetch_row@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    13 when the exit nr = 0;
    14 dbms_hs_passthrough.get_value@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c, 1, val);
    15 dbms_output.put_line (val);
    16 end loop;
    17 dbms_hs_passthrough.close_cursor@FREETDS_DG4ODBC_EMGTW_11_2_0_3 (c);
    18 end;
    19.
    24576

    PL/SQL procedure successfully completed.

    => instead of executing the statement using the "execute Immediate" we use the PASTHROUGH package to pass the statement to SQL Server.

    Published by: kgronau on July 23, 2012 10:10

  • How not to display variable binding in the query ADF search panel?

    Hello, I use JDeveloper 11.1.2.3.0.

    I have a variable binding in my VO, (* required) that I use in the sql query. I put the value of this variable to link through the groovy expression so I don't have to manually put through my page. It works fine but the problem is that it appears in the query ADF Panel that I created in my page. To do this, I created a ViewCriteria and I've specified to display only 3 (other) fields for the simple search. Apart from the selected 3 variable bind shows here again because its value is set. I tried to remove the ' * required ' of the variable binding in the original Version, but in this case I have problems with my sql query.

    Does anyone know how this variable is not to display in the Panel request ADF?

    Thank you

    Has tried to define the binding to bee hidden variable?

    Controll tips, hint of display = hide

  • selection of a query as a table name in the reports

    Greedings,

    an example to explain what im trying to do

    allows said
    Query1: = table1. Name | | ' _Nom ';
    This result will be for example "citizen_code".

    what im trying to do is to select the specific query to obtain the required data

    Select code in: Code_P of query1@seconddatabase where...

    is it possible to do something like that?

    Thanks for your time,
    dem

    Hello

    Try to create a query such as this

    SELECT &P_COLUMN_1 COLUMN_1,
    &P_COLUMN_2 COLUMN_2,
    &P_COLUMN_3 COLUMN_3,
    &P_COLUMN_4 COLUMN_4
    FROM &table_name
    

    Note You must create the user settings before you create the query, and also all the column setting and the name of the table must have the valid default value.

    Best regards

    Arif Khadas

  • Using the variable as a schema / table names?

    Hello all-

    For the first time post :)

    I would use PL SQL to do something like this

    --***************RUN MAIN******************
    DEFINE SCHEMA_NAME IS 'SCHEMA_NAME' TANK;.
    SET FINAL_TABLE 'FINAL_TABLE' TANK IS;.
    BEGIN
    SELECT A DISTINCT FROM SCHEMA_NAME COLUMN. FINAL_TABLE
    END

    However, this does not work. I googled and found other ways as the production of a prompt orders, but those who are always in the search string and not the name of the schema or table to run the SQL on. I don't know if this is even possible. Any help would be appreciated.

    Thank you!

    Published by: 813738 on November 19, 2010 11:02

    813738 wrote:
    However, this does not work.

    In SQL, use:

    SELECT DISTINCT COLUMN FROM &SCHEMA_NAME..&FINAL_TABLE;
    

    In PL/SQL, you need to use SELECT INTO (if the query returns exactly one line) or a slider.

    SY.

  • How to get a list of the names of a query table?

    Hello

    I use Oracle 10 g. I have about 100 SQL queries stored in a table. I would like to know if there is an easy way to retrieve the source tables in each query.
    For example:
    I have a query "SELECT * FROM Table1 t1 INNER JOIN Table2 t2 ON t1.col1 = t2.col1.
    This query, I would automatically get a list of tables:
    Table1:
    Table2

    Thanks in advance for your collaboration.

    Best regards
    Beroetz

    This query, I would automatically get a list of tables:

    Make a plan to explain on the query.

    The name of the object will be in the OBJECT_NAME column in your PLAN_TABLE.

    But the name of the object can be a table or an index so you'll need to join the user_objects this name to see if it is a table or index name.

    You will also need to take into account those moments where a query can be satisfied by only using the index. You can always get the name of the table glancing user_indexes.

  • To bind the Variable as being of a literal string value

    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod

    PL/SQL Release 10.2.0.5.0 - Production

    CORE Production 10.2.0.5.0

    AMT for Linux: Version 10.2.0.5.0 - Production

    NLSRTL Version 10.2.0.5.0 - Production

    Hi there, thank in advance. I have a problem when you create a dynamic statement. The problem is in the binding variable': OLD. CUST_NAME'... my question is is there an escape character to treat the affair as a literal string variable?

    {code}

    v_str2: = "' client_name =" ' |' | ' || ': OLD. CUST_NAME';

    EXECUTE IMMEDIATE 'create or replace trigger trg_.

    || SUBSTR (rec_cur.table_name, 1, 26)

    || "before insert or update or delete on.

    || rec_cur. Owner

    || '.'

    || rec_cur.table_name

    || '

    declare

    Start

    If the UPDATE can

    FIFAPPS.ibug.log_errors('||)

    v_str2 | »

    );

    end if;

    end;';

    {code}

    I want the output in a trigger something like this:

    {code}

    If the UPDATE can

    FIFAPPS.ibug.log_errors (' client_name ='|: O LD.) CUST_NAME

    );

    {code}

    Hello

    What is the need of business that you are trying to address?  Before writing any kind or trigger and especially before you dynamically create a lot of triggers, see if Oracle provides a better way to meet your needs, for example, audit.

    If triggers are really justified, and you are looking for just an easy way to crank out a large number of almost identical triggers right now (not something that end users will do all the time), so I suggest SQL * Plus and the substitution variables.  It will be easier to debug writing and debugging, because you won't have to you not so much worried about quotes and concatenation.  For example, if all the triggers are identical except for the diagram, the table name and column name, you can write a simple script that can be used to create an unlimited number of triggers, like this:

    -Trigger_Factory.sql - create trigger standard

    DEFINE schema_name = & 1
    DEFINE table_name = & 2
    DEFINE column_name = & 3

    CREATE OR REPLACE TRIGGER trg_ & table_name
    BEFORE ON INSERT or UPDATE or DELETE &... schema_name table_name
    -' SEO NEW OLD NEW old' is the default, so do not say

    -REFERENCING NEW AS NEW OLD O
    -In this way, you don't have to worry about the bad OLD spelling.
    FOR EACH LINE
    BEGIN
    IF THE UPDATE CAN
    fifapps. IBUG.log_errors (: OLD & column_name);
    ...

    Once you have this course of debugging, you can write another script that calls the script above:

    @trigger_factory fifapps t t_column_key

    @trigger_factory fifapps u colonne_1

    @trigger_factory foo bar column_xyz

    Alternatively, instead of manually create a script like the one above, write a query to do it for you:

    SELECT '@trigger_factory'

    owner

    table_name

    column_name

    From all_tab_columns

    WHERE THE...

  • Select a table returned in the result of the query

    Hi, I'm trying to find a way to query a table name that I'm back to a different query. I am doing this in pure SQL and PL/SQL, if I can.

    Here's the situation. I have a table called FILES, a table called TYPE and an unknown number of different reference tables with different names.

    Each entry in the FILE has a reference to a TYPE id, and each entry type is a varchar that contains the name of a table reference, such as PHOTO_INFORMATION, PDF_INFORMATION or XML_INFORMATION.

    I want to be able to extract the data from the reference table for any data file. So with a file id, I question TYPE to get the name of the reference table (IE, "PHOTO_INFORMATION" back) then the request it is at this table for all of its columns, using the reference id in the FILE table.

    The thing is that I wish it were generic, so that I can just add an entry to AA_TYPE and a new table for this type, and then I can ask her but I want, through the FILE table. The reason is that there are some data that is common for all files, and I would like to that data in one place.

    Here is my paintings, I have two reference tables of the sample to the bottom "AA_FILETYPE1" and "AA_FILETYPE_PHOTO".
    CREATE TABLE  "AA_FILES" 
       (     "FILE_ID" NUMBER, 
         "FILE_NAME" VARCHAR2(4000), 
         "FILE_TYPE" NUMBER, 
         "REFERENCE_ID" NUMBER, 
          CONSTRAINT "AA_TEST_FILE_PK" PRIMARY KEY ("FILE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_TYPE" 
       (     "TYPE_ID" NUMBER NOT NULL ENABLE, 
         "REFERENCE_TABLE" VARCHAR2(4000), 
          CONSTRAINT "AA_TYPE_PK" PRIMARY KEY ("TYPE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_FILETYPE1" 
       (     "REFERENCE_ID" NUMBER, 
         "DATE_MODIFIED" DATE, 
         "SUMMARY" VARCHAR2(4000), 
         "TOTAL_VALUE" NUMBER(5,2), 
          CONSTRAINT "AA_FILETYPE1_PK" PRIMARY KEY ("REFERENCE_ID") ENABLE
       )
    /
    
    CREATE TABLE  "AA_FILETYPE_PHOTO" 
       (     "REFERENCE_ID" NUMBER NOT NULL ENABLE, 
         "DATE_TAKEN" DATE, 
         "CAMERA_NUMBER" VARCHAR2(4000), 
         "WEATHER_CONDITIONS" VARCHAR2(4000), 
         "CONSULTANT_NAME" VARCHAR2(4000), 
          CONSTRAINT "AA_FILETYPE_PHOTO_PK" PRIMARY KEY ("REFERENCE_ID") ENABLE
       )
    /
    Here's an example query I would use:
    select * from (select REFERENCE_TABLE from AA_TYPE where TYPE_ID = AA_FILES.FILE_TYPE) where REFERENCE_ID = AA_FILES.REFERENCE_ID;
    So who withdrew all the columns in the reference given in AA_TYPE table based on an entry in AA_FILES.

    I'm not entirely sure how to do this, or if this is possible even without using PL/SQL.

    I'm open to suggestions on how to achieve what I want with a different design of table, I am a student and I'm not really experienced in database design. (My first design of database class isn't until next year!)

    Thank you very much!

    Hello

    [email protected] wrote:
    Sorry about the confusion about file_id = 3, I meant the insert in the third I've included. I did not indicate the id_fichier in my inserts since it is the main key and it auto increments.

    It is important to post of the CREATE TABLE and INSERT statements that work. All those who want to help you to will want to recreate the problem and test solutions. Also, do not use strings for all entries. If the column is a NUMBER, use a NUMBER in the INSERT statement. If the column is a DATE, use a DATE or a function that returns a DATE.
    So you should post something like:

    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (1, 'test-photo-1.jpg',  1,  1);
    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (2, 'test-xml-1.jpg',    2,  2);
    insert into AA_FILES(FILE_ID, FILE_NAME, FILE_TYPE, REFERENCE_ID) values (3, 'test-photo-2.jpg',  1,  2);
    -- The value file_type=1 immediately above was not in your original data, but seems to be what you meant.
    
    prompt =====  AA_TYPE Table:  =====
    
    insert into AA_TYPE(TYPE_ID, REFERENCE_TABLE) values (1, 'AA_FILETYPE_PHOTO');
    insert into AA_TYPE(TYPE_ID, REFERENCE_TABLE) values (2, 'AA_FILETYPE1');
    
    prompt =====  AA_FILETYPE1 Table:  =====
    
    insert into AA_FILETYPE1 (REFERENCE_ID, DATE_MODIFIED,                 SUMMARY,                                    TOTAL_VALUE)
           values           (1,           TO_DATE ('01-01-02', 'MM-DD-RR'), 'An XML file that has some information about something', '14');
    
    prompt =====  AA_FILETYPE_PHOTO Table:  =====
    
    insert into AA_FILETYPE_PHOTO (REFERENCE_ID, DATE_TAKEN,                 CAMERA_NUMBER, WEATHER_CONDITIONS, CONSULTANT_NAME)
                    values            (1,          TO_DATE ('01-01-01', 'MM-DD/RR'), 'abc123',      'rainy!',         'John Smith');
    insert into AA_FILETYPE_PHOTO (REFERENCE_ID, DATE_TAKEN,                 CAMERA_NUMBER, WEATHER_CONDITIONS, CONSULTANT_NAME)
                    values            (2,          TO_DATE ('01-01-02', 'MM-DD/RR'), 'def456',      'slightly cloudy',  'Jane Jones');
    commit;
    

    To give you my workplace, I'm applying in Application Express. A user has entered the number '3' the file_id (I'm not worried about the distinction between passing in the id_fichier and the name of the file, I just my application one application or the other).

    Now, run a query that will get related data which table it is stored in. I don't know the name of the table at design time, as that particular file may be of any type (each of which has a different table name). However, with a the file_id, I have a file_type (in aa_files) which refers to an entry in aa_type.

    I see. You could add even add new tables after this query is written. As long as the new table has a column named reference_id, and there is a line for the new table in aa_files, the following query should work.

    >

    select FILE_TYPE
    from AA_FILES
    where FILE_ID = 3
    

    I stored the name of the table, I need to ask for the rest of the data in aa_type at design time, so using the file_type value, I can get the name of reference_table:

    select REFERENCE_TABLE from AA_TYPE where FILE_TYPE = 1
    

    In the sample data, you have validated, Type_de_fichier = 2 on the 3rd row. I've changed that in my example 1 revised data.
    Be very careful that your explanation fits your data. You talk to people who know about your application, and it is very easy for them to be induced in error or confusion.

    Now the '1' is here that the first query would return. I would like to use a subquery to combine these two queries into a single (I think?). This second query would return "AA_FILETYPE_PHOTO", which is the reference table.

    So I have the reference table, which is a name of table to another table in my database. It contains the data that I'm actually looking for. I want it for this particular file (file_id 3), and in aa_files, I have a value of "reference_id", which refers to the respective line in the reference table. File_id 3, the reference_id is 2.

    select * from AA_FILETYPE_PHOTO
    where reference_id = 2
    

    If the above query gets me my final data.

    Now, I've been watching substitution values and bind variables, here's another way to explain what I want:

    Explanation step by step below is very useful. It would be more useful if each step uniquely and gavce movement results given the sample data and an example of setting (3 in this case)

    -- get the file_type from aa_files for the desired file
    EXEC :file_type := (select file_type from aa_files where file_id = 3);
    

    That we will call the step step (a) above.
    Step (a) sets: Type_de_fichier 1 (given my corrected sample data)

    -- get the reference table from aa_types using the file_type
    EXEC :reference_table := (select reference_table from aa_type where type_id = :file_type);
    

    That we will call the step step (b) above.
    (B) sets the stage: reference_table to 'AA_FILETYPE_PHOTO '.

    -- get the reference_id from aa_files for the desired file
    EXEC :reference_id := (select reference_id from aa_files where file_id = 3);
    

    That we will call the step step (c) above.
    (C) sets the stage: reference_id 2

    -- using the reference table and reference id for the desired file, get the rest of the data
    select * from :reference_table where reference_id = :reference_id;
    

    Not sure if this makes it more clear or not.

    Yes, it helps a lot.

    Basically I have a table full of table names. How do I write a query that pulls one of these table names and it then queries?

    You need SQL dynamic, because you can't hardcode a table name in the query that you normally would be.
    How dynamic SQL works normally (and the functioning of this example) are that the query is built by using a variable. In SQL * more (as shown below), you can simply use a variable substitution instead an identifier hardcoded, and that's what it takes to make the dynamic query from SQL * more resolves the substitution variables before sending the code for the compiler. I don't know much on the Apex, but I bet there's some way to do dynamic SQL in the Apex, too.
    So the dynamic part here should include step d, since you can't hardcode the name of the table in the query.
    Until we can step (d), then, did they to us to do the steps (a) and (b) to obtain this file name. In the example blelow, I used a separate, preliminary request to get the & table_name...
    Step (c) could be made in the main query, using a subquery or a join. However, I chose to step (c) in the preliminary motion, as well as steps (a) and (b), since it's the same table same step (a). In this way, step (d) must refer to a table.

    Here's (finally) how to make this work in SQL * more:

    ACCEPT     file_id     PROMPT     "Enter the file_id (a number, e.g. 3): "
    
    -- Preliminary Query, to set table_name
    
    COLUMN     reference_id_col     NEW_VALUE     reference_id
    COLUMN     table_name_col           NEW_VALUE     table_name
    
    SELECT  f.reference_id          AS reference_id_col
    ,     t.reference_table       AS table_name_col
    FROM      aa_files     f
    JOIN     aa_type          t     ON     f.file_type     = t.type_id
    WHERE     f.file_id     = &file_id
    ;
    
    --     Main Query
    
    SELECT  *
    FROM     &table_name
    WHERE      reference_id     = &reference_id
    ;
    

    The results, account required to the data from the sample I posted above, and the & file_id 3, are:

    `                      CAMERA_    WEATHER_        CONSULTANT_
    REFERENCE_ID DATE_TAKE NUMBER     CONDITIONS      NAME
    ------------ --------- ---------- --------------- ---------------
               2 01-JAN-02 def456     slightly cloudy Jane Jones
    
  • bind the variable column of v$ sqlarea

    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE     10.2.0.4.0     Production
    TNS for HPUX: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    select to_char(sql_fulltext), bind_data from v$sqlarea where sql_id = '5fwm73ndv5pjp';
    TO_CHAR(SQL_FULLTEXT)                    BIND_DATA
    select vgal.GAFS_DISPLAY_LINE_CD
    from view_gafs_account_line vgal
     where vgal.ACCOUNT_ID =  :p1 and
     vgal.ACCOUNT_LINE_SEQ_CD =  :p2 and 
    vgal.ACCOUNT_TYPE_ID =  :p3 and 
    vgal.PROGRAM_SUMMARY_ID =  :p4     
    I'm not horribly v$ sqlarea. but there were some questions about the application executes a query and get
    no row is returned.

    I find the query in v$ sqlarea but I would like to know what are bind variables, but this column is null.

    This means that the query has been run with null for all bind variables?
    or bind variables not seized for any reason are any?

    v$ sql_bind_capture I bind the value of the variable

    SELECT
       a.sql_text,
       b.name,
       b.position,
       b.datatype_string,
       b.value_string
    FROM
    
      v$sql_bind_capture b,
    
      v$sqlarea          a
    
    WHERE
    
       b.sql_id = 'dpf3w96us2797'
    
    AND
       b.sql_id = a.sql_id;
    
  • The analysis of the query variable

    I am facing a problem when parsing variable query of exit.

    Scenario: -.
    I stored the name of session variable as long as the value of a column in a table.
    Now, I used the cfquery tag and get the result column value that is the name of the session variable. But cold fusion does not analyze this session with its actual value variable.

    Step 1 - Table view using the cfdump tag
    query - Top 1 of 1 lines
    PARAMETERNAME - PARAMETERVALUE
    1 @matterspacename - #SESSION. Matter_space_Name #.

    Step 2 - use cfquery tag to retrieve data from the table: -.

    < name cfquery = "qSendNotification" datasource = "#Database_DSN #" >
    Select
    ParameterName,
    ParameterValue
    Of
    Tbl_EventParameterDetails
    where
    NotificationEventID = 1
    and IsActive = 1
    < / cfquery >

    Step 3 - now using the cfquery output result.
    < cfset event_data = #qSendNotification.ParameterValue # >

    Step 4 - when I used cfdump to view the result of his shows value provided for in: -.

    < cfdump var = "#event_data #" >

    output:-#SESSION. Matter_space_Name #.

    Instead of the actual value of the session variable analysis, it displays the name of the session variable.

    Please help me, how to analyze this session value or if my code is an error, please suggest me another way to handle this situation.

    Thanks in advance




    In short when I dump the query result it shows just the name of the session variable because it is [#Session.Matter_space_Name #] instead of display the value of this variable real session.

    Simply, it comes down to this: you saved the string ' #Session.Matter_space_Name # ' as data in the column parameterValue. If this isn't what you want, return to the inserted code data and change the value. Or perhaps you plan to store the string Session.Matter_space_Name under parameterValue so that you can then get the value with

    Evaluate (qSendNotification.ParameterValue).

  • NEC Bind array Variable on changes in the value of SelectOneRadio

    I have a SelectOneRadio button and a Table. I just set the variable binding of the query that is displayed in the table of selection of option buttons.
    I put the buttons SelectOneRadio autosubmit true and I have a method to the ValueChangeListener destination. In the ValueChangeListener I get the value of the SelectOneRadio and setNamedWhereClauseParam ("bindValue", value); I also added the Id of the SelectOneRadio to the partial relaxation of Tables.

    However the variable binding is still not updated. Y at - it a step I have missed to set the variable in the query binding when you press the SelectOneRadio, run the query and refresh the page so that the update query is displayed.

    I use JDeveloper 10.1.3



    Steve

    Steve,

    You must select the id of the component, not the property of partialtriggers of selectoneradio selectoneradio. When you do this, the components selectoneradio id is 'sor1', then the partialTriggers property must be set to the value 'sor1', it won't lead to EL Expression just a literal value.

    Follow the steps below:

    -Select the table in the structure pane, in the property inspector, select property "partialTriggers".
    -In the menu, select 'Edit' (no generator expressions)
    -In ' change ownership: PartialTriggers dialog, select component selectoneradio and then move it to the selected and then say okay section
    -The id of the component of selectoneradio would be assigned to the property of table partialTriggers
    -To the source of the jspx page, it should be something like partialTriggers = "", if the radio id is sor1, it should be (partialTriggers = 'sor1')

    Jean Lou

  • How to find all the table names that has a particular data

    Hello
    How could I get the names of the tables in a database (for a diagram) which includes "KST6490" data in one of the fields in the table. There are a lot of tables with this
    data. Data type is Varchar2. Thank you.

    Is LIST_NO a VARCHAR2 column? The name would seem to imply that it is a number, but your search parameter is a VARCHAR2. Assuming that everything is a VARCHAR2

    EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' || i.table_name || ' WHERE list_no = ' || p_search
        INTO l_cnt;
    IF( l_cnt > 0 )
    THEN
      dbms_output.put_line( i.table_name );
    END IF;
    

    This requires that the call DBMS_OUTPUT. Put_line with the names of the tables is sufficient for your application - it is generally dubious whose functionality depends on the client application that is configured to read the buffer in that DBMS_OUTPUT writes the code. It also assumes that you have declared a local variable L_CNT to store the number returned by the query.

    Justin

  • Create procedure upsert (name of the existing table, incoming table name)

    Is it possible to create a procedure that makes a merge (upsert) with only two parameters:

    1. Existing Table name - name of table that will have data merged into it.
    2. Incoming Table name - name of the table that has developed data day/news.

    The method would be:

    1. Use primary keys on the "existing" table as the condition links
    2. Fact and update if exists and insert new
    3. no record
    4. no clues
    5. no removal clause

    Oracle 11g

    MERGE < tip > < table_name >

    USING < table_view_or_query >

    (< CONDITION >)

    WHEN MATCHED THEN < update_clause >

    DELETE < where_clause >

    WHEN NOT MATCHED THEN < insert_clause >

    [ERRORLOG < log_errors_clause > < reject limit < integer | unlimited >];

    < table_name > - from input parameter

    < table_view_or_query > -socket input parameter

    < condition > - primary key links (how search a single/multiple primary keys and return the list?)

    < update_clause > - update all columns (other than KP, how to get and use a dynamic list of columns)

    < where_clause > - not used

    < insert_clause > - insert new records for all columns (including the PK (s))

    declare

    p_source varchar2 (30): = "EMP_X";

    p_target varchar2 (30): = "EMP_Y";

    query varchar2 (32000);

    function get_cols (p_table in varchar2) return varchar2 is

    VARCHAR2 (32000) retval;

    Start

    Select the Group (order of column_id) listagg (column_name, ',')

    in retval

    of user_tab_cols

    where table_name = p_table

    Table_name group;

    Return retval;

    end;

    function get_keys (p_table in varchar2) return varchar2 is

    VARCHAR2 (4000) retval;

    Start

    Select listagg (cc.column_name, ',') in the Group (order by cc.position)

    in retval

    from user_constraints c,.

    user_cons_columns cc

    where cc.table_name = p_table

    and c.constraint_type = 'P '.

    and cc.table_name = c.table_name

    and cc.constraint_name = c.constraint_name

    C.table_name group;

    Return retval;

    end;

    function merge (p_merge1 varchar2, p_merge2 varchar2, p_link varchar2) return varchar2 is

    Merge1 varchar2 (32000): = p_merge1 | «, » ;

    merge2 varchar2 (32000): = p_merge2 | «, » ;

    VARCHAR2 (32000) retval;

    Start

    then merge1 is not null

    loop

    retval: = retval | » t.'|| substr (Merge1, 1, InStr (Merge1, ',') - 1) |'s =.' | substr (merge2, 1, InStr (merge2, ',') - 1);

    Merge1: = substr (merge1, instr(merge1,',') + 1);

    merge2: = substr (merge2, instr (merge2, ',') + 1);

    If merge1 is not null then

    retval: = retval | p_link;

    end if;

    end loop;

    Return retval;

    end;

    Chopper (p_cols p_keys varchar2, varchar2) return varchar2 is

    passes varchar2 (32000): = ', '. p_cols | «, » ;

    keys varchar2 (32000): = ', '. p_keys | «, » ;

    VARCHAR2 (32000) retval;

    Start

    While the keys! = «, »

    loop

    If instr (passes, substr (keys, 1, instr(keys,',',1,2))) = 1 then

    cols: = substr (collars, instr(cols,',',1,2));

    on the other

    cols: = substr (passes, 1, instr (passes, substr (keys, 1, instr(keys,',',1,2))) | substr (collars, InStr (collars, ',', InStr (passes, substr (Keys, 1, InStr(Keys,',',1,2))), 2) + 1);)

    end if;

    keys: = substr (keys, instr(keys,',',1,2));

    end loop;

    return trim (both ',' collar);

    end;

    Start

    query: = 'merge'. p_target |' t ' |' using (select ' | get_cols (p_source): ' from ' | p_source |') s '.

    ' on ('|) Merger (get_keys (p_target), get_keys (p_source), 'and') |') ' ||

    "When matched then update set ' | '. Merger (Chopper (get_cols (p_target), get_keys (p_target)), Chopper (get_cols (p_source), get_keys (p_source)), ',').

    «When not matched then insert ('|)» get_cols (p_target) |') values (s.'|) Replace (get_cols (p_source),', ', ', s') |') ';

    dbms_output.put_line (Query);

    end;


    Fusion in EMP_Y t using (select EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO EMP_X) s on (t.EMPNO = s.EMPNO and t.ENAME = s.ENAME) when matched then update set t.JOB = s.JOB, t.MGR = s.MGR, t.HIREDATE = s.HIREDATE, t.SAL = s.SAL, t.COMM = s.COMM, t.DEPTNO = s.DEPTNO when not matched then insert (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO) values (s.EMPNO, s.ENAME, s.JOB, s.MGR, s.HIREDATE, s.SAL, s.COMM, s.DEPTNO)

    Concerning

    Etbin

Maybe you are looking for