Dynamic Tag Query  with dynamic tag name.

Hi,
In our implementation we have 10+ users. Each one want to monitor only one production line ( eg. one tag value ) in the dashboard by default when they login.
I was able to design this requirement CONCEPTUALLY but facing some trouble technically.
Here is my issue.
Tagname will be coming from one of the BLS Transaction input parameters (Transaction.Tagname). I am able to build tag query using xMII Tag Query block, able to configure repeater. Here is the spot where I was struck. While assigning tag value to XML Row
i.e IlluminatorRow_0.Tagvalue = Repeater_0.Output{/Row/AssetUtil1}.
In the above assignment link it requires a hardcoded tagname. In my case it will be dynamic. I tried different ways like
1. IlluminatorRow_0.Tagvalue = Repeater_0.Output{/Row/@Transaction.Tagname}.
2.IlluminatorRow_0.Tagvalue = Repeater_0.Output{/@Transaction.Tagname}.
But no luck.
Can someone help in how to do this dynamic tagname assignment.
Thanks,
Srinivasa.

Hi Srinivas,
another option is to use "Dynamic Links" which from your sample code is what you were trying to do. For this, the proper syntax is:
Repeater_0.Output{/Row/#Transaction.Tagname#}
Make sure that the tag name you pass to the historian is the same as the tag name returned by the historian as part of the data set, and make adjustments for that. For example, some historians escape non-alphanumeric characters when they process your request (e.g. passing "abc.def 12-rt" as the tag name can be returned from the historian as "ABC.DEF_12_RT", etc.).
Hope this helps,
Sascha

Similar Messages

  • Dynamic select query with dynamic where condition

    Hi all,
    I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
    Please advice, if there is any other way to achieve this requirement.
    Thanks,
    Sanket Sethi
    Code***************
    PARAMETERS: p_tabnam      TYPE tabname,
                p_selfl1      TYPE edpline,
                p_value       TYPE edpline,
                p_where1      TYPE edpline .
    DATA: lt_where    TYPE TABLE OF edpline,
          lt_sel_list TYPE TABLE OF edpline,
          l_wa_name   TYPE string,
          ls_where    TYPE edpline,
          l_having    TYPE string,
          dref        TYPE REF TO data,
          itab_type   TYPE REF TO cl_abap_tabledescr,
          struct_type TYPE REF TO cl_abap_structdescr,
          elem_type   TYPE REF TO cl_abap_elemdescr,
          comp_tab    TYPE cl_abap_structdescr=>component_table,
          comp_fld    TYPE cl_abap_structdescr=>component.
    TYPES: f_count TYPE i.
    FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
    *                <ls_outtab> TYPE ANY,
                    <l_fld> TYPE ANY.
    struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
    elem_type   ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
    comp_tab = struct_type->get_components( ).
    comp_fld-name = 'F_COUNT'.
    comp_fld-type = elem_type.
    APPEND comp_fld TO comp_tab.
    struct_type = cl_abap_structdescr=>create( comp_tab ).
    itab_type   = cl_abap_tabledescr=>create( struct_type ).
    l_wa_name = 'l_WA'.
    CREATE DATA dref TYPE HANDLE itab_type.
    ASSIGN dref->* TO <lt_outtab>.
    *CREATE DATA dref TYPE HANDLE struct_type.
    *ASSIGN dref->* TO <ls_outtab>.
    * Creation of the selection fields
    APPEND p_selfl1 TO lt_sel_list.
    APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
    ** Creation of the "where" clause
    *CONCATENATE p_selfl1 '= '' p_value ''.'
    *            INTO ls_where
    *            SEPARATED BY space.
    *APPEND ls_where TO lt_where.
    * Creation of the "where" clause
    APPEND p_where1 TO lt_where.
    * Creation of the "having" clause
    l_having = 'count(*) >= 1'.
    * THE dynamic select
    SELECT          (lt_sel_list)
           FROM     (p_tabnam)
           INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
    *       WHERE    (lt_where).

    Hi Sanket,
    The above given logic of mine works for you, put the code in the If condition and try-
    just like below:
    IF NOT P_EBELN IS INITIAL.
    lt_where = '& = ''&'' '.
    REPLACE '&' WITH p_ebeln INTO lt_where.
    REPLACE '&' WITH field_value INTO lt_where.
    SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
    FROM (p_tabnam)
    WHERE (lt_where).
    ENDIF.
    thanks\
    Mahesh

  • Absolute dynamic select query with dynamic join and where

    Has anyone ever tried creating an absolutely dynamic SELECT query with dynamic Join and Where conditions.
    I have a requirement of creating such a query in an Utility Class, and i have written the code. But its throwing my sysntax errors.
    Please let me know where am I going wrong OR is it really possible to create such a dynamic Query??
        SELECT (FIELDS) INTO TABLE IT_TABLES
          FROM ( (ME->TABLE1)  inner join ( me->table2 )
          on ( on_condition ) )
          WHERE (me->where_fields).
    Ags.

    It worked for me in a following way:
    select * into corresponding fields of table <result_table>
            from (join_string)
            where (l_where).
    Where the contents of join_string were dynamically build using concatenation. So it will be something like
    concatenate ME->TABLE1 'as a INNER JOIN' me->table2 'as b ON (' into join_string separated by space.
    <...>
    add here matching/reference colums, something like
    concatenate 'a~' me->TABLE1_JOIN_COL into temp1.
    concatenate 'b~' me->TABLE2_JOIN_COL into temp2.
    concatenate join_string temp1 '=' temp2 into join_string separated by space.
    <...>
    concatenate join_string ')' into join_string separated by space.
    And then use similar approach for l_where variable.

  • Running a SQL Stored Procedure from Power Query with Dynamic Parameters

    Hi,
    I want to execute a stored procedure from Power Query with dynamic parameters.
    In normal process, query will look like below in Power Query. Here the value 'Dileep' is passed as a parameter value to SP.
        Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData 'Dileep'"]
    Now I want to pass the value dynamically taking from excel sheet. I can get the required excel cell value in a variable but unable to pass it to query.
        Name_Parameter = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
        Name_Value = Name_Parameter{0}[Value],
    I have tried like below but it is not working.
    Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData Name_Value"]
    Can anyone please help me with this issue.
    Thanks
    Dileep

    Hi,
    I got it. Below is the correct syntax.
    Source = Sql.Database("ABC-PC", "SAMPLEDB", [Query="EXEC DBO.spGetData '" & Name_Value & "'"]
    Thanks
    Dileep

  • Creating Query with dynamic columns to show results

    Hi experts,
    I need to know how to create a query with dynamic columns. Meaning, I don't want to create a query with fixed columns representing the 12 periods of the fiscal year to show me actuals as the fiscal year proceeds.
    For example, if I am currently in the middle of period 3 (March) of a fiscal year, when I execute the query, I need it to automatically only show me the 'Actuals' for periods 1 and 2, without seeing the columns from periods 3 to 12 showing blank.
    Then when I am in the middle period 5 (May) the query should ONLY show me the columns for periods 1 to 4 'Actuals', no results should be shown for periods 5 to 12 yet, and I don't want to even see blank columns for period 6 to 12.
    How do I define my columns, to achieve this.
    Maximum points will be awarded.
    Thanks Everyone.

    Hi Josh,
    I'm having a little difficuluty understanding what should be included in my restricted key figures.
    The time characteristics that I have available to use are:
    0FISCPER3 (posting period)
    0FISCYEAR (fiscal year), currently using SAP EXIT to default current fiscal year.
    0FISCVARNT (fiscal year variant).
    In addition, I have the following characteristics available to be used in the columns:
    Value type (10)
    version (currently I'm using variable for it)
    Currency type (020)
    Currency (USD).
    Can you explain what my restricted key figure should be based on and how it should look.
    I tried to create a restircted key figure using 0AMOUNT, and 0FISCPER3. For 0FISCPER3  I created a range from 1 to previous period (using SAP EXIT that supplied previous period).I also had value type, version, currency type, and currency included in that restricted key figure.Then when I tried to drag 0FISCPER3 under the restricted key figure once again, it wouldn't let me, probably because I've already used 0FISCPER3 in the restricted key figure.
    Please let me know if my explanation is not clear.
    Your step by step help would be great.
    Thanks
    Edited by: Ehab Mansour on Sep 23, 2008 2:40 PM

  • Global query block is causing a DNS server to fail a query with error code Name Error exists in the DNS database for WPAD

    Global query block is causing a DNS server to fail a query with error code Name Error exists in the DNS database for WPAD on a Windows 2008 server.

    The global query block list is a feature that prevents attacks on your network by blocking DNS queries for specific host names.  This feature has caused the DNS server to fail a query with error code NAME ERROR for wpad.contoso.com. even though data
    for this DNS name exisits in the DNS database.  Other queries in all locally authoritative zones for other names that begin with labels in the block list will also fail, but no event will be logged when further queries are blocked until the DNS server
    service on this computer is restarted.

  • String Param tag replace with Br tag

    original text:
    <P ALIGN="LEFT">sample text1</P><P ALIGN="LEFT">sample text2</P><P ALIGN="LEFT">sample text3</P>
    I need to: <br/>sample text1<br2>sample text2<br2>sample text3
    can help me

    var reg:RegExp = /\<\/?P.*?\/?\>/igm;
      var _m=messageField.htmlText//<P ALIGN="LEFT">sample text1</P><P ALIGN="LEFT">sample text2</P><P ALIGN="LEFT">sample text3</P>
      _m=_m.replace(reg, '<br/>');
    trace(_m) //  "<br/>sampletext1<br/><br/>sampletext2<br/><br/>sampletext3<br/>"
    Iam getting double breaks i need only one break.
    Re: String Param tag replace with Br tag 

  • Tag Query with Special Characters in Tag Name not working

    Hello-
    We are on SAP xMII 12.0 sp8.6, connecting to Honeywell's PHD. We are doing Tag Queries, and all is working well, except when there are special characters in the Tag Name (+, /, \) We have attempted to do the Encoding of the tag name, such as as is returned from the function xmlencodename and also tried URL Encoding.
    Here is our tag which returns nothing.
    82TK1INV.OCTANE_R+M/2
    We have also tried these encoded versions, still to no avail:
    82TK1INV.OCTANE_R%2BM%2F2
    82TK1INV.OCTANER_M_2
    Any help on how to return the values with special characters in the tag name would be very helpful!
    thanks,
    Paul Mazeika

    To Chianti's question of why can't/shouldn't MII work with those bizarre tag names...
    Actually, there are a number of reasons:
    1) It's a poor design practice to use characters like that in tag names, regardless of the underlying system.  That type of information is best assigned to the tag description, not the tag name.  I've even seen idiots put leading spaces on tag names...figure that one out!
    2) MII uses XML extensively, and XML's syntax rules dictate what is and is not acceptable for XML element and attribute names, and many of these special characters are not permitted.
    3) Usage of characters in tags that also represent mathematical operators greatly complicate the parsing and processing of expressions that involve tag names
    In general, it reminds of the story of the guy who walks into the doctor, bangs his fist against a specific spot on his head, and says "Doc, it hurts when I do this", to which the doctor responds, "so don't do that". 
    So, Don't Do That.

  • Query with Dynamic SQL

    Hello,
    I would like to create a Dynamic SQL in which change is the name of the table according to the outcome of the first SQL. This is possible?
    'WITH TABLE_X AS(SELECT LEVEL LVL FROM DUAL CONNECT BY LEVEL <= 12)' ||
    'SELECT A.COL1, A.COL2, B.COL1, B.COL7'                              ||
    '  FROM TABLE_A' || TABLE_X.LVL || ' A'                              ||
    '     , TABLE_B' || TABLE_X.LVL || ' B'                              ||
    ' WHERE A.COL1 = B.COL1 AND ...    'tables in database
    TABLE_A1
    TABLE_A2
    TABLE_A12
    TABLE_B1
    TABLE_B2
    TABLE_B12let me know how I can do this
    Regards

    Hi,
    Sorry, I don't see what you're trying to do.
    "Dynamic SQL" is really a mis-nomer. The number of tables and columns in a query, and their names, must be spelled out when the statement is compiled. There is nothing dynamic about it.
    In dynamic SQL, a PL/SQL procedure or another query writes all or part of query just milliseconds before it is compiled, typically using data taken from tables or supplied by a user right then.
    For example, consider this static query:
    SELECT     a.col1, a.col2, b.col1, b.col7
    FROM     table_1     a
    ,     table_2 b
    WHERE     a.col1 = b.col1;Now, say the 1 in "table_1" and the 2 in "table_2" are variables, x and y, that you will want to look up from another table every time you run this query. You can make it dynamic like this:
    sql_txt := 'SELECT  a.col1, a.col2, b.col1, b.col7 '
         || 'FROM    table_' || TO_CHAR (x) || ' a '
         || ',       table_' || TO_CHAR (y) || ' b '
         || 'WHERE   a.col_1 = b.col1';Now let's make it really interesting. Say that instead of 2 tables, and 1 join condition, you''ll have n tables and n-1 join conditions, where n has to be computed at (actually a split second before) run-time. That is, if n=4, you might need to construct a static query with 4 tables and 3 join conditions, like this:
    SELECT     a.col1, a.col2, b.col1, b.col7
    FROM     table_1     a
    ,     table_2 b
    ,     table_12 c
    ,     table_2 d
    WHERE     a.col1 = b.col1
    AND     a.col1 = c.col1
    AND     a.col1 = d.col1;You can do that using dynamic SQL, too.
    Post an example of the static query you need to build, and describe what parts of it are dynamic, and how you get the values for those parts, and someone will help you write the dynamic SQL.

  • Sql query with dynamic fiscal year

    Hi,
    I wrote this query with static fiscal year and fiscal period, I need info on making the variables dynamic
    Fiscal year : starts from July1st. So this year until June'30 it is '2011' and from July'1st its '2012'
    Fiscal period: July1st its '1' and June'1st its '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
                             from org_account o
                                  left outer join 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
    thanks,
    Mano
    Edited by: user9332645 on Jun 2, 2011 6:55 PM

    Hi, Mano,
    Welcome to the forum!
    Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements), and the results you want from that data.
    Always say which version of Oracle you're using.
    Since this is your first thread, I'll post some sample 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');Is this the output you would want from that 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            01If so, here's one 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 fiscal year starts 6 months before the calendar year, you need to add 6 months to the actual date to get the fiscal year and month.
    The query above produces strings for fiscal_year and fiscal_period. If you'd rather have 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 higher).
    I'm not sure when EXTRACT was introduced. It definitely works in Oracle 10, and may be available in earlier versions, too.

  • Input query with dynamic actual & forecast values by month per year

    Hello,
    I am working on a Input ready query for a forecasting application which shows both actuals and forecast numbers and the user will revise the forecast numbers by month
    Requirement: I want to build a Input query for monthly forecasting for the current year. It will be dynamic rolling of months with actuals & forecast data.
    E.g. My report has 12 months for the current year
    and if run the report in May, the months before May has to show the actuals and the months after May has to show the old forecast data so that the user will revise the numbers again in each month and save the data to the real time cube.
    Jan.Feb.Mar.Apr.May.Jun.Jul.Aug.Sept.Nov.Dec
    Act Act  Act Act Act  Old frcst for the remaining months
      user will revise forecast for these months
    So, i am able to create Input query with all restricted key figures( plan kf has change mode set to change, actual kf are not set change) and calculate key figures and all the logic is done on dynamically moving/rolling the data based on the input month of the year.
    But the problem is that i am using cal kf to dynamically roll months, i was not able to set the change option for the cal kf.
    So, how can i make sure that the dynamically changed plan months will open for entering forecast and the actuals months not to change?
    Do you guys have any better solutions in implementing it?
    I really appreciate it your input....:)
    Thanks,
    Srini

    Hi,
    Please look at the following DOC which may be useful to you and if so please grant me point.
    Regards,
    SUbha'
    Input-Ready Query
    Use
    You use input-ready queries to create applications for manual planning. These can range from simple data entry scenarios to complex planning applications.
    Integration
    You define a query that you want to use for manual planning in the BEx Query Designer (see Defining New Queries).
    In the Web Application Designer or the BEx Analyzer, you can combine the input-ready queries with other queries and planning functions to create complex planning applications.
    Prerequisites
    You can define an input-ready query on any of the following InfoProviders:
    &#9679;     Aggregation levels (see Aggregation Levels)
    &#9679;     MultiProviders that include at least one simple aggregation level
    The aggregation levels are created in the planning modeler; MultiProviders are defined in the modeling functional area of the Data Warehousing Workbench.
    Features
    Definition of an Input-Ready Query
    Once you have defined a query on an InfoProvider, you see the Planning tab page under the Properties of structural components (for example, in key figures or restricted key figures). The options provided there allow you to determine which structural components of an input-ready query are to be input ready at runtime and which are not. With structural components that are not input ready, you can also determine whether these components are viewed as reference data or are just protected against manual entry.
    For the structural components, you also have the following options:
    Input readiness of structural components of a query
    Option
    Description
    Not input ready (reference data)
    If they are being used as reference data, the structural components are not protected by data locks to ensure exclusive access for one user because this data serves as a reference for many users.
    This is the default setting.
    Not input ready (no reference data)
    If you want to protect structural components against manual entries but allow changes by planning functions, you can use locks to protect this data for one particular user. In this way you can ensure that the planning function works with the displayed data only and not with data that has been changed by other users.
    Input ready
    You can also determine whether an input ready query is to be started in change mode or in display mode. You find this property in the Query Properties on the Planning tab page. If there is at least one input-ready query component, the query (as long as it has not been determined otherwise) is started in display mode.
    In BI applications that use input ready queries as data providers, you can enter data manually at runtime. For more information, see Performing Manual Planning and Creation of Planning Applications.
    Example
    You want to create an input-ready query for manual planning for a plan-actual comparison of revenues for a set of products. You want the plan data in a real-time-enabled InfoCube and the actual data in a standard InfoCube.
           1.      Create a MultiProvider that includes the InfoCubes for the plan and actual data.
           2.      Define an aggregation level on the MultiProvider which contains the characteristic Product and the key figure Revenue.
           3.      On the aggregation level, create two restricted key figures Plan Revenue and Actual Revenue. For restriction, choose the characteristic 0INFOPROV and restrict it to the plan or actual InfoCube.
           4.      Add the restricted key figures to the key figure structure. Insert Product into the rows. For Plan Revenue, choose Input Ready for the input-readiness option. For Actual Revenue, choose the option Not Input Ready (Reference Data).
           5.      In the query properties, set the indicator that determines whether the queries are started in display or change mode as required.
    Example of an input-ready query
    Product
    Plan Revenue
    Actual Revenue
    P01
    20
    P02
    30
    If you want to keep actual and plan data in a real-time enabled InfoCube, you do not require a MultiProvider for the task described above. Create an aggregation level on the InfoCube and define the input-ready query for the aggregation level. In the example above, a version characteristic acts as the InfoProvider. Create restricted key figures with the plan or actual version and proceed as in the previous example.

  • Query with dynamic variables and customised caption

    How to change the Field label when the query asking dynamic values during the execution?
    for example:  in where condition i want to give a country name during the query execution, but in the small window it will display as 'Name' which is a country name.  i want to display it as 'Country Name' which should be more readable for the end user. How can we achieve this?
    Thanks
    SV Reddy

    Hi,
    Unfortunately, it is not possible to change the system field description.
    Refer to this thread
    Re: Parameter Display Name Reg.
    Regards,
    Vijay Kumar
    SAP Business One Forums Team

  • Dynamic REF Cursor with Dynamic Fetch - Urgent

    i have a pl/sql package with generates dynamic SQL statments. my problem is i want to open this SQL statment dynamically and fetch data in dynamic variable.
    declare
    type type_temp is REF CURSOR;
    cur_temp type_temp;
    mv_sql varchar2(4000);
    begin
    -- this will be dunamically generated and
    -- hence could have any no. of columns.
    mv_sql := select f1, f2, f3, f4 from table_temp;
    open cur_temp for mv_sql;
    fetch cur_temp into c1, c2, c3, c4;
    close cur_temp;
    end;
    problem is my sql statment will have N no. of columns how can i fetch this N no. of columns.

    Very hard problem, because ref cursors do not (directly) support description!
    Se mine (non-ideal) solution (it may be doable, but it isn't very practical
    or easily maintainable):
    1. "Generic" package
    CREATE OR REPLACE PACKAGE dyn_fetch IS
    TYPE ref_cur_t IS REF CURSOR;
    g_query VARCHAR2 (32000);
    g_count NUMBER;
    g_desc_tab DBMS_SQL.DESC_TAB;
    varchar2_type CONSTANT PLS_INTEGER := 1;
    number_type CONSTANT PLS_INTEGER := 2;
    date_type CONSTANT PLS_INTEGER := 12;
    rowid_type CONSTANT PLS_INTEGER := 11;
    char_type CONSTANT PLS_INTEGER := 96;
    long_type CONSTANT PLS_INTEGER := 8;
    raw_type CONSTANT PLS_INTEGER := 23;
    mlslabel_type CONSTANT PLS_INTEGER := 106;
    clob_type CONSTANT PLS_INTEGER := 112;
    blob_type CONSTANT PLS_INTEGER := 113;
    bfile_type CONSTANT PLS_INTEGER := 114;
    PROCEDURE describe_columns;
    FUNCTION record_def RETURN VARCHAR2;
    END;
    CREATE OR REPLACE PACKAGE BODY dyn_fetch IS
    PROCEDURE describe_columns IS
    l_cur INTEGER;
    BEGIN
    l_cur := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE (l_cur, g_query, DBMS_SQL.NATIVE);
    DBMS_SQL.DESCRIBE_COLUMNS (l_cur, g_count, g_desc_tab);
    DBMS_SQL.CLOSE_CURSOR (l_cur);
    EXCEPTION
    WHEN OTHERS THEN
    IF DBMS_SQL.IS_OPEN (l_cur) THEN
    DBMS_SQL.CLOSE_CURSOR (l_cur);
    END IF;
    RAISE;
    END;
    FUNCTION record_def RETURN VARCHAR2 IS
    l_record_def VARCHAR2 (32000);
    l_type VARCHAR2 (100);
    l_col_type PLS_INTEGER;
    l_col_max_len PLS_INTEGER;
    l_col_precision PLS_INTEGER;
    l_col_scale PLS_INTEGER;
    BEGIN
    FOR i IN 1..g_count LOOP
    l_col_type := g_desc_tab(i).col_type;
    l_col_max_len := g_desc_tab(i).col_max_len;
    l_col_precision := g_desc_tab(i).col_precision;
    l_col_scale := g_desc_tab(i).col_scale;
    IF l_col_type = varchar2_type THEN
    l_type := 'VARCHAR2(' || l_col_max_len || ')';
    ELSIF l_col_type = number_type THEN
    l_type := 'NUMBER(' || l_col_precision || ',' || l_col_scale || ')';
    ELSIF l_col_type = date_type THEN
    l_type := 'DATE';
    ELSIF l_col_type = rowid_type THEN
    l_type := 'ROWID';
    ELSIF l_col_type = char_type THEN
    l_type := 'CHAR(' || l_col_max_len || ')';
    -- ELSIF l_col_type = ...
    -- long_type, raw_type ...
    END IF;
    l_record_def := l_record_def || ' col_' || i || ' ' || l_type || ',';
    END LOOP;
    l_record_def := RTRIM (l_record_def, ',');
    RETURN l_record_def;
    END;
    END;
    Note that procedure "record_def" creates columns names as col_1 (col_2 ...)
    because SELECT clause in your query can be without aliases, for example
    "SELECT deptno || dname FROM dept".
    2. Your package which returns query nad ref cursor
    CREATE OR REPLACE PACKAGE test IS
    PROCEDURE set_query (p_query VARCHAR2 := NULL);
    FUNCTION ref_cur RETURN dyn_fetch.ref_cur_t;
    END;
    CREATE OR REPLACE PACKAGE BODY test IS
    PROCEDURE set_query (p_query VARCHAR2 := NULL) IS
    l_query VARCHAR2 (32000) :=
    ' SELECT e.empno, e.ename,' ||
    ' e.deptno, d.dname' ||
    ' FROM emp e,' ||
    ' dept d' ||
    ' WHERE e.deptno = d.deptno';
    BEGIN
    IF p_query IS NULL THEN
    dyn_fetch.g_query := l_query;
    ELSE
    dyn_fetch.g_query := p_query;
    END IF;
    END;
    FUNCTION ref_cur RETURN dyn_fetch.ref_cur_t IS
    l_ref_cur dyn_fetch.ref_cur_t;
    BEGIN
    OPEN l_ref_cur FOR dyn_fetch.g_query;
    RETURN l_ref_cur;
    END;
    END;
    Why we need two separate procedures (functions) in your package ?
    a) Receiving program must use dynamic SQL, but in dynamic block we can access
    only PL/SQL code elements that have global scope (standalone functions and procedures,
    and elements defined in the specification of a package).
    Unfortunately, cursor variables cannot be defined in the specification of a package
    (cannot be global variables).
    b) Receiving program must get the column list before ref cursor.
    So, we have two options: call (in receiving program) the same function two times
    (once to get the column list and once to return a ref cursor)
    or use one procedure (or function) for returning query (to get the column list)
    and second function for returning a ref cursor.
    3. Your receiving program
    CREATE OR REPLACE PROCEDURE test_fetch_ref_cur (p_query VARCHAR2 := NULL) IS
    l_statement VARCHAR2 (32000);
    FUNCTION process_def RETURN VARCHAR2 IS
    l_process_def VARCHAR2 (32000);
    BEGIN
    l_process_def := 'DBMS_OUTPUT.PUT_LINE (';
    FOR i IN 1 .. dyn_fetch.g_count LOOP
    l_process_def := l_process_def || ' l_record.col_' || i || ' || ''>>'' || ';
    END LOOP;
    l_process_def := RTRIM (l_process_def, ' || ''>>'' || ') || ');';
    RETURN l_process_def;
    END;
    BEGIN
    test.set_query (p_query);
    dyn_fetch.describe_columns;
    l_statement :=
    ' DECLARE' ||
    ' TYPE record_t IS RECORD (' ||
    dyn_fetch.record_def || ');' ||
    ' l_record record_t;' ||
    ' l_ref_cur dyn_fetch.ref_cur_t;' ||
    ' BEGIN' ||
    ' l_ref_cur := test.ref_cur;' ||
    ' LOOP' ||
    ' FETCH l_ref_cur INTO l_record;' ||
    ' EXIT WHEN l_ref_cur%NOTFOUND;' ||
    process_def ||
    ' END LOOP;' ||
    ' CLOSE l_ref_cur;' ||
    ' END;';
    EXECUTE IMMEDIATE l_statement;
    END;
    You can test this with:
    SET SERVEROUTPUT ON;
    EXECUTE test_fetch_ref_cur;
    Note that we can try to use more generic solution:
    CREATE OR REPLACE PACKAGE dyn_fetch IS
    -- SAME AS BEFORE, PLUS:
    PROCEDURE fetch_ref_cur (
    p_function_ref_cur VARCHAR2,
    p_process_def VARCHAR2);
    END;
    CREATE OR REPLACE PACKAGE BODY dyn_fetch IS
    -- SAME AS BEFORE, PLUS:
    PROCEDURE fetch_ref_cur (
    p_function_ref_cur VARCHAR2,
    p_process_def VARCHAR2)
    IS
    l_statement VARCHAR2 (32000);
    BEGIN
    l_statement :=
    ' DECLARE' ||
    ' TYPE record_t IS RECORD (' ||
    record_def || ');' ||
    ' l_record record_t;' ||
    ' l_ref_cur dyn_fetch.ref_cur_t;' ||
    ' BEGIN' ||
    ' l_ref_cur := ' ||
    p_function_ref_cur || ';' ||
    ' LOOP' ||
    ' FETCH l_ref_cur INTO l_record;' ||
    ' EXIT WHEN l_ref_cur%NOTFOUND;' ||
    p_process_def ||
    ' END LOOP;' ||
    ' CLOSE l_ref_cur;' ||
    ' END;';
    EXECUTE IMMEDIATE l_statement;
    END;
    END;
    CREATE OR REPLACE PROCEDURE test_fetch_ref_cur (p_query VARCHAR2 := NULL) IS
    FUNCTION process_def RETURN VARCHAR2 IS
    -- SAME AS BEFORE
    END;
    BEGIN
    test.set_query (p_query);
    dyn_fetch.describe_columns;
    dyn_fetch.fetch_ref_cur (
    p_function_ref_cur => 'test.ref_cur',
    p_process_def => process_def);
    END;
    Regards,
    Zlatko Sirotic

  • How to create a dynamic table region with dynamic VO

    Hi All,
    I have a requirement to create a dynamic table region with a dynamic VO.
    I need this because at runtime only the user will select the table name. So based on that table name, i have to create a table region to display the records.
    I already created a dynamic VO. Could anyone share the code for dynamic table region creation.
    Thanks in Advance.
    Thanks and Regards,
    Myvizhi

    Hi All,
    I have a requirement to create a dynamic table region with a dynamic VO.
    I need this because at runtime only the user will select the table name. So based on that table name, i have to create a table region to display the records.
    I already created a dynamic VO. Could anyone share the code for dynamic table region creation.
    Thanks in Advance.
    Thanks and Regards,
    Myvizhi

  • How to create a dynamic table region with dynamic VO in processFormRequest

    Hi All,
    I have a requirement to create a dynamic table region with a dynamic VO.
    I need this because at runtime only the user will select the table name. So based on that table name, i have to create a table region to display the records.
    I already created a dynamic VO. Could anyone share the code for dynamic table region creation.
    Thanks in Advance.
    Thanks and Regards,
    Myvizhi
    Edited by: Myvizhi Selvi on May 20, 2013 6:21 PM

    Hi,
    You can use following sample code to create advance table columns dynamically with colum groups as well.
    It assumes that you have already created advance table with ID EmpTblRN.
    Below code returns column heading dynamically and if you keep your VO column names and attributes
    same in all the cases (COL1, COL2.....) then you can easily use a loop to create advance table columns.
    It is attaching VO attributes to OAMessageStyledText bean in the last.
    Hope it helps.
    OAAdvancedTableBean advTable = (OAAdvancedTableBean)webBean.findChildRecursive("EmpTblRN");
    Serializable [] param = {currentWindowSeq.toString()};
    Datum[] colHeadingArray = (Datum[])am.invokeMethod("getColumnHeading", param);
    String oldGrpName = null;
    String newGrpName = null;
    OAColumnGroupBean columnGroup = null;
    DictionaryData columnFormat = new DictionaryData();
    columnFormat.put(WIDTH_KEY, "4%");
    for (int i = 0; i < colHeadingArray.length; i++)
    try
    oracle.sql.STRUCT os = (oracle.sql.STRUCT)colHeadingArray;
    Object[] colHeadAttr = os.getAttributes();
    newGrpName = (String)colHeadAttr[0];
    if(newGrpName!=null)
    if(!newGrpName.equals(oldGrpName))
    // Create a column group, create the set the column header,
    // and add the column group under the advanced table
    columnGroup = (OAColumnGroupBean)createWebBean(pageContext, COLUMN_GROUP_BEAN, null, "ColGroup"+i);
    OASortableHeaderBean columnGroupHeader = (OASortableHeaderBean)createWebBean(pageContext, SORTABLE_HEADER_BEAN, null, "ColGroupHeader"+i);
    columnGroupHeader.setText(newGrpName);
    // Retrieve from message dictionary
    columnGroup.setColumnHeader(columnGroupHeader);
    advTable.addIndexedChild(columnGroup);
    oldGrpName = newGrpName;
    // Create a column, create the set the column header, and add the column
    // under the column group
    OAColumnBean column1 = (OAColumnBean)createWebBean(pageContext, COLUMN_BEAN, null, "Column"+i);
    OASortableHeaderBean column1Header = (OASortableHeaderBean)createWebBean(pageContext, SORTABLE_HEADER_BEAN, null, "Column1Header"+i);
    column1Header.setText(colHeadAttr[1].toString());
    column1.setColumnHeader(column1Header);
    column1.setColumnFormat(columnFormat);
    columnGroup.addIndexedChild(column1);
    // Create the actual leaf item under the first column
    OAMessageStyledTextBean leaf1 = (OAMessageStyledTextBean)createWebBean(pageContext, MESSAGE_STYLED_TEXT_BEAN, null, "Leaf"+i);
    //OARawTextBean leaf1 = (OARawTextBean)createWebBean(pageContext, RAW_TEXT_BEAN, null, "Leaf"+i);
    leaf1.setViewAttributeName("Week"+(i+1));
    String destination = "OA.jsp?page=/xxqc/oracle/apps/per/leaveadvance/webui/EmployeeLeaveDetailPG&personId={@PersonId}";
    destination = destination + "&startDate="+colHeadAttr[1].toString()+"-"+(String)colHeadAttr[0];
    destination = destination + "&addBreadCrumb=Y&retainAM=Y";
    leaf1.setDestination(destination);
    OADataBoundValueViewObject cssjob = new OADataBoundValueViewObject(leaf1,"Color"+(i+1));
    //leaf1.setAttributeValue(oracle.cabo.ui.UIConstants.STYLE_CLASS_ATTR, cssjob);
    leaf1.setAttributeValue(UIConstants.RENDERED_ATTR, cssjob);
    column1.addIndexedChild(leaf1);
    catch(Exception e)
    System.out.println("e"+e);

Maybe you are looking for

  • How can I change my iCloud account on my ipad

    How do I change my iCloud account

  • Adobe DPS with mac os-x 10.6.8

    Hi I'm currently running mac OS X 10.6.8,  and i am looking at using the Adobe Digital publishing (from indesign cs6) suite to create an app. The problem is the only version of Xcode i can find available for my system is 3.2. i was just wondering if

  • My itunes wont connect to the itunes store please help

    My itunes isnt connecting to my itunes store. i have internet but its just my itunes store not working.

  • [JS] CS3 file.openDialog ()

    What folder does file.openDialog default to? I can't seem to find any consistency in this. And is there any way to control it?

  • XI condition for Mail triggering

    Hi All, Is that possible to give condition like mail should trigger after sales order has been created. For EX: the flat file send from XI to R3. In R3 side sales order will create using the BAPI Function module. Here, the mail has triggered even the