Function body of pl/sql returning the SQL query

< code >
v_code: = "Code:";
V_calls: = ' calls:';
V_region: =' region:';

v_sql: = ' SELECT "' | v_code | " ' || CODES.NAME | " ' || v_calls | " ' || (select count (t.code) in case where t.code = cases.code group by code) as Total_Calls, "' | V_region | " ' || CASE. Region,

(select count (tt.region) in case t where t.region = cases.region and t.casecode = cases.casecode group by region) as calls

CODES, CASES
where the BUSINESS. CASE CODE = CODES. BRIEFCODE ';

< code >
I have to do a separate on the selection above and I get error when I put as follows.

< code >

v_sql: = ' SELECT distinct "' | v_code | " ' || CODES.NAME | " ' || v_calls | " ' || (select count (t.code) in case where t.code = cases.code group by code) as Total_Calls, "' | V_region | " ' || CASE. Region,

(select count (tt.region) in case t where t.region = cases.region and t.casecode = cases.casecode group by region) as calls

CODES, CASES
where the BUSINESS. CASE CODE = CODES. BRIEFCODE ';

< code >

Hello

Try

v_code := 'Code :';
V_calls := 'Calls :';
v_region:='Region:';

v_sql := 'SELECT '''||v_code||'''||CODES.NAME ||'''||v_calls||'''|| (select count(t.code) from cases t where t.code = cases.code group by code ) as Total_Calls, '''||v_region||'''||CASES.REGION Region,

(select count(tt.region) from cases t where t.region = cases.region and t.casecode = cases.casecode group by region) as Calls

from CODES,CASES
where CASES.CASECODE = CODES.BRIEFCODE ';

v_sql := 'SELECT DISTINCT * FROM ( ' || v_sql || ')';

Kind regards
Jari

Tags: Database

Similar Questions

  • Any difference between the separate function and aggregation in sql query cost?

    Hello
    I've run many models sql stmts - such as:
    one) using a single table
    (b) using the two tables, using simple joins or outer joins

    but I didn't notice a difference in sql stmts in cost and implementation plan...
    In any case, my colleague insists on only using the aggregate function is less expensive compared to
    separate... (something I've not confirmed, that is why I believe that they are exactly the same...)

    For the situation described above under 1 sql... We could for example use
    select distinct deptno
    from emp
    select count(*), deptno
    from emp
    group by deptno
    select distinct owner, object_type from all_objects
    select count(*), owner, object_type from all_objects
    group by owner, object_type
    Have you ever found no difference between the two...?

    Note: I use Ora DB 10g v2.

    Thank you
    SIM

    Alexandre Gelin says:
    function separate and aggregation are for different uses and can give the same result, but if you use the aggregate function to get the separate records, it will be expensive...

    really? I find them almost identical to 11g. Actually GROUP BY is almost always more fast for me in the old days.

    article about this askTom Re: any difference between the separate function and aggregation in sql query cost?
    This applies mainly to the older oracle versions http://www.oracle.com/technology/products/rdb/pdf/distinct_derivedtables_groupby_sort_tech_article.pdf

  • JavaScript Command Window.getComputedStyle (document.body, ': after') .getPropertyValue ('content') returns the content with quotes

    When I use in my css:
    body: after {}
    content: "mobile";
    display: none;
    }
    And by controlling javascript with the command:
    size var = window.getComputedStyle (document.body, ': after') .getPropertyValue ('content');

    I get in firefox (mac v 23.0.1) returns the '' mobile' ' string with double quotes as return and, therefore, checking if size == 'mobile' returns false. In safari, the value returned 'mobile' without the quotes. How is it?

    What you get is a string that represents what you specified in the content.

    A content specification can include other things like a counter: body: after {content: "subjects []" counter (topics) "]" ;}}

    size = window.getComputedStyle(document.body,_':after').content would give: 'subjects []' counter (topics) "].

    If you need test the exact text of the contents: size == ' 'mobile "";

  • How to run the function body that is stored in the variable string?

    Hello!

    Let's say we have a function body stored in the string variable, like this:

    ......

    ......

    var body: String = "public function display_message(kom:String):void {mx.controls.Alert.show (kom) ;};

    .....

    Here, I would like to do something with variable 'body' to run the code in this variable, is - it possible?

    ......

    ......

    With regard to the bars.

    d.Eval can do what you want. check it out at http://www.riaone.com/products/deval/index.html

  • [need help] Function body of PL/SQL returning the SQL with BI publisher

    Hello

    I'm new to BI publisher, back then I used ocj4 for pdf printing, but then we got BI publisher. We want to have a better relationship, since we always used the standard one.

    My pl/sql like this look
    DECLARE
      q varchar2(4000);
      list_betreuer htmldb_application_global.vc_arr2;
      list_semester htmldb_application_global.vc_arr2;
      list_status htmldb_application_global.vc_arr2;
    
    BEGIN
    
     -- variable to store the list
     list_betreuer := HTMLDB_UTIL.STRING_TO_TABLE(:P61_BETREUER);
     list_semester := HTMLDB_UTIL.STRING_TO_TABLE(:P61_SEMESTER);
     list_status := HTMLDB_UTIL.STRING_TO_TABLE(:P61_STATUS);
    
     -- Query begins
     q:= 'select p1.name, p1.vorname , a1.tel, a2.tel, '; 
     q:= q||'ab.thema, ab.status, ab.typ, s.bezeichnung, p2.name ';
     
     q:= q||'from person p1, person p2, adresse a1, adresse a2, ';
     q:= q||'zuordnungp_a zpa1,zuordnungp_a zpa2, ';
     q:= q||'abschlussarbeit ab, semester s ';
    
     q:= q||'WHERE ab.SEMESTER = s.OBJECTID (+) ';
     q:= q||'AND ab.STUDENT = p1.OBJECTID (+) ';
     q:= q||'AND ab.BETREUER = p2.OBJECTID (+) ';
    
     q:= q||'and p1.objectid = zpa1.person (+) ';
     q:= q||'and zpa1.adresse  = a1.objectid (+) ';
     q:= q||'and zpa1.art (+)= ''Privat'' ';
    
     q:= q||'and p1.objectid = zpa2.person (+) ';
     q:= q||'and zpa2.adresse  = a2.objectid (+) ';
     q:= q||'and zpa2.art (+)= ''Geschäft'' ';
    
    
     -- Loop for betreuer list
     FOR i in 1..list_betreuer.count
     LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.betreuer = '||list_betreuer(i);
        ELSE
        q:= q||' OR ab.betreuer  = '||list_betreuer(i);
        END IF;
     END LOOP; if (list_betreuer.count>0)THEN q:= q||')'; END IF;
    
      -- Loop for semester list
     FOR i in 1..list_semester.count
     LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.semester = '||list_semester(i);
        ELSE
        q:= q||'OR ab.semester = '||list_semester(i);
        END IF;
     END LOOP; if (list_semester.count>0)THEN q:= q||')'; END IF;
     
     -- Loop for status list
     FOR i in 1..list_status.count
     LOOP
        IF i = 1 THEN
        q:= q||'AND (ab.status = '''||list_status(i)||'''';
        ELSE
        q:= q||'OR ab.status = '''||list_status(i)||'''';
        END IF;
     END LOOP; if (list_status.count>0)THEN q:= q||')'; END IF;
     
     -- htp.p(q);
     return q;
     
    END;
    the question is how can I generate a pdf with this query using BI publisher report, what should I do?



    Thanks in advance


    Danny

    Check this out to see if this helps you. This article talks about passing parameters to the BI publisher of Apex report.

    http://tylermuth.WordPress.com/2008/03/31/call-bi-Publisher-Web-services-from-apex/

    Thank you!

  • function in pipeline does not return the first values of immediately?

    I'm new to features in the pipeline. I want to get the first results of this function in the pipeline as soon as possible. But in my test case, I get all the lines at the end, when the function ends.

    create or replace
    dummy function
    return DBMS_DEBUG_VC2COLL
    PIPELINED - NOTE the keyword in pipeline
    is
    Start
    line of conduct (to_char (sysdate, ' DD-MON-YYYY HH24:MI:SS'));))
    DBMS_LOCK. Sleep (90);
    line of conduct (to_char (sysdate, ' DD-MON-YYYY HH24:MI:SS'));))
    return;
    end;
    +/+

    I expect
    + January 20, 2009 08:32:51 + immediately
    a 90-second delay
    + 08:34:21 + 20 January 2009 thereafter.

    But I have two lines after 90 sec.

    Can I change the behavior of this function somehow, or is this the only default behavior and I have to find other solutions?

    Thanks in advance
    Martin

    A parameter in your SQL * Plus has an influence on behavior, specifically the ArraySize.

    by your function (pipe_nums), run this:

    select * from table(pipe_nums);
    
    set arrays 5
    
    select * from table(pipe_nums);
    

    and notice the difference

  • Clear the cache or return the Web query

    I have a situation where the user selects a combobox control, based on what they choose, it sends and receives data through a web service and fills another drop-down list box.  There is also a clear button that clears all selections of previous drop-down list, the list box washing box drop-down fist with the original list of choices.  If the user will choose the same selection on the first drop-down list box, as above, it does not send it through the service web like system (flex) already think he did.  Is there a way to clear the cache or force the web service to return?

    These links may help:

    http://blog.atrexis.com/index.cfm/2008/9/30/browser-cache-when-Flex-working-with-PHP

    http://StackOverflow.com/questions/300757/preventing-Flex-application-caching-in-browser-m ultiple-modules

  • SQL query + html

    Hello

    I have a test_table (col1, col2, col3) on apex.oracle.com.

    First of all:

    I would like to create report as the type of SQL query:

    Select col1, col2, col3 from test_table;

    I want to change the properties of the col2 for example the font or color during the generation.

    I have to write in the report source code (this is only an example?):

    Select col1,

    "< span style =" ' make-weight: bold; ' > ' col2 "</span >", "

    COL3

    from test_table;

    I think it's wrong, but I would like to know what are the first principles of the connection between sql and html.

    Second:

    I create the report in the body of type SQL query return PLSQL function:

    Start

    return "select col1.

    || "< span style =" ' make-weight: bold; ">" | 'col2' | ' </span >', "

    ||' COL3

    from test_table;';

    end;

    What is the problem in the two examples? I can't find it in the documentation. Could you tell me something about the principles.

    Concerning

    Ziut

    Hello

    One way is to query as

    select col1,
    col2,
    col3,
    case when col1 = 'XXX' then
     'bold'
    else
     'normal'
    end as fontweight
    from test_table;
    

    Column of FONTWEIGHT set as hidden.

    Then place the COL2 HTML expression

    #COL2#
    

    Kind regards

    Jari

  • How to call a function whose name is stored in the table?

    Dear members,

    I have a function with return number and store its name in a table.

    now, I want to choose the name of this table function and run it and return the value of a variable in my form.

    Here is my code in when pressed to release button.
    DECLARE
         v_value number;
         V_FUNC VARCHAR2(100);
         V_PARAM VARCHAR2(100);
    begin
         select FUNCTION_NAME, PARAM 
         INTO V_FUNC, V_PARAM
         from function_table
         where id =1;
          
         message('V_FUNC='||V_FUNC); pause;
         v_value := v_func||';'; --run_tb_function;
         :text01 := v_value;
    end;
    This code gives the following error:

    ORA-06502


    with regard to:

    Published by: user2040934 on February 2, 2013 09:47

    You can use EXECUTE IMMEDIATE to call pl/sql dynamic. But you need to wrap it in a db procedure.

    BTW... What is the reason of this dynamic approach, as it is very unusual?

  • Get the dynamic query alias name

    Hi all

    I have a plsql function using a dynamic query.
    And the function takes an entire sql query as a parameter.

    The main problem is that the function must get what aliases or columns were interviewed.

    For example,.
    FUNCTION_GET_QUERY_ALIAS ('SELECT 1 AS col1, col2 FROM DUAL 2 AS')
    Inside the function, he must find the alias name COL1 and COL2.

    I would be grateful for any help.

    I modified print_table as fact and function to meet your needs.

    SQL> CREATE OR REPLACE TYPE my_column_object AS OBJECT(ruw_number integer, column_name VARCHAR2(1000), column_val VARCHAR2(1000))
      2  /
    
    Type created.
    
    SQL> CREATE OR REPLACE TYPE my_table_type AS TABLE OF my_column_object
      2  /
    
    Type created.
    
    SQL> CREATE OR REPLACE FUNCTION print_table( p_query in varchar2 ) RETURN my_table_type PIPELINED
      2  AS
      3      l_theCursor     INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
      4      l_columnValue   VARCHAR2(4000);
      5      l_status        INTEGER;
      6      l_descTbl       DBMS_SQL.DESC_TAB;
      7      l_colCnt        NUMBER;
      8      l_rcount           INTEGER := 0;
      9  BEGIN
     10      DBMS_SQL.PARSE(  l_theCursor,  p_query, dbms_sql.native );
     11
     12      DBMS_SQL.DESCRIBE_COLUMNS( l_theCursor, l_colCnt, l_descTbl );
     13
     14      FOR i IN 1 .. l_colCnt
     15      LOOP
     16          DBMS_SQL.DEFINE_COLUMN(l_theCursor, i, l_columnValue, 4000);
     17      end loop;
     18
     19      l_status := DBMS_SQL.EXECUTE(l_theCursor);
     20
     21      WHILE ( DBMS_SQL.FETCH_ROWS(l_theCursor) > 0 )
     22      LOOP
     23             l_rcount := l_rcount + 1;
     24          FOR i IN 1 .. l_colCnt
     25          LOOP
     26              DBMS_SQL.COLUMN_VALUE( l_theCursor, i, l_columnValue );
     27
     28              PIPE ROW(my_column_object(l_rcount,l_descTbl(i).col_name,l_columnValue));
     29          END LOOP;
     30      END LOOP;
     31
     32     RETURN;
     33  end;
     34  /
    
    Function created.
    
    SQL> select * from table(print_table('select * from emp'))
      2  /
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
             1 EMPNO                7369
             1 ENAME                SMITH
             1 JOB                  CLERK
             1 MGR                  7902
             1 HIREDATE             17-DEC-80
             1 SAL                  800
             1 COMM
             1 DEPTNO               20
             1 DIV                  10
             2 EMPNO                7499
             2 ENAME                ALLEN
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
             2 JOB                  SALESMAN
             2 MGR                  7698
             2 HIREDATE             20-FEB-81
             2 SAL                  1600
             2 COMM                 300
             2 DEPTNO               30
             2 DIV                  10
             3 EMPNO                7521
             3 ENAME                WARD
             3 JOB                  SALESMAN
             3 MGR                  7698
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
             3 HIREDATE             22-FEB-81
             3 SAL                  1250
             3 COMM                 500
             3 DEPTNO               30
             3 DIV                  10
             4 EMPNO                7566
             4 ENAME                JONES
             4 JOB                  MANAGER
             4 MGR                  7839
             4 HIREDATE             02-APR-81
             4 SAL                  2975
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
             4 COMM
             4 DEPTNO               20
             4 DIV                  10
             5 EMPNO                7654
             5 ENAME                MARTIN
             5 JOB                  SALESMAN
             5 MGR                  7698
             5 HIREDATE             28-SEP-81
             5 SAL                  1250
             5 COMM                 1400
             5 DEPTNO               30
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
             5 DIV                  10
             6 EMPNO                7698
             6 ENAME                BLAKE
             6 JOB                  MANAGER
             6 MGR                  7839
             6 HIREDATE             01-MAY-81
             6 SAL                  2850
             6 COMM
             6 DEPTNO               30
             6 DIV                  10
             7 EMPNO                7782
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
             7 ENAME                CLARK
             7 JOB                  MANAGER
             7 MGR                  7839
             7 HIREDATE             09-JUN-81
             7 SAL                  2450
             7 COMM
             7 DEPTNO               10
             7 DIV                  10
             8 EMPNO                7788
             8 ENAME                SCOTT
             8 JOB                  ANALYST
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
             8 MGR                  7566
             8 HIREDATE             19-APR-87
             8 SAL                  3000
             8 COMM
             8 DEPTNO               20
             8 DIV                  10
             9 EMPNO                7839
             9 ENAME                KING
             9 JOB                  PRESIDENT
             9 MGR
             9 HIREDATE             17-NOV-81
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
             9 SAL                  5000
             9 COMM
             9 DEPTNO               10
             9 DIV                  10
            10 EMPNO                7844
            10 ENAME                TURNER
            10 JOB                  SALESMAN
            10 MGR                  7698
            10 HIREDATE             08-SEP-81
            10 SAL                  1500
            10 COMM                 0
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
            10 DEPTNO               30
            10 DIV                  10
            11 EMPNO                7876
            11 ENAME                ADAMS
            11 JOB                  CLERK
            11 MGR                  7788
            11 HIREDATE             23-MAY-87
            11 SAL                  1100
            11 COMM
            11 DEPTNO               20
            11 DIV                  10
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
            12 EMPNO                7900
            12 ENAME                JAMES
            12 JOB                  CLERK
            12 MGR                  7698
            12 HIREDATE             03-DEC-81
            12 SAL                  950
            12 COMM
            12 DEPTNO               30
            12 DIV                  10
            13 EMPNO                7902
            13 ENAME                FORD
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
            13 JOB                  ANALYST
            13 MGR                  7566
            13 HIREDATE             03-DEC-81
            13 SAL                  3000
            13 COMM
            13 DEPTNO               20
            13 DIV                  10
            14 EMPNO                7934
            14 ENAME                MILLER
            14 JOB                  CLERK
            14 MGR                  7782
    
    RUW_NUMBER COLUMN_NAME          COLUMN_VAL
    ---------- -------------------- --------------------
            14 HIREDATE             23-JAN-82
            14 SAL                  1300
            14 COMM
            14 DEPTNO               10
            14 DIV                  10
    
    126 rows selected.
    
    SQL>
    

    Thank you
    Knani.

    Published by: Karthick_Arp on September 23, 2008 12:11 AM

  • Export as .xls. Classic report type: SQL (body of function from PL/SQL returning the SQL) query

    Hey guys,.

    I'm using version 4.2.6 apex. The theme is 26.

    IM also using Listener Oracle APEX.

    I can print my classic report in PDF or CSV format.

    But I need to export it as a .xls extension.

    Report type: SQL (body of function from PL/SQL returning the SQL) query

    I need is like this cause my 'where' clause type is dynamic.

    Look at using this method: Tom's Blog: a non-standard export excel 2010 (.xlsx)

    I do something similar for downloads to excel in my projects...

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • SQL (body of function from PL/SQL returning the SQL) query when you use to_char

    We are trying to build a page of Type SQL Query report (body of function from PL/SQL returning SQL query).
    our request is simple, to extract the month of the column recording_date.

    declare
    l_query varchar2 (1000);
    Start
    l_query: = 'select to_char (recording_date, 'MM') of re_productive;
    Return l_query;
    end;

    but we would like the following for this query problem

    Function returning SQL query: query cannot be parsed in the generator. If you believe that your query is syntactically correct, check the box of generic columns below the source of the region without analysis.
    (ORA-06550: line 4, column 42: PLS-00103: encountered the symbol "MY" what awaits one of the following values:.) (* @ % & = - +; <>/ at is mod remains not rem <>or! = or ~ = > = < = <>and or as between | multiset Member SUBMULTISET_ the symbol ".") was inserted before 'MY' to continue.)

    Notes:
    1 - the request is correct and it has been tested under sqlplus and toad.
    2. we tried option use generic name (analysis of query runtime only) column, but we get the same problem.


    any quick help please.

    Hello

    You have not escaped your quote in the string. Try this...

    DECLARE
    l_query VARCHAR2(32767);
    
    BEGIN
    
    l_query:= 'select to_char(recording_date,''MM'') from re_productive';
    
    RETURN l_query;
    
    END;
    

    See you soon

    Ben

  • Assigning a page element in the region of the "body of function return PLSQL SQL query.

    I've not been here in a long time. I like the new forum text editor!

    I have a search page in my application that contains a return region of query SQL PLSQL function body. I use PLSQL to build a query based on the user entries in various page numbers (search text, serial number, year, etc.). Using PLSQL is very useful to enforce the page quickly because there are 1/2 million lines with a lot of text fields some of which are CLOB.

    Users want to know how many rows were returned, but if I allow using a paging system that includes the total performance dies because ApEx has to sort through all the pages of output. Instead, I use ' line varies X to Y "without the part of" Z", and it's pretty fast. I can't use the #TOTAL_ROWS # because it does not work with this system of pagination.

    So, I built a code within the region of function body PLSQL to build a second query that counts only the lines based on the input parameters. I can do this query within the region using EXECUTE IMMEDIATE and the number to an output variable. The disconnect is that I can not then assign it to a page element. If I add a statement assigned to a page element, either by

    : P45_COUNT: = p_count;
    or
    APEX_UTIL. SET_SESSION_STATE ('P45_COUNT', p_count);

    then when I submit the changes I get

    ERR-1002 unable to find point item ID 'P45_COUNT' in the application '4000 '.

    as if the ApEx is not looking for the item in my application, but in the application development environment. I am able to write the results to a table and then recover data in the next region. That's how I got around the problem, but it seems too complicated and unnecessary.

    I wrote the following code just to illustrate the problem.

    Make sense? Any ideas?

    Thank you!

    Bill


    declare
    p_sql varchar2 (32767).
    p_sql_count varchar2 (32767).
    p_table_count number (2);
    p_count number (10);
    p_instr number (10);
    Start
    p_sql: = q'! Select g.id, g.widget, g.year_made, g.serial!';
    p_sql: = p_sql | q'! g table_g where g.status = 1!';

    If: P45_YEAR_MADE is not null then
    p_sql: = p_sql | q'! and $P45_YEAR_MADE = g.year_made!';
    end if;
    If: P45_SERIAL is not null then
    p_sql: = p_sql | q'! and upper (g.serial) like '% "| Upper ($P45_SERIAL) | » %' !';
    end if;
    If: P45_WIDGET_SEARCH is not null then
    p_sql: = p_sql | q'! and upper (g.widget) like '% "| Upper ($P45_WIDGET_SEARCH) | » %' !';
    end if;

    p_instr: = instr (p_sql, 'of g table_g where g.status = 1');
    p_sql_count: = ' select count (g.id) of "| substr (p_sql, p_instr);

    p_sql_count: = replace (replace (replace (p_sql_count, ' $P45_YEAR_MADE ',: P45_YEAR_MADE), "$P45_SERIAL", "' |: P45_SERIAL |)) ('), "$P45_WIDGET_SEARCH", "' | : P45_WIDGET_SEARCH | '''');

    run immediately p_sql_count in p_count;

    / * the following

    : P45_COUNT: = p_count;

    gives this error when I submit the region in the development environment

    ERR-1002 unable to find point item ID 'P45_COUNT' in the application '4000 '.

    */

    Select count (1) in the table_sql p_table_count where app_session =: APP_SESSION.
    If p_table_count = 0 then
    insert into table_sql (app_session, sql_text, session_date, count) values (: APP_SESSION, p_sql_count, sysdate, p_count);
    on the other
    Update table_sql set sql_text = p_sql_count, session_date = sysdate, count = p_count where app_session =: APP_SESSION.
    end if;

    / * the above written SQL and count of a table * /.

    Return replace(p_sql,'$',':');
    end;

    Hello

    Try the suggestion of Scott in Re: how to get the query region "PL/SQL function body returns the query string"?

    Andy

  • How to get the query of the region "PL/SQL function body returns the query string"?

    Hello

    is it possible to get the query string from the region of type "PL/SQL function body returns the query string"?

    I can get the definition of the region as a PL/SQL procedure, but I am interested in the returned query. I tried to write something like

    < pre > v_return_query: = «...» » ;
    : P49_QUERY: = v_return_query;
    Return v_return_query; < / pre >

    to save the return on hidden item P49_QUERY string, but it does not work. I get the error message: ERR-1002 cannot find the item for the "P49_QUERY" element ID in the application '4000 '.

    Kind regards
    Przemek

    If you need to make reference to a page element in the block then you can use this type of control to avoid having to use generic column names:

    if apex_application.get_current_flow_sgid(:APP_ID) = apex_application.get_sgid then-- runtime  :P9_SQL := vSQL;else-- design time  null;end if;
    

    But if all you want to do is capture the SQL debugging you can take all the references element in the block and use the insert statement (in a debug table) as I showed earlier.

    Scott

  • Function body PLSQL returning a sql report returns ORA-01403 no data found

    I'm on APEX 3.1.2.00.02 and Oracle 10 g.

    I develop a relationship with the type of SQL query (body of function from PL/SQL returning SQL query). But the performance of the report, I get

    error report:
    ORA-01403: no data found


    Source of the region
    declare
      qry varchar2(32767);
    begin
      --Procedure call
      my_pkg.get_query(qry);
    
      htp.p(qry);
    
      return /*select 1 from dual */ qry;
    end;
    Procedure
    PROCEDURE get_query (V_QRY OUT VARCHAR2)
    IS
      qry varchar2(32767);
    begin
    
      qry := ' select name
         , max(decode(to_char(service_date,''Mon-YY''), ''Jan-09'', value, null)) as "Jan-09"
         , max(decode(to_char(service_date,''Mon-YY''), ''Jan-09'', value, null)) as "Feb-09"
         from MY_TABLE
         group by name ';
      
      V_QRY := qry;
    end;
    The query will be improved later to add more month and year according to the user settings that I am running on this report.

    I want to use specific query column names. I saw this suggestion from Scott in a number of threads to use / * select 1 double * / with the query, but does not not in my case.

    Please can anyone suggest what I can do to make it work?

    Kind regards

    Amir

    First of all, unit you have tested the procedure (namely, in the workshop of SQL, SQL * Plus, SQL Developer, etc, etc) to see if it produces the output in the first place right?

    If you have, and the generated query string is valid, try to assign the output to a page element (allowing you to visualize in the session browser), or even through the procedure output window for debugging (using the wwv_flow.debug function). This might indicate a change of State or session that is causing it not to return. You might find this easier to achieve if you switch from one "procedure and output parameter ' combination 'function returning string' approach."

    If not, try to re-create the report in a new region - sometimes I came across strange bugs with parts of the report which were solved in this way.

Maybe you are looking for