ODI: Using Table Name in Dynamic filters

We have a requirement, where the filters have to be dynamically generated and applied on the source system data stores.
The requirement can be best explained by the below example.
I have EMPLOYEE and DEPARTMENT table as the source datastores and EMP_DEPT (flat table) as the target datastore.
The filter condition will be updated now and then by the admin in a table. They would like to run the integration interface with the condition mentioned in the table.
Metadata table and sample data: (DY_FILTERS)
TABLE_NAME | INTERFACE_NAME | CONDITION
EMPLOYEE | EMP_DEPT | EMPLOYEE.EMPLOYEE_NAME LIKE 'A%'
DEPARTMENT | EMP_DEPT | DEPARTMENT.DEPARTMENT_ID = 10
So now the interface has to run with the conditions 'EMPLOYEE.EMPLOYEE_NAME LIKE 'A%' and DEPARTMENT.DEPARTMENT_ID = 10.
To achieve, the best possible solution I can think of is, I have defined a variable for the dynamic filter and under the refresh section and I am planning to use the following query:
SELECT CONDITION FROM DY_FILTERS WHERE INTERFACE_NAME = <%=odiRef.getPop("POP_NAME")%> AND
TABLE_NAME = ***************.
I was able to pick the interface that is currently involved by using getPop() method where as I dont have clue for getting the table name.
Please share with me, if you have answer. Also if you have any other way to achieve this, please share the same.
Note: The actual scenario is more complex than the example given above. But the crux of the requirement is very well covered in the example.
Edited by: 986046 on Feb 14, 2013 2:06 PM

Hi,
If you've only one source datastore in your interface, you can retrieve it's name with <%=odiRef.getSrcTablesList("[RES_NAME]", "")%>.
If you have more than one source it will list all you sources.
However I can't see when you plan to refresh your variable. getSrcTablesList won't work before/after the interface execution.
Regards,
JeromeFr

Similar Messages

  • Problem in using table name dynamically in PL/SQL

    I tried to create a procedure to use table name dynamically and got the following error. Anything wrong with my procedure?
    NFADV>declare
      2   cnt number;
      3   cursor cur is select table_name from user_tables where table_name in ('EMP','DEPT');
      4  begin
      5   for c1 in cur
      6   loop
      7    execute immediate select count(*) into cnt from c1.table_name;
      8      dbms_output.put_line('Count is : '||cnt);
      9   end loop;
    10  end;
    11  /
    declare
    ERROR at line 1:
    ORA-06550: line 7, column 21:
    PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
    ( - + case mod new not null <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    <a string literal with character set specification>
    <a number> <a single-quoted SQL string> pipe
    <an alternatively-quoted string literal with character set specification>
    <an alternatively-quo
    ORA-06550: line 8, column 5:
    PLS-00103: Encountered the symbol "DBMS_OUTPUT"
    ORA-06550: line 8, column 45:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    . ( , * % & - + / at mod remainder rem <an identifier>
    <a double-quoted delimited-identifier> <an exponent (**)> as
    from into || multiset bulkThanks and Regards
    Kaustubh

    Hi,
    The wrong part is in execute immediate, it should be as follows:
    execute immediate ('select count(*) from '|| c1.table_name)
    into cnt
    (not tested)
    Regards
    AK

  • How to use table name dynamically in report  procedure

    Hello every body
    I want to use table name dynamically means at runtime i want to pass table name.
    I can do this by lexical parameter in main query.
    But my problem is that i want to crate new format trigger or new function that use 1 cursor in which that lexical parameter : table name is used.
    so how to do that?
    i can not use that lexical parameter it is giving error.
    please help me how to do that.

    Call a database function which you pass the lexical parameter. Then in the database function you use dynamic sql or the execute immediate option to build the SQL string.
    Return the information from this function to build your business logic on in your format trigger.
    Marcos

  • How to find the list of un used table names in a schema?

    Hi,
    I have a doubt in Oracle. The doubt is that If we are using any tables in Function Or Proc.... Then...We can list all those used table names from USER_DEPENDENCIES system table. Right...
    But, If the table is used with Execute Immediate Statement, then, those table names are not coming out with USER_DEPENDENCIES system table. Because they are identified at run time and not compile time.
    It is fine. And I agree.. But, If I want to list out those tables also...then...How to do? Any idea?
    I think ‘USER_SOURCE’ system table may not be the right one. If there is any other system table avails for this purpose...then..it would be very grateful to extract right...
    So I am wanting that exact system table.
    Please let me know about this, if you have any idea or check with your friends if they have any idea.
    Regards,
    Subramanian G

    Hi Guys,
    Thanks for all your answers.
    Yes....You are all right. We can list out the used tables upto certain extent. Anyhow, I have done some R&D to derive the SQL's which is given below:
    SELECT TABLE_NAME FROM USER_TABLES
    MINUS
    SELECT DISTINCT UPPER(REFERENCED_NAME)
    FROM user_dependencies
    where
    referenced_type='TABLE' and UPPER(NAME) in
    select distinct UPPER(object_name) from user_objects where UPPER(object_type) in
    'MATERIALIZED VIEW',
    'PACKAGE',
    'PACKAGE BODY',
    'PROCEDURE',
    'TRIGGER',
    'VIEW',
    'FUNCTION'
    UNION
    SELECT UT.TABLE_NAME FROM
    SELECT TABLE_NAME FROM USER_TABLES
    MINUS
    SELECT DISTINCT UPPER(REFERENCED_NAME)
    FROM user_dependencies
    where
    referenced_type='TABLE' and UPPER(NAME) in
    select distinct UPPER(object_name) from user_objects where UPPER(object_type) in
    'MATERIALIZED VIEW',
    'PACKAGE',
    'PACKAGE BODY',
    'PROCEDURE',
    'TRIGGER',
    'VIEW',
    'FUNCTION'
    AND REFERENCED_OWNER=(SELECT sys_context('USERENV', 'CURRENT_SCHEMA') FROM dual)
    ) UT,
    ( SELECT * FROM USER_SOURCE
    WHERE NAME IN
    ( SELECT DISTINCT NAME FROM USER_SOURCE
    WHERE TYPE NOT IN ('TYPE')
    AND
    UPPER(TEXT) LIKE '%EXECUTE IMMEDIATE%'
    ) US
    WHERE
    UPPER(US.TEXT) LIKE '%'||UPPER(UT.TABLE_NAME)||'%'
    AND
    (UPPER(US.TEXT) NOT LIKE '%--%')
    The above SQL Query can list out unused tables by checking the Dynamic SQL Statement also upto some level only.
    Once we extracted the list of unused tables, having a manual check would be also greater to verify as it is should not impact the business applications.
    Regards,
    Subramanian G

  • Dynamic table names without dynamic sql?

    I am trying to figure out a way to use table names as variables without using dynamic sql.
    So for instance, I have...
    execute immediate 'INSERT INTO '||vTABLE||' VALUES ('test')';
    and
    execute immediate 'INSERT INTO TABLE1 SELECT * FROM '||vTable;
    Is there any other way to do these without the dynamic sql in Oracle 10.2g?

    I am trying to figure out a way to use table names as variables without using dynamic sql. Well I guess it makes a change from perpetual motion machines or cold fusion.
    Are you doing this as a purely academic exercise or do you have something against dynamic SQL?
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Creating Report using EPM Functions with Dynamic Filters

    Hi All,
    I am new to BPC, In BPC 7.5 i seen like we can generate EPM report using EVDRE function very quickly and easy too. Is the same feature is existing in BPC 10.0 ? if no how can we create EPM reports using EPM Functions with Dynamic Filters on the Members of the dimension like in BPC 7.5.
    And i searched in SDN, there is no suitable blogs or documents which are related to generation of Reports using EPM Functions. All are described just in simple syntax way. It is not going to be understand for the beginners.
    Would you please specify in detail step by step.
    Thanks in Advance.
    Siva Nagaraju

    Siva,
    These functions are not used to create reports per se but rather assist in building reports. For ex, you want to make use of certain property to derive any of the dimension members in one of your axes, you will use EPMMemberProperty. Similary, if you want to override members in any axis, you will make use of EPMDimensionOverride.
    Also, EvDRE is not replacement of EPM functions. Rather, you simply create reports using report editor (drag and drop) and then make use of EPM functions to build your report. Forget EvDRE for now.
    You can protect your report to not allow users to have that Edit Report enabled for them.
    As Vadim rightly pointed out, start building some reports and then ask specific questions.
    Hope it clears your doubts.

  • Unable to  use Table name in a variable

    Hi,
    I am trying to build a select statement which uses table name in a variable. Please help me in building such statements.
    Regards
    Kishore

    Hi,
    I am trying to build a select statement which uses table name in a variable. Please help me in building such statements.
    Regards
    Kishore

  • Can I use table function inside Dynamic query ?

    Dear Gurus,
    I have following code
    DECLARE
    TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
    OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
    QUERY_STRING VARCHAR2(4000);
    BEGIN
    OtherNoList := CRITERIA_LIST_TABLE();
    SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
    QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
    'SELECT C1,'||
    'C2 '||
    'FROM TAB1 ,'||
    'TABLE( '||
              'CAST (OtherNoList AS CRITERIA_LIST_TABLE) '||
                   ') OTHRNOS '||
    'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
    DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
    EXECUTE IMMEDIATE QUERY_STRING;
    END;
    Can I use Table function inside dynamic query.
    Thanking in advance
    Sanjeev

    Try:
    DECLARE
    TYPE CRITERIA_LIST_TABLE AS TABLE OF VARCHAR2(20);
    OtherNoList CRITERIA_LIST_TABLE; /* CRITERIA_LIST_TABLE is index by table*/
    QUERY_STRING VARCHAR2(4000);
    BEGIN
    OtherNoList := CRITERIA_LIST_TABLE();
    SELECT DISTINCT REGEXP_SUBSTR('1,5,6,4', '[^\,]+',1, LEVEL ) BULK COLLECT INTO OtherNoList
    FROM DUAL
    CONNECT BY LEVEL <= REGEXP_COUNT('1,5,6,4', '\,') + 1 ;
    QUERY_STRING := 'INSERT INTO TAB1 (C1,C2) '||
    'SELECT C1,'||
    'C2 '||
    'FROM TAB1 ,'||
    'TABLE( '||
    'CAST (:OtherNoList AS CRITERIA_LIST_TABLE) '||
    ') OTHRNOS '||
    'WHERE TAB1.C1 = OTHRNOS.COLUMN_VALUE ';
    DBMS_OUTPUT.PUT_LINE('Query String is '||QUERY_STRING);
    EXECUTE IMMEDIATE QUERY_STRING using OtherNoList;
    END;p.s. not tested
    Amiel Davis

  • Using Table name in Read statement dynamically

    Hi Experts,
    I have the following requirement.
    Based on a country code say "A" , "B", "C" and based on this i have to read different internal tables lt_tabA, lt_tabB and lt_tabC.
    The table key can be given dynamically, but how can i use the internal table name dynamically without using if statements.
    Please help.
    Thanks!
    Best Regards,
    Gayathri

    Hi Gayathri,
    something like
    DATA:
        lt_t100 TYPE TABLE OF t100,
        lt_t000 TYPE TABLE OF t000.
      FIELD-SYMBOLS:
        <table> TYPE table,
        <rec>   TYPE ANY,
        <field> TYPE ANY.
      SELECT:
        * INTO CORRESPONDING FIELDS OF TABLE lt_t100 FROM t100 UP TO 10 ROWS,
        * INTO CORRESPONDING FIELDS OF TABLE lt_t000 FROM t000 UP TO 10 ROWS.
      CASE abap_true.
        WHEN space.
          ASSIGN  lt_t100 TO <table>.
        WHEN OTHERS.
          ASSIGN  lt_t000 TO <table>.
      ENDCASE.
      READ TABLE <table> with key ('MANDT') = sy-mandt ASSIGNING <rec>.
    Regards,
    Clemens

  • Use table name in UPDATE statement as variable

    Hi All,
    I am using ORACLE 9i AIX base. I want to write following procedure:
    PROCEDURE update_header (
    p_care_msg_nbr IN NUMBER,
    p_care_msg_id IN NUMBER,
    p_care_msg_gkey IN NUMBER,
    p_old_status IN VARCHAR2,
    p_new_status IN VARCHAR2
    IS
    l_table varchar2(50);
    BEGIN
    l_table := 'CARE_EDI_MESSAGES';
    UPDATE '&l_table'
    SET status = p_new_status,
    changed = sysdate,
    changer = user
    WHERE care_msg_no = p_care_msg_nbr
    AND care_msg_id = p_care_msg_id
    AND gkey = p_care_msg_gkey
    AND status = p_old_status;
    END;
    I want to give the table name by passing value in a variable or parameter. Is it the write way or can I do this function in any other way.
    Pleae tell me in urgency.
    Thanks & Regards
    Hassan Raza

    This implies that you have several tables with identical or near identical structures, otherwise you will get errors if any of the mentioned columns do not exist in the table passed but ...
    You cannot use a substitution variable that way. Oracle will ask for a value when you try to create the procedure, and compile what ever value you supply into the procedure viz.
    SQL> CREATE PROCEDURE p AS
      2  l_id NUMBER;
      3  BEGIN
      4     SELECT id INTO l_id FROM &t;
      5  END;
      6  /
    Enter value for t: T
    old   4:    SELECT id INTO l_id FROM &t;
    new   4:    SELECT id INTO l_id FROM T;
    Procedure created.
    SQL> SELECT text FROM user_source WHERE name = 'P'
      2  ORDER BY line;
    TEXT
    PROCEDURE p AS
    l_id NUMBER;
    BEGIN
       SELECT id INTO l_id FROM T;
    END;Even if that is the effect you want, note that there are no quotes around the substitution variable in the CREATE statement.
    If you want to be able to pass the name of the table to the procedure, then you need to make the table name a parameter, then build the sql statement and execute it using EXECUTE IMMEDIATE. Something more like:
    PROCEDURE update_header (p_care_msg_nbr  IN NUMBER,
                             p_care_msg_id   IN NUMBER,
                             p_care_msg_gkey IN NUMBER,
                             p_old_status    IN VARCHAR2,
                             p_new_status    IN VARCHAR2,
                             p_table         IN VARCHAR2) IS
    l_sqlstr VARCHAR2(4000);
    BEGIN
       l_sqlstr := 'UPDATE '||p_table||' SET status = :b1 '||
                   'changed = sysdate, changer = user '||
                   'WHERE care_msg_no = :b1 and care_msg_id = :b3 and '||
                   'gkey = :b4 and status = :b5';
       EXECUTE IMMEDIATE l_sqlstr
          USING p_new_status, p_care_msg_nbr, p_care_msg_id, p_care_msg_gkey, p_old_status;
    END;HTH
    John

  • To know schema using table name

    Can I know the schema using the table name.

    I have a handy if probably overcomplicated script for this:
    SQL> @which v$session
    Objects matching 'v$session':
    Name                                       Type                OWNER                Granted? Synonym
    V$SESSION                                  SYNONYM             PUBLIC
    SYS.V_$SESSION (VIEW)
    SQL> @which dual
    Objects matching 'dual':
    Name                                       Type                OWNER                Granted? Synonym
    DUAL                                       SYNONYM             PUBLIC
                                               TABLE               SYS                  Yes      DUAL
    SYS.DUAL (TABLE)
    www.williamrobertson.net/scripts/which.sql

  • Use Table Name in Summary Table

    Hi,
    I am looking for a way to use the names of tables in another table.
    eq. I have tables named after the months. And I want to use this name in another table in which i summarize all the facts from the mont tables. Is there a way to refer to the table name?
    Thanks in Advance Paul

    Hi Jerrold
    It seems that we made the same interpretation.
    I just wished to give a soluce allowing the user to change easily the name of the referenced table.
    In my sample, if I add a new table, the required task is just to add it's name in the first column and replicate the original formula with no change.
    For a single formula, it changes quite nothing but if we use many cells, it's an efficient time saving.
    I just gave a really bare example.
    Here is one with more referenced cells.
    Don't worry, the separator is semi-colon because I ran Numbers in English on my French system
    Yvan KOENIG (VALLAURIS, France.) mardi 11 août 2009 17:19:46

  • How to Use Table name at run time

    Hi All
    I have created a function that accepts a table name as a parameter and returns the maximam sequence number, but in my function body i can not write the parameter name as a table i.e.
    CREATE OR REPLACE FUNCTION MAX_ID(TAB_NAME Varchar)
    RETURN Number IS
    max_id Number;
    CURSOR curSalPoint IS
         SELECT MAX(EMP_NUMBER)
         FROM TAB_NAME ;
    BEGIN
    max_id:=0;
    OPEN curSalPoint ;
         FETCH curSalPoint INTO max_id;
         CLOSE curSalPoint;
    RETURN max_id
    END
    But it will give an error saying
    (1):PL/SQL: ORA-00942: table or view does not exist
    for "TAB_NAME"
    Any help would be appreciate ........

    Yes, as i contcatinated table name with the original statement, so you can also continate fields' names with your statment and execute immediate the statement.
    Sorry i forgot this statement in my function, to execute the statement you need to include following statement
    CREATE OR REPLACE FUNCTION MAX_ID(TAB_NAME Varchar)
    RETURN Number IS
    max_id Number;
    query varchar2(200);
    BEGIN
    max_id:=0;
    query:=null;
    query := query || 'select max(empno) into max_id from'|| tab_name;
    EXECUTE IMMEDIATE query;
    RETURN max_id;
    END;
    Message was edited by:
    Salman Qureshi

  • How to use table name as variable in insert statement

    Hi,
    I want to insert data from the cursor into the table and I want to submit table name as a variable. I tried the code below but it's not working. Any ideas how to solve this problem? Thx
    DECLARE
    v_new_table_name VARCHAR2(30) := 'test';
    --open cursor   
    CURSOR ACM IS
    SELECT *
    FROM DWH.CLI_DIMENSION@SLSPDW CLI
    WHERE where_clause
    FROM some_table;
    BEGIN
    FOR REC_ACM IN ACM LOOP
    EXECUTE IMMEDIATE 'INSERT INTO ' || v_new_table_name || ' VALUES REC_ACM'; --table name as a variable in which the data from cursor will be inserted
    V_ROWCOUNT := V_ROWCOUNT + 1;
    IF MOD(V_ROWCOUNT, 100) = 0 THEN --this feature commits after 100 rows.
    COMMIT;
    END IF;
    END LOOP;
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Number of inserted records:' || V_ROWCOUNT);
    END;

    Try this and let me know if it works. I have not tested it so I can not say for sure.
    DECLARE
      v_new_table_name VARCHAR2(30) := 'test';
      CURSOR ACM IS
        SELECT * FROM DWH.CLI_DIMENSION@SLSPDW CLI
                WHERE where_clause
                FROM some_table;
      BEGIN
      loop
       fetch ACM INTO REC_ACM
       exit when ACM%NOTFOUND;
       EXECUTE IMMEDIATE 'INSERT INTO ' || v_new_table_name || ' VALUES REC_ACM';
       V_ROWCOUNT := V_ROWCOUNT + 1;
       IF MOD(V_ROWCOUNT, 100) = 0 THEN
        COMMIT;
       END IF;
      end loop;
      COMMIT;
      DBMS_OUTPUT.PUT_LINE('Number of inserted records:' || V_ROWCOUNT);
      END;

  • Writing procedure using table name as parameter

    I want to write a procedure to sample size any table. It could be employees, departments, etc. It will not know anything about the table (what table, columns, datatypes) until it is called.
    I want to invoke it sample_size(table_name_in, table_name_out, sample_sz).
    Table_out will be created and empty. It will determine the columns to be selected from table_in.
    It is a given that all columns in table_out exist in table_in with same name/datatypes.
    Pseudocoding:
    determine increment using size of table_in and sample_sz
    build out_var list from table_out
    select out_list from table_in
    for (rows in table_in) loop by increment
    insert into table_out
    end for
    I wrote function to get cursor:
    create or replace
    FUNCTION get_cursor
    (table_nm IN VARCHAR2,
    flds IN VARCHAR2)
    RETURN sys_refcursor
    IS
    cur sys_refcursor;
    vQry VARCHAR2(4000);
    BEGIN
    vQry := 'SELECT ' || flds || ' FROM ' || table_nm;
    OPEN cur FOR vQry;
    RETURN cur;
    END get_cursor;
    What I cannot figure out is how to define rowtype in calling procedure:
    PROCEDURE
    sample_size( table_in IN VARCHAR2,
    table_out IN VARCHAR2,
    sample_sz IN NUMBER )
    IS
    c1 sys_refcursor;
    vInto VARCHAR2(4000);
    BEGIN
    -- code to get variables desired into variable vInto (I know how to do this)
    c1 := get_cursor(table_in,vInto);
    LOOP
    FETCH c1;
    EXIT WHEN c1%NOTFOUND;
    -- code to decide wether to insert row into table_out
    END LOOP;
    CLOSE c1;
    END sample_size;
    I get error on FETCH c1; line:
    Error(47,15): PLS-00103: Encountered the symbol ";" when expecting one of the following: . into bulk
    All discussions I found about subject will have something similar to:
    Rec emp%rowtype
    and then
    fetch c1 into Rec
    None of the discussions showed me how to process an unknown table.
    If tomorrow someone tells me to sample_size table CITIES, I want to use function without having to change it.
    This is my first post. I hope I gave enough information. Thanks for any answer.

    Welcome to the forum.
    If yours is not an exercise why you don't want to use just
    <tt><b>[url http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#SQLRF01702]select * from table_name {sample_clause}</b></tt> ;)
    Regards
    Etbin

Maybe you are looking for

  • How to find XSD file? XML to ABAP using XSLT convertor

    Hi Gurus, I am trying to convert an XML file to ABAP internal tables using an XSLT transformation. I used the code posted by Durairaj (XSLT program Y_XML_2_ITAB_SIMPLE as mentioned in the link: [Y_XML_2_ITAB_SIMPLE|Parse data to Internal Table;) and

  • Help with return statements

    Can someone explain to me what a return statement does exactly and how I would use it to return a value in the follwoing type of program. Its a array making program that allows up to 25 values with the value 0 stopping the method. I need to be able t

  • Pkgmap files missing in global zone, can't build non-global zone

    My solaris 10 server is missing the pkgmap files for the packages. As a result, I can't build a non-global zone. Is there a way to recreate the pkgmap files? The OS on the Solaris 10 server was installed via jumpstart (initial install). However, the

  • Check what is the last operation for a table

    Hi expert, I need to check what is the last operation for a table ? ( such as insert/delete/truncte.......), will show me the function or sql to get that? Many Thanks,

  • Java.lang.NoClassDefFoundError: Login: com/sun/gi/comm/users/client/JMEClie

    I am getting this error when i am ruunning my j2me program in eclipse 3.2 >>>> The default color phone emulator og the j2me disappear after launching... Can anybody please tell whats the problem? <Error code> java.lang.NoClassDefFoundError: Login: co