Column order in SQL Query (PL/SQL function returning a query)

Hi,
when I define a PL/SQL function returning a query inside a region, I often find that the column order is arbitrarily changed.
How do I enforce the column order ?
Bye,
Flavio

I removed the 11th column called service_name from this dynamic query: and now the report says: report error:
ORA-01403: no data found. I messed around with the Headiuns Type. It was set to Custom. I changed it to Column Names. There is no difference.
I am not sure how to fix?
declare topqry varchar2(32000);
whereqry varchar2(32000);
finalqry varchar2(32000);
var_status varchar2(100);
division_status varchar2(50);
office_status varchar2(1000);
user_status varchar2(1000);
overdue_status varchar2(1000);
begin
if :P10_FALLBACK = 'All' then
var_status:= ' and vp.status in (''FA'',''FBA'',''FBI'',''25%'',''50%'',''90%'',''Closed'') ';
elsif :P10_FALLBACK = 'Active' then
var_status:= ' and vp.status in (''FA'',''25%'',''50%'',''90%'',''FBA'') ';
elsif :P10_FALLBACK = 'FB' then
var_status:= ' and vp.status in (''FBA'',''FBI'') ';
elsif :P10_FALLBACK = 'Closed' then
var_status:= ' and vp.status in (''Closed'') ';
elsif :P10_FALLBACK = 'Inactive' then
var_status:= ' and vp.status in (''FBI'') ';
end if;
if :P10_DIVISION = 'All' then
division_status:= ' and vp.vms_division in (''News'',''Ad Services'') ';
elsif :P10_DIVISION = 'News' then
division_status:= ' and vp.vms_division in (''News'') ';
elsif :P10_DIVISION = 'Ad' then
division_status:= ' and vp.vms_division in (''Ad Services'') ';
end if;
if :P10_OFFICE = '%' then
office_status:= ' and OFFICE_ID in (select office
from VMS_OFFICE_ACCESS
where user_id = lower(:P0_user) ) ';
else
office_status:= ' and OFFICE_ID in :P10_OFFICE ';
end if;
if :P10_LIMIT_USER = '%' then
user_status := ' and SALESPERSON in (select first_name || '' '' || last_name
from VMS_PROSPECT_users u
join vms_office_access o
on u.office_id = OFFICE
where o.user_id = lower(:P0_USER) ) ';
else
user_status:= ' and SALESPERSON in (:P10_LIMIT_USER ) ';
end if;
if :P10_SHOW_OVERDUE = 'Show' then
overdue_status:= ' and target_close_date <= sysdate ';
var_status:= ' and vp.status in (''25%'',''50%'',''90%'',''FBA'') ';
else
overdue_status:= ' and FIRST_APPOINTMENT between
nvl(to_date(:P10_FIRST_APPT_START, ''mm/dd/yyyy''),FIRST_APPOINTMENT) and
nvl(to_date(:P10_FIRST_APPT_END,''mm/dd/yyyy''),FIRST_APPOINTMENT) ';
end if;
topqry := 'SELECT OFFICE_ID ,vp.PROSPECT_ID ,ENTRY_DATE ,ACCOUNT , NEXT_CONTACT_DATE ,ACTION_STEP ,
TARGET_CLOSE_DATE ,vp.STATUS ,SALESPERSON ,vp.SALES_TYPE ,service_name , FIRST_APPOINTMENT ,MODIFY_DATE ,EST_ANNUAL_REVENUE ,EST_INCREMENTAL_REVENUE ,
pi.NOTES , pi.SALES_TYPE ,pi.STATUS ,Contact ,Origin_Source FROM VMS_PROSPECTING_ITEMS pi right outer join VMS_PROSPECTS vp on vp.PROSPECT_ID = pi.PROSPECT_ID left outer join VMS_SERVICES vs on vs.service_ID = pi.service_ID where 1 = 1 ';
whereqry := ' and (not exists (select *
from VMS_PROSPECTING_ITEMS i3
where vp.prospect_id = i3.prospect_id)
or exists (select *
from VMS_PROSPECTING_ITEMS i2
where i2.order_id = pi.order_id
and active = ''Y'' )) and instr(upper(ACCOUNT),upper(nvl(:P10_ACCOUNT,ACCOUNT))) > 0 ';
whereqry := whereqry || var_status || division_status || office_status || user_status || overdue_status;
finalqry := topqry || whereqry;
return finalqry ;
end;

Similar Messages

  • Function returning a query

    Hi guys,
    A query suddenly became very slow & has remained like it while connecting over a database. I assume the reason is because the data is being retrieved from 6 tables across a link (6 different connections to the same database) so I thought a view should be better as I had a similar issue and this seemed to resolve it. However I then thought that perhaps a function returning the results would be faster as it would mean I could include the where clauses & group by clause to be done remotely on the database rather than locally after much more rows were returned...is this assumption correct?
    My query is as follows:
    select     rpad(username,18) user_name, rpad(terminal,18) terminal_id, rpad(userhost,30) host_name, 
               action_name, count(*) actions, sum(sessioncpu) session_cpu
    from
    select     username,
       terminal,
       userhost,
       action_name,
       to_char(timestamp,'DD/MM/YYYY HH24:MI:SS') timestamp,
       logoff_time,
       returncode, session_cpu sessioncpu
    from       dba_audit_session@XXX
    where (logoff_time >= sysdate - :P1_RAD
    AND :P1_RAD IS NOT NULL AND :P1_RAD != -1
    AND :REQUEST != 'But')
    OR (logoff_time >= to_TIMESTAMP(TO_DATE(:P1_FROM, 'DD-MON-YY') || ' ' || :P1_FROM_HOUR, 'DD-MON-YY HH24:MI:SS')
    AND logoff_time < to_TIMESTAMP(TO_DATE(:P1_TO, 'DD-MON-YY') || ' ' || :P1_TO_HOUR, 'DD-MON-YY HH24:MI:SS')
    AND :REQUEST = 'But'
    AND :P1_FROM IS NOT NULL AND :P1_TO IS NOT NULL)
    union
    select username,
            terminal,
       userhost,
       action_name,
       to_char(timestamp,'DD/MM/YYYY HH24:MI:SS') timestamp,
       logoff_time,
       returncode, sessioncpu
    from
    select
           userid            USERNAME ,
           userhost          USERHOST ,
           terminal          TERMINAL ,
           cast (
               (from_tz(ntimestamp#,'00:00') at local) as date) timestamp,
           act.name          ACTION_NAME ,         
           logoff$time logoff_time      /* LOGOFF_TIME   */,
           sessionid         /* SESSIONID */,
           returncode        /* RETURNCODE */,      
           sessioncpu        /* SESSION_CPU */      
    from sys.aud_archive@XXX aud, system_privilege_map@XXX spm, system_privilege_map@XXX spx,
         STMT_AUDIT_OPTION_MAP@XXX aom, audit_actions@XXX act
    where   aud.action#     = act.action    (+)
      and - aud.logoff$dead = spm.privilege (+)
      and   aud.logoff$dead = aom.option#   (+)
      and - aud.priv$used   = spx.privilege (+)
    and act.action between 100 and 102
    where (logoff_time >= sysdate - :P1_rad
    AND :P1_RAD IS NOT NULL AND :P1_RAD != -1
    AND :REQUEST != 'But')
    OR (logoff_time >= to_TIMESTAMP(TO_DATE(:P1_FROM, 'DD-MON-YY') || ' ' || :P1_FROM_HOUR, 'DD-MON-YY HH24:MI:SS')
    AND logoff_time < to_TIMESTAMP(TO_DATE(:P1_TO, 'DD-MON-YY') || ' ' || :P1_TO_HOUR, 'DD-MON-YY HH24:MI:SS')
    AND :REQUEST = 'But'
    AND :P1_FROM IS NOT NULL AND :P1_TO IS NOT NULL)
    group by username,   terminal,   userhost,    action_name
    order by actions desc;So it would take 6 parameters (p1_rad, request, p1_from, p1_to, p1_from_hour, p1_to_hour) and return a table with 8 columns. Would the WHERE & GROUP BY clauses being done remotely rather than on APEX be much better?
    Mike

    In general functions don't help much to increase the performance.
    However sometimes you can programatically choose different select statements depending whether a parameter is filled by the user or not. This allows you as a programmer to provide different and optimized statements depening on the input conditions.
    simplified pseudocode example
    "SELECT"
    select *
    from myTable
    where (column1 = :param1 or :param1 is null); /* problematic to get an index scon on column1 for this OR expression */
    "PL/SQL"
    if :param1 is null then
      select *
      bulk collect into ...
      from myTable; /* Full table scan will be used */
    else
      select *
      bulk collect into ...
      from myTable
      where column1 = :param1; /* index scan on column1 can be used, column historgrams will be considered */
    end if;

  • Maximum length of query string for functions return a SELECT

    Hi all,
    I have a report that gets it's SELECT statement from a function, instead of being coded into the region. All was well but I suspect now I'm blowing some kind of limit as I'm getting an error :
         ORA-06502: PL/SQL: numeric or value error
         Error      ERR-1101 Unable to process function body returning query.
    However if I run the procedure out of ApEx and grab the SELECT statement then it works fine. The length of the query is 8636 bytes (yup, it's a beauty!).
    Does anyone know if there is a hard limit to the size of the string that can be returned?
    I'm using ApEx 3.1.
    Thanks,
    Steve H

    I do have a similar painfull scenario - Although my query length is very less i.e 618 bytes only.
    I have defined a stored function, which returns an SQL query string, this return SQL string executes fantastic but when I tried to to call this function from a APEX report it gives error. the details are as follows. Please help.......
    The function code:
    CREATE OR REPLACE function PROD."TEST_C_QRY"
    return VARCHAR2
    is
    msql VARCHAR2(32767);
    Begin
    msql:='Select null,statusname,AgeInd, ';
    For m_stat in (select statusname from a02_status)
    loop
    msql:= msql || q'[decode(statusname,']';
    msql:= msql || m_stat.statusname;
    msql:= msql || q'[',count(id),0) ]';
    msql:= msql || m_stat.statusname|| ',';
    end loop;
    msql:=rtrim(msql,',');
    msql:= msql||' from ';
    msql:= msql||'( ';
    msql:= msql||'select a.id, round(sysdate-a.registeredon) TimeSpan,';
    msql:= msql||'case ';
    msql:= msql||q'[when round(sysdate-a.registeredon)<=7 then 'Week' ]';
    msql:= msql||q'[when round(sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' ]';
    msql:= msql||q'[when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then 'Month' ]';
    msql:= msql||q'[else 'More...'  end ageind,]';
    msql:= msql||'a.status_id,b.statusname ';
    msql:= msql||'from a02_task a,a02_status b ';
    msql:= msql||'where b.id=a.status_id) ';
    msql:= msql||'group by statusname,AgeInd;';
    return msql;
    end TEST_C_QRY;
    The Output SQL comes from this is
    SQL> Select null,statusname,AgeInd, decode(statusname,'Scheduled',count(id),0) Scheduled,decode(statusname,'Executing',count(id),0) Executing,decode(statusname,
    'Completed',count(id),0) Completed from ( select a.id, round(sysdate-a.registeredon) TimeSpan, case when round(sysdate-a.registeredon)<=7 then 'Week' when round
    (sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then
    'Month' else 'More...' end ageind, a.status_id,b.statusname from a02_task a,a02_status b where b.id=a.status_id) group by statusname,AgeInd;
    The result that comes when I execute the above resultant SQL is as follows.
    N STATUSNAME AGEIND SCHEDULED EXECUTING COMPLETED
    Completed More... 0 0 4
    Completed Week 0 0 1
    Scheduled Week 1 0 0
    Completed Month 0 0 3
    Executing More... 0 1 0
    Executing Month 0 6 0
    Scheduled More... 1 0 0
    7 rows selected.
    But the surprising error that comes from Oracle XE when I use the following code for stacked bar chart
    Code:
    begin
    return TEST_D_QRY;
    end;
    Error thrown by XE report builder is as follows:
    1 error has occurred
    Failed to parse SQL query!
    Select null,statusname,AgeInd, decode(statusname,'Scheduled',count(id),0) Scheduled,decode(statusname,'Executing',count(id),0) Executing,decode(statusname,'Completed',count(id),0) Completed from ( select a.id, round(sysdate-a.registeredon) TimeSpan, case when round(sysdate-a.registeredon)<=7 then 'Week' when round(sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then 'Month' else 'More...' end ageind, a.status_id,b.statusname from a02_task a,a02_status b where b.id=a.status_id) group by statusname,AgeInd;
    Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
    Regards,
    Soumen

  • Dynamic LOV - Function returning LOV query

    Hi All,
    For some reason I can not write a generic LOV query and want to edit where clause dynamically. Is there a way to achieve it.
    My LOV query will be
    'SELECT D,R FROM LOV WHERE ID IN (1,2,3)' for one person and
    'SELECT D,R FROM LOV WHERE ID IN (4,5,6)' for another person.
    Here entire string "1,2,3" or "4,5,6" is from a page item say :P1_ID_LIST and I can not use the bind variable like 'SELECT D,R FROM LOV WHERE ID IN (:P1_ID_LIST)'.
    If I have the option of function returning the LOV query I can use
    return 'SELECT D,R FROM LOV WHERE ID IN (' || :P1_ID_LIST || ')'
    Does there a way to acheive in Apex?
    Thanks
    Balaji

    See Re: Search on a typed in list of values for at least part of the answer.
    Scott

  • Controling Column Order for Report with Dynamic SQL

    Hi,
    I have a report region using Function block returning the SQL.
    The output of the function will look like the following
    SELECT NAME, CLASS1, CLASS2,CLASS3,CLASS4, AVERAGE_SCORE FROM XXXX;
    The number of CLASSn column will be determine by the function based on the data. If the person doesn't have any score on CLASS4, the the SQL would not have CLASS4 column.
    My problem with this is I can't control the order of column appearance.
    For e.g : If my previous SQL is without CLASS4, when I query a person with CLASS4. The CLASS4 column will appear after the AVERAGE_SCORE.
    NAME---CLASS1---CLASS2---CLASS3---AVERAGE_SCORE---CLASS4
    I want it to maintain AVERAGE_SCORE as the last column.
    Can you guys give a suggestion how to handle this?
    Additional info :
    - I am disabling the report header, setting it to None as the first row of the sql returned records is the header.
    Cheers,
    Joel

    Hi all,
    My report seems to be behaving correctly once i set it to "Use Generic Column Names (parse query at runtime only)" :)
    Cheers,
    Joel

  • Function returning query takes more time to run in Apex4.0

    Hi All,
    I created a report using function returning query. The function returns query based the parameters which returns dynamic columns. When I run the query in sql developer the query generates and returns the result in 3mins. But in apex it takes maximum of 35mins to return.
    The query will return around 10000 rows.
    Is it a performance issue in the query or in Apex?can anyone please help
    Regards
    Raj

    RajEndiran wrote:
    Hi Roel,
    Thanks much for your suggestion. I run in TOAD and got the result as
    Row 1 of 500 fetched so far in 3.31 minutes which means it queried for 500 records alone ? is that not the actual time taken to run the fulll query?That reflects the time to return the first 500 records...
    Please suggest.With all the best will in the world, if I was your user and I had to wait 3 minutes for the page to refresh, I'd steadily lose the will to live!
    As this is primarily an SQL tuning question, have a look at this message in the FAQ thread in the {forum:id=75} forum:
    {message:id=9360003}
    That should give you some pointers on the right approach.

  • Change column order updateable sql query report APEX 4

    Hi all,
    I have a master detail page. Detail is SQL Query (updateable report)
    I want to change the column order but seems not possiible anymore in A4.
    In A3... on the right side of the report attributes it was possible to move columns up or down.
    path is Home>>Application Builder>>Application nnn >>Page xx >>Report Attributes
    It seems that A4 the move up or down functionality is hidden or the region is to small with no horizontal scrollbar.
    Is there a work_aorund?
    This is also the case when the pages are displayed in icon view when showing all pages using.
    Home >> Application Builder >>Application
    Most right icons are hidden after the about and task regions.
    The work-around here is to display the pages in report or detail view
    Maybe a fix needed for APEX4?
    have nice weekend!
    Hugo Perfors
    Enthousiastic APEX developer

    Hi,
    It could be your browser settings. Try zooiming out in the browser View - Zoom - Zoom Out.
    Regards

  • PL/SQL function in datamodel query

    Hi All,
    I have the following problem:
    I have a query Q1 returning a few rows. In the group G1 using this query Q1 i have a computed field returning a number NUM_1.
    select col_1, col_2 from table_1;
    So the output looks like:
    row 1 col_1 col_2 NUM_1_1
    row n col_1n col_2n NUM_1_n
    I want to order these rows by the calculated column NUM_1 the highest first.
    I know i can't order by a calculated column but can i do it by using a pl/sql function in the query to calculate the NUM_1?
    Like:
    select col_1, col_2, function(x) NUM_1 from table_1;
    And where should i create this function? Can it be done in the program unit section or do i have to create a library?
    Best regards,
    Snoesky

    Oke, i have created a break group on the calculated field.
    Ordering works fine now.
    I have an additional question:
    Is it possible to dynamically order this break (column) group? Meaning thru a parameter to tell the ordering to be descending or ascending.
    Regards,
    Snoesky

  • PL/SQL Function Returning Query Error / ORA-01858: a non-numeric char.....

    I'm trying to write a PL/SQL function to dynamically return a query with varying # of columns. I've done this type of thing before wiith much success, however this is the first time I'm using a cursor for loop within a function to accomplish my task.
    here is the error I get:
    ORA-01858: a non-numeric character was found where a numeric was expected
    Error ERR-1101 Unable to process function body returning query.
    Mind you I have tested the PL/SQL from a SQL editor and it works fine. I'm confused.
    Code is below.
    Thanks in advance!
    DECLARE
    my_query varchar2(4000);
    string1 varchar2(50) := 'select city, ';
    string2 varchar2(4000) := '' ;
    string3 varchar2(4000):= 'from
    ( select a.title, a.city, a.start_date, sum(a.total_stu) cnt
    from sj_class_summary3 a
    group by a.title, a.city, a.start_date
    having a.title = :P4_COURSE )
    group by title, city';
    TYPE date_tab_type IS TABLE OF date INDEX BY PLS_INTEGER;
    date_tbl date_tab_type;
    i number;
    BEGIN
    i:=1;
    for myrec in (select distinct start_date from sj_class_summary3
    where start_date between :P4_START_DATE and :P4_END_DATE order by 1) loop
    date_tbl(i) := myrec.start_date;
    string2 := string2 || ' max( decode( start_date, ''' || date_tbl(i) || ''', cnt,0) ) "' || date_tbl(i) || '", ';
    i := i+ 1;
    end loop;
    string2 := SUBSTR(string2,1,LENGTH(string2)-2);
    string2 := string2 || ' ';
    my_query := string1 || string2 || string3;
    return my_query;
    END;

    Hi Bob,
    you also have another date to character to date conversion in:
    decode( start_date, ''' || date_tbl(i) || ''', cnt,0)
    does this need to be:
    decode( start_date, to_date(''' || to_char(date_tbl(i), 'dd/mm/yyyy') || ''', ''dd/mm/yyyy''), cnt,0)
    Regards
    Michael

  • The order of execution (of PL/SQL function calls) changes...why??

    select e.EMPID empid,
    e.name name,
    aatest.SETVALUES(2) z,
    aatest.TEST1() b,
    aatest.TEST2() x,
    aatest.TEST3() y
    from emp e
    where e.empid = 101
    order by e.name;
    when I execute this select statement...the order of function calls is as follows:
    setvalues 1st (call no:1)
    test1 (call no:2)
    test2 (call no:3)
    test3 (call no:4)
    Now...I introduce a join between the two tacles as mentioned in the query
    select e.EMPID empid,
    e.name name,
    e2.deptno deptid,
    aatest.SETVALUES(2) z,
    aatest.TEST1() b,
    aatest.TEST2() x,
    aatest.TEST3() y
    from emp e, emp2 e2
    where e.empid = e2.empid
    order by e.name;
    The order of execution of function calls changes to
    (I observed this using DBMS_OUTPUT.PUT_LINE)
    test3 (call no:1)
    setvalues 1st (call no:2)
    test1 (call no:3)
    test2 (call no:4) (the first and last calls swap!)
    i.e: it calls the last function in the select statement at the beginning
    instead of calling it at the last. Is it the normal behaviour? or whats going on
    here?
    Can somebody explain me, please....
    Details:
    the following four functions are defined in a package called 'aatest' and compiled.
    aatest.SETVALUES(2)
    aatest.TEST1()
    aatest.TEST2()
    aatest.TEST3()
    the Tables EMP and EMP2 are two tables defined in the same schema.

    Your "thinking" is wrong here. You can not use the column order to model your program flow. As SQL is set/tupel based, there is no given sequence of the execution order. Otoh you want to have a specific order in wich your functions must be executed otherwise the result will be wrong (or undefined). Thus here you need a procedural approach. This can be done by using PL/SQL for example.
    You would code your functions in that way, that they are working correctly independent from the place where they are called ie if function1 needs the setvalues function, this function must be called inside the function1 then.
    Are you sure you need all these functions in this procedural approach inside the sql-statement? This is mostly not needed and can be accomplished by using pure SQL. If not, may be your design is broken.

  • Issue with running PL/SQL function returning Sql query

    hi, I am trying to create a report region by using the option of PL/SQL function returning sql query.
    I notice that it's very slow for the report region page to show up. In my PL/SQL function body, there are only 3 steps, first update all the 10 rows of varchar2 fields to null,then insert values to those fields, then select all from the table to show report results. It takes more than 5 minitues for the page to load up, how ever, if i run those steps in SQL*Plus, it only takes a couple of seconds to finish. Any suggestions?
    Thanks,
    gina

    Sergio, the codes are as followed,
    Declare
    q varchar2(32767); -- query
    Begin
    q := 'select "ID",'||
    '"ENTRY NAME","TOTAL","#CM","%CM","#CA",'||
    '"%CA", from Info_table';
    update info_table
    set "TOTAL" = '',
    "#CM" = '',
    "%CM" = '',
    "#CA" ='',
    "%CA"=''
    where "ID"<=10;
    // set all data in column Total to null,there is only 10 rows in the table
    update info_Table set Total = vTotal,
    "#CM" = vCM
    (those variables hold user key-in Text filed value)
    where ID = 1;
    return q;
    End;

  • Function Returning SQL in BI Publisher Report Query

    I have a report that is based on a SQL Query (PL/SQL Function body returning SQL query). The code is below. I am now trying to create a PDF version of the report using BI Publisher in APEX. When I try to build the Report Query shared component I get a syntax error when entering this code. Does anyone know if it is possible to create a Report Query from a SQL Query (PL/SQL Function body returning SQL query) and if so, how?
    v_sql varchar2(4000);
    begin
    select apexim.exec_summ_bymonth_sql ('D', :p260_time_frame, 12, nvl(:p260_population_sel, 'All'), nvl(:p260_region_sel, 'All'), nvl(:p260_oper_state_sel, 'All'))
    into v_sql
    from dual;
    return(v_sql);
    end;.

    Thanks for the suggestion Simon.
    I just created a view based on the 46-column SELECT statement from dual above and then set "SELECT * FROM myview" as the Source Query.
    Unfortunately I get exactly the same error.
    Thanks,
    Andy

  • APEX, BI Publisher and SQL Query (PL/SQL Function returning SQL Query)..

    I don't know if I should be posting this in this Forum or the BI Publisher forum, so I am posting in BOTH forums..
    I love APEX, let me say that first.. And appreciate the support offered here by the group, but am running int a confusing issue when BI Publisher tries to build a report from the above type APEX report..
    Here is my dilemma:
    I have a number of reports that are part of a Oracle package. They return an SQL Query back to a reports region on a page. I am having to deal with the column names returned are col01, col02..
    The issue I have is, when building the Application Level query to download the XML sample from in building RTF layouts in Word, you can not use this code, you MUST use a standard SQL Select.
    I have taken the sql from the function returning sql, and copied into the application query, supplying the required data values for bind variables being used in the query.
    An XML file is produced, and I use this to build the RTF format file that I load back into APEX and try to use it for the PDF rendering of the report. I can view the output as a PDF in the Word add on, but when I try using it with the report, it is returning an empty PDF file.
    Can anyone tell me what error log files on the bi publisher side I can look at to see what error is happening?
    Thank you,
    Tony Miller
    UTMB/EHN
    Title changed, maybe SOMEONE has an idea on this??
    Message was edited by:
    Tony Miller

    Hi,
    1/ first check you are passing the bind variables and
    appropriate values in the call to your report - if
    the query returns no data then you get an empty page
    So if your query takes :P10_USERNAME variable then
    pass it to the report in the URL
    f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=YOUR_REP_QUERY_N
    AME:::P10_USERNAME:MYUSER
    2/ try to use the Default layout first to check your
    report query really returns the data when called
    3/ if you defined a header in your rtf template check
    there is no & (ampersand) - if using & in the header
    and preview the template from word it displays data
    OK, but if you use this template in the report query
    it fails to render the data (bug in Apex-> Bi
    Publisher integration maybe?)
    4/ If using the table in the rtf template check its
    width does not overflow the page margins - there is a
    problem with pdf export
    5/ check
    /oc4j/j2ee/home/application-deployments/xmlpserver/app
    lication.log forthe information on BI Publisher runs
    RadoIssue was in the APEX page having issues.. I recoded a new page and am able to generate BI Publisher based PDF files..
    Thank you,
    Tony Miller
    UTMB/EHN

  • SQL Query (pl/sql function body returning Sql query)

    Hi All,
    I have created a region of "SQL Query (pl/sql function body returning Sql query)" type and it is working fine , but when I am migrating(export /import) this application from development to systest environment ,
    It gives error for this region :
    Error ERR-1101 Unable to process function body returning query.
    OK
    ORA-06550: line 1, column 52: PLS-00306: wrong number or types of arguments in call to 'FU_TRADE_REPORT_QUERY' ORA-06550: line 1, column 45: PL/SQL: Statement ignored
    Any pointer ...why this is happening.
    Thanks
    Dikshit

    If your function is a stored function that is called from within APEX (function body not coded into the app itself), have you made sure that the function has been created and compiles ok prior to installing your apex app.
    If there are some dependency issues between other PL/SQL units or database objects that are causing your function not to be compiled, you apex install will fail as you are trying to reference an uncompelled bit of pl/sql.
    Let me know how you get on
    Regards
    Duncan

  • SQL Query(PL/SQL Function Returning SQL Query)

    I am trying to write a dynamic report using SQL Query(PL/SQL Function Returning SQL Query).
    I can get the report to run but I need to concatinate some columns into one, seperated by a comma or a dash.
    I have tried select *****||','||***** alias
    also select *****||'-'||***** alias
    but I always get an error.
    Is there a way of doing this please
    Gus

    This is my full query
    declare
    v_query varchar2(4000);
    begin
    if :P63_TRAN_INFO = 2 THEN
    v_query := 'select
         A.FILENR,
         A.EXERCISENAME,
    A.STARTDATE,
    A.ENDDATE,
         A.UNIT,
    A.ACCADDRESSES, B.ADDRESS, B.ADDRESS_1, B.POST_CODE, B.TOWN,
         A.EXERCISEAREAS,
         A.TOTALVEHICLES,
    A.TOTALTROOPS+A.RNTOTALTROOPS+A.RAFTOTALTROOPS TOTALTROOPS,
    A.CAR, A.MINIBUS, A.HGV,
    A.NAMERANK, A.ADDRESS, A.ADDRESSI, A.ADDRESSII, A.POSTCODE,
    A.TRANSIT,
    A.INFOONLY
    from     BFLOG_AT A, BFLOG_ACCADDRESS B
    WHERE A.ACCADDRESSES = B.NAME
    AND A.STARTDATE >= :P63_START_DATE
    AND A.ENDDATE <= :P63_END_DATE
    AND A.AUTHORISED = 1
    AND A.INFOONLY = 1' ;
    END IF;
    RETURN v_query;
    END;
    This query runs ok, but if I try changing it to the code below with fields concatinated, then it fails
    declare
    v_query varchar2(4000);
    begin
    if :P63_TRAN_INFO = 2 THEN
    v_query := 'select
         A.FILENR,
         A.EXERCISENAME,
    A.STARTDATE,
    A.ENDDATE,
         A.UNIT,
    A.ACCADDRESSES||','||B.ADDRESS||','||B.ADDRESS_1||','||B.POST_CODE||','||B.TOWN ADDRESS,
         A.EXERCISEAREAS,
         A.TOTALVEHICLES,
    A.TOTALTROOPS+A.RNTOTALTROOPS+A.RAFTOTALTROOPS TOTALTROOPS,
    A.CAR, A.MINIBUS, A.HGV,
    A.NAMERANK, A.ADDRESS, A.ADDRESSI, A.ADDRESSII, A.POSTCODE,
    A.TRANSIT,
    A.INFOONLY
    from     BFLOG_AT A, BFLOG_ACCADDRESS B
    WHERE A.ACCADDRESSES = B.NAME
    AND A.STARTDATE >= :P63_START_DATE
    AND A.ENDDATE <= :P63_END_DATE
    --AND (A.EXERCISEAREAS LIKE "GAP, OA, OAL")
    --OR (A.EXERCISEAREAS LIKE "Harz")
    AND A.AUTHORISED = 1
    AND A.INFOONLY = 1' ;
    END IF;
    RETURN v_query;
    END;
    Cheers
    Gus

Maybe you are looking for