Function in report query builder

Hi,
It is possible to call a function in the select statement of a report query builder as followed :
select my_func()
from my_table
The function is defined as :
create or replace my_func() return vachar2 is
v_temp vachar2(100);
begin
v_temp := 'column_1, column_2, column_3';
return(v_temp);
end;
Therefore, the query should be interpreted as:
select column_1, column_2, column_3
from my_table
and the fields "column_1", "column_2" and "column_3" with the same alias name would be created for the report.
Thank you,
DS

Ok. Here is the way!
Create user parameter p_query. Datatype Character. Width 10000. Set initial value as
select RPAD('n',10) c1, RPAD('n',10) c2, RPAD('n',10) c3 from dual
** Suppose type of column 1, 2 and 3 is character and maximum length can be 10. So using this in above select statement.
Get value in After Parameter Form trigger
begin
:p_query := yourfuntion;
return(true);
end;
data model will have only this:
&p_query
Now you will see three columns in data model
c1
c2
c3
NOW error ORA-24333 can appear, when function/procedure doesn't return back anything for data model, I mean lexical parameter p_query is empty.
** You can replace whole select statement with lexical parameter.

Similar Messages

  • Conditional SQL in Report Query

    How can I code a conditional SQL in the Report query builder
    to include a WHERE clause parameter or not, depending on the value
    of a report parameter? Basically, what I want to do is:
    select field from table where x=1
    <cfif param.a eq 1>and a=1</cfif>
    Report builder does not like this, but I can't find any help
    on how to do this.

    I don't think CFML tags may be used like that in the SQL of
    report query. But then, I'm not very much into reports. If you're
    just out to get the result, then try
    select field from table
    where
    (x=1 and #param.a# <> 1) or (x=1 and #param.a#=1 and
    a=1)

  • 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

  • Functions Not Available in Query Builder

    Application Express 4.1.1.00.23
    When we go into the Query Builder and select a table and then, select a column, this adds a row for that column below the table. In that newly added row, there is a dropdown labeled "Function". However, this drop down is never enabled, i.e. clicking it has no effect.
    Inspecting this element in Chrome, we find that the following error is being thrown at line 502 of qb_core.js
    >
    Uncaught TypeError: Cannot call method 'indexOf' of undefined
    >
    The offending line appears to be:
    var lid = tableDiv.childNodes.id.substring(0,tableDiv.childNodes[i].id.indexOf('_'));
    Has anyone seen this or does anyone have a work around?
    Thanks,
    -Joe                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Mehabub,
    Seems hard to believe that it is working for you. We are on Chrome 21.0.1180.89 m. This is not working for anyone (was originally reported by an End User). BTW, we forced our users to abandon IE in lieu of Chrome. Clearing the cache makes no difference.
    It does not work in Safari. Safari -5.1.7 (7534.57.2) throws errors here:
    >
    qb_core.js:129TypeError: 'undefined' is not an object (evaluating 'e.explicitOriginalTarget.id')
    >
    if (e.explicitOriginalTarget.id == 'QUERYTEXT'){
            if (e.ctrlKey == true && (e.charCode == 97 || e.charCode == 99)) {
              return e.keyCode;
            } else {
              return false;
        }It does not work AT ALL in IE. IE doesn't even add the row for the selected column in the GUI. It throws this error (from F12 Debug):
    >
    SCRIPT5022: DOM Exception: HIERARCHY_REQUEST_ERR (3)
    qb_core.js, line 1389 character 5
    >
    This is the section of the code it dies on:
    if(document.all){
        table.firstChild.appendChild(newTR);
      }else{
        table.appendChild(newTR);
      }It does work in FireFox (15.0). This is the only browser for which this works (for anyone here).
    -Joe

  • Report- Pl/sql function returning sql query parsing page items as text?

    Hi Team,
    I am facing a strange issue .
    I have four page items namely
    1)JOB_CODE
    2)MIN_EXP
    3) MAX_EXP
    4) SOURCES1
    I have a report of the type "Pl/sql function returning sql query"
    declare
    v_sql varchar2(4000);
    begin
    if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
    v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
    end if;
    insert into query_list values (v_sql);
    insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
    return v_sql;
    end;
    Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
    Now I select the data from the debug tables.
    select unique(query) from query_list;
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
    select * from debug;
    JOBCODE     MINEX     MAXEX     SOURCE
    21     1     10     donkeyHire
    And if I run the query in sql I get some records returned
    select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
    V_CANDIDATE_ID     V_FNAME     V_CURRENT_EMPLOYER     V_EXPERIENCE_YEARS
    2     Vengu     Andale Tech     4
    But the record does not show up in the report!
    does this type of report parse page items as text?
    Why is it so?
    Waiting for an early reply.
    Thanks,
    venkat

    Venkat - You don't want to put ':SOURCES1' in quotes like that.
    Scott

  • How to add a new field in Query Builder or Report

    Hi,
    I am writing a report using Oracle 6i query builder and report.
    example:
    QTY_1 QTY_2 QTY_3
    QTY_1 and QTY_2 are table fields and QTY_3 Is not. I need to show the value of (QTY_2-QTY_1) in QTY_3.
    I need to create a field QTY_3 which is not in the database table. How do I do that?
    Jun

    Hi,
    Try using formula to return the qty_1 - qty2.
    or
    select qty_1, qty_2, (qty_1 - qty_2) qty_3
    from table;
    regards,
    CB

  • On Submit process not firing -report (PL/SQL function returning SQL query)

    Can anyone suggest possible causes / solutions for the following problem?
    I have a report region that uses a PL/SQL function returning SQL query. The report allows the user to update multiple fields / rows and then click a button to submit the page which should run the On-Submit process to update the database. However the process does not run and I get a 'HTTP404 page cannot be found' error; and when I navigate back using the Back button I cannot then navigate to any other page in my application without getting the same error. The button was created by a wizard selecting the options to submit the page and redirect to a (same) page. The button does not actually have a redirect in its definition but the wizard created a branch to the same page which should work and the button has the text 'submit as SUBMIT' next to it so it appears to be set up correctly.
    I have recreated this page several times in my application and I cannot get the On-Submit process to run. However I have created a cut down version of the same page in the sample application on apex.oracle.com at http://apex.oracle.com/pls/otn/f?p=4550:1:179951678764332 and this works perfectly so I am at a loss to understand why it does not work in my application. I cannot post any part of the application itself but if anybody would like to check out page 30 of the sample application (Customer Update Test tab) updating the surnames only, using credentials ja, demo, demo this is pretty much what I have got in my application.
    Any ideas would be much appreciated?

    Thanks for the suggestions guys. I have now identified that the problem goes away when I remove the second table from my report query. The original report query retrieved data from two tables and the process was updating only one of the tables. I thought I had approached the task logically i.e. first get the report to display the records from the two tables, then get the process to update the first table and finally to modify the process further to update the second table.
    Can anyone point me to an example of multiple row updates on multiple tables using a PL/SQL function returning an SQL query?

  • Using a function in a report query

    Why can't I call a function (basically a query) in a report query like I can from from SQL?
    Consider the following:
    Select MyFunctionName(arg) from dual;
    From SQL, it works great! No problem:
    In a report query, [Application/Shared Components/Report Queries] It doesn't work. I get an XML error:
    XML Parsing Error: not well formed
    <MyFunctionName('arg')>&lt;?xml version="1.0"?&gt;
    ----------------------^
    Why?
    Looks like APEX is not even executing the function...
    See I have a table with a CLOB field that contains properly formatted HTML. I cannot simply query for that content, since Oracle escapes the tags in the conversion to XML. I have to (somehow) tell Oracle to keep it's grubby mitts off my CLOB content. As far as I can tell, using DBMS_XMLGEN.setConvertSpecialChars is the only way to keep Oracle from escaping the html stored in the table--in fact, the DBMS_XMLGEN documentation states that it why this functionality exists in the first place!
    This is why I am trying to use a function. Simply queries don't work. The function I wrote works beautifully in SQL, but not in a report query...
    Edited by: Vorlon on Aug 5, 2010 1:20 PM

    Note from the first post:
    "In a report query, [Application/Shared Components/Report Queries]" Let me clarify: This report query is used in a BI Publisher report. Getting the information to the screen isn't the problem. I have that working. :-) It's just when I try to get the report to print that I see APEX has escaped the output before reaching BI Publisher--so BI Publisher is not the issue. I have a xsl template that will process the embedded HTML, but APEX is escaping my data before I can act on it. In other words:
    It seems Apex is not creating the XML properly, since it escapes everything. Even when the function passes back data correctly.
    Has anyone else seen this? Ideas for a workaround?
    Thanks!

  • How to change the font in query builder window in Reports 6i?

    Hi
    I am facing the old problem again and again, which is I can not find any way to change the font in query builder window in Reports 6i. The current font is so bad for alignment and ordering each part of SELECT statement. Is there any way to change this to COURIER NEW for example?

    No, but I suggest using a different editor which does allow a different text option and just pasting it in.

  • Query Builder functionality

    Has anyone built a Query Builder Page in the apps that is similar to the standard APEX Query Builder?

    I haven't done exactly this, but remember doing a tabular form genarator (similar to the tabular form wizard in the builder) choosing tables, columns and field types. But that was using Apex 3.2, now that we have jQuery and dynamic actions in Apex 4.0, it should be much easier.
    If you looking for an approach, here's one
    <li>create a left side bar region with tables from schema: report or list based
    select table_name from user_tables<li>On click of the list entry, show a modal dialog of a report based on the columns of the selected table
    SELECT * FROM USER_TAB_COLS WHERE table_name = :<TABLE_NAME ITEM> Show images based on column type ("data_type" in user_tab_cols)
    Checkboxes return the column name for each row
    <li> Have a dynamic action that runs for each checkbox calling a PLSQL to update a collection adding the clicked column name to the the list.
    Refresh a updateable report region which is based on the collection , showing the column, sort order,group by options
    and JS code to move rows up or down (
    move_up code (pseudo code)
    this_row = $(this.triggeringElement).parents('tr:first);
    prev_row = this_row.prev();
    next_row = this_row.next();
    //move up
    prev_row.before(this_row);Then the SQL code generation would concatenate the application arrays containing the column names adding columns one row at a time and adding sort and order options. You would need to some custom PLSQL coding, looping throw each row adding predicates.

  • Results in Query Builder Differ From Report Results

    I've got a report I built in SSRS using an SSAS dataset. The problem is that the results differ between the query builder result set and the actual report. For some reason, when running the actual report, certain rows are being filtered out, but yet those
    same rows appear in the result set when validating the query in the query builder.
    Here's the result set as it appears in query builder:
    ...and here are the results of the actual report:
    As you can see, 3M and Angie's popcorn are not returned in the report. I have no filters defined on the report at all.
    This appears to be happening with other result sets for the same report.
    No idea why the results are accurate in query builder and then off in the actual report.
    Any help would be appreciated!
    A. M. Robinson

    Hi A. M. Robinson,
    The issue may be caused by the data cache. When we preview a report, the report processor runs all the queries for datasets in the report using the current parameter defaults, and saves the results as a local data cache (.rdl.data) file. We can continue
    to design our report without incurring the overhead of retrieving this data again if we make no changes to either the report dataset queries or the report parameters. Please to delete the cache (.rdl.data) file try to solve the issue.
    Reference: http://technet.microsoft.com/en-us/library/ms157366.aspx
    Alternative, you can create a similar report to check if the issue is persist.
    If the issue is persist, could you please post more detail information about your report design?  It is benefit for us to do further analysis.
    Regards,
    Alisa Tang
    If you have any feedback on our support, please click
    here.
    Alisa Tang
    TechNet Community Support

  • Query builder in Reports

    In the reports when I use query builder available in the reports for the same user/owner it works fine. If I will select/use any table from other schema it creates query for it but when I again try to go to query builder it shows me blank. This behaviour is same in reports 3 and 6i. Is this a bug or there is some configuration issue?
    e.g.
    Currently I am working in the scott login and opened the query builder to build the query. I have select table EMP and the its fields I have to select. Now the DEPT table is in another schema and scott has select privs of this table. I have select the DEPT table from that schema and pressed OK and the query is now in the query window but now if I want to modify the query and want to open query builder again and it is not possible at my machine. So I have to modify the query in the query window manually.
    I hope the above detail will help u in understanding the exact situation so if still not cleared then let me know.

    Hi Sikandar,
    Make sure you are on the latest patch (patch 10), and if it still reproduces you should contact Oracle Support.
    regards,
    Stewart

  • Query for recurring reports using Query Builder in Business objects

    1. How to count webi Recurring reports using query builder in business objects? (Need Query for this)
    2. How to count Crystal Recurring reports using query builder in business objects? (Need Query for this)
    I am able to get summerized recurring reports using Query Builder.
    For Example we have 343 reports which are under recurring (This includes both Webi Reports and Crystal Reports).
    we need to get individually how many webi reports are under Recurring and Crystal reports are under Recurring.

    1. How to count webi Recurring reports using query builder in business objects? (Need Query for this)
    2. How to count Crystal Recurring reports using query builder in business objects? (Need Query for this)
    I am able to get summerized recurring reports using Query Builder.
    For Example we have 343 reports which are under recurring (This includes both Webi Reports and Crystal Reports).
    we need to get individually how many webi reports are under Recurring and Crystal reports are under Recurring.

  • How to identify recurring instance of a report using Query Builder

    Hi,
    I am having a report scheduled for four different set of  parameters.  I want to identify the instances pertaining to each schedule.  I tried the last successful instance but it gives only the last instance detail.
    Kindly help me
    Thanks and Regards,
    Subbu S

    Hi,
    Use the following query in the query builder
    SELECT
    SI_NAME, SI_SCHEDULEINFO.SI_STARTTIME
    FROM
    CI_INFOOBJECTS
    WHERE
    SI_RECURRING = 1
    SI_NAME: The recurring report name.
    SI_SCHEDULEINFO.SI_STARTTIME:  The date and time the report is scheduled to run next.
    The query above will return all the recurring reports .
    Regards,
    Prithvi
    Edited by: Raj_10 on Sep 14, 2011 1:54 PM

  • Can Execute Report But Fails in Query Builder

    I'm running into an odd issue...
    I've inherited a report that was built using Visual Studio. It's going against an Analysis Services cube and the query is in MDX.
    For some reason, when I view the query in Query Builder and attempt to execute the query, it throws an error. I then cancel out of Query Builder and cancel any changes. Now if I actually run the report, it runs just fine. Users have verified that the results
    are correct.
    I've never seen this before! I've attached the query and the error message:
    WITH
    SET [Selected Discipline] AS STRTOSET(@Disciplines, CONSTRAINED)
    SET [Selected Department] AS STRTOSET(@Departments, CONSTRAINED)
    SET [Selected Departments] AS IIF(@Disciplines = @Departments, 
      FILTER(
        DESCENDANTS([Selected Discipline], [Employee].[DISC - DEPT - EMP].[Department], AFTER), 
        NOT INSTR([Employee].[DISC - DEPT - EMP].CurrentMember.UNIQUE_NAME, "Freelance")),
      DESCENDANTS([Selected Department], [Employee].[DISC - DEPT - EMP].[Department], AFTER))
    SET [TTM] AS { LastPeriods(12, StrToMember(@SelectedMonth, CONSTRAINED)) }
    SELECT 
      [Measures].[Employee Hours], 
      [Measures].[Employee Hours %] 
    } ON COLUMNS, 
    NON EMPTY CROSSJOIN(
    [Selected Departments],
    [Employee].[Employee Bill Rate].[Employee Bill Rate].ALLMEMBERS,
    [Employee].[Employee Level].[Employee Level].ALLMEMBERS,
    [TTM]) 
    DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS 
    FROM [OLSON BI]
    WHERE (
    [Employee Hours Time Category].[Time Category].&[Client Facing],
    [Employee Hours Time Category].[Utilization Category].&[PRODUCTION])
    CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS
    The error is:
    A. M. Robinson

    Hello,
    Glad to heard that the issue had been solved and thanks for your sharing. It will be very beneficial for other community members who have similar questions.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

Maybe you are looking for

  • Can not access the media card files Blackberry 8310 - HELP

    Can not access the media card files Blackberry 8310.  I had a battery drain problem. The unit would only last 16 hours before completely drained. Purchased a new battery with the same result. I figured that I should try a complete reset so I did a ha

  • Static NAT inbound correct - Outbound using Interface IP

    Here is the scenario that i have: I have a router (2921) that has 2 interfaces:      G0/0 - WAN - 10.254.1.10      G0/1 - LAN - 192.168.1.230 I have a few static NATs for servers that are behind g0/1, this is the only nat config i have except for an

  • Adobe Premiere Pro 5.5 Crashes on start up

    I was editting on a Mac in Premiere 5.5. I was in one project, saved and exited and created another project. I finished it and tried reopening the first one, and now Premiere crashes after I choose a project from the opening splash page every time I

  • Tables for PO & GRN

    hi! all,          can anybody help me to fetch the data based on the combination of Purchase Order & Goods Receipt i,e from which table can fetch the Goods Receipt for the given Purchase Order. (for PO - EKKO , EKPO) Thanks and Regards, Nagulan

  • Oracle8.1.7 install problem

    I installed oracle8.17 at solaris 8, after the system installation ,it start a database configuration assistant, after I configue all the parameters, it began creat a database, now it appear an error, 'not connect to database'. There are no init.ora