How to retrieve report region source statement programmatically?

Hi all,
I have several report regions in an apex application each
of type "PL/SQL function body returning SQL query"
and of same structure like:
bq. declare \\ stmt varchar2(32767); \\ ... \\ begin \\ /* some stuff preparing sql query string */ \\ stmt := 'select' || ' a,b,c' || 'from table'; \\ return stmt; \\ end;
Now I need to retrieve the region source returned sql statement programmatically.
The region source is stored in apex view "apex_application_page_regions.region_source".
But what is the best way to retrieve the SQL statement value, by executing
the anonymous pl/sql block OR how does it work in apex internally?
An "execute immediate +region_source+ ... " approach does not work due to PLS-00372.
Any hints?
Regards,
Matthias

Dear Matthias,
an interesting problem you raise here. The solution is to create a function from the region source, call that function and then do something useful with the result.
Let's suppose your region source is :
declare v_text varchar2(100); begin return(''select * from emp''); end;
- put this text instead of the first declare
declare
v_statement varchar2(4000) := '
declare
function test return varchar2 is
- put this code behind the source:
begin
dbms_output.put_line(test);
end;';
begin
execute immediate v_statement;
end;
Now you have created a anonymous PL/SQL block that can be performed. The whole code looks like:
declare
v_statement varchar2(4000) := '
declare
function test return varchar2 is
begin return(''select * from emp''); end;
begin
dbms_output.put_line(test);
end;';
begin
execute immediate v_statement;
end;
Instead of the put_line you might set a package variable, so that you can use the result in another way,
good luck, DickDral

Similar Messages

  • How to change report region fields in read only mode?

    How to change report region fields in read only mode?
    skud.

    add the following javascript fuction to page header(or Javascript function and variables section)
    function disableItems(pRegionStaticId,pDisableFlag) {
      $('#'+pRegionStaticId).find('[name^=f]').each( function(){ /* matches fxx */
        if( $(this).attr('name').match(/f[0-9][0-9]/) ){
          return $(this);
      }).attr('disabled',pDisableFlag);
    pRegionStaticId is the region's static Id+
    Note that this code specifically disables only application arrays. Disabled items are not available after submission (and hence are different from readonly) . But any page javascript can modify disabled or readonly items(client side), so you must check at the server side to validate the data.
    You can disable items using
    disableItems('MY_REGION_ID' ,true);and enable them by passing false
    disableItems('MY_REGION_ID' ,false);

  • SQL report region source to call a pl/sql function using DB link

    Hi - I have a pl/sql function fn_dbtype(id NUMBER) defined in database X. The pl/sql function executes couple DML statements and returns a string (a SELECT query). I am able to call this function using SQL Plus (Connected to Database X) as below and it works fine:
    declare
    vSQL VARCHAR2(100);
    begin
    vSQL := fn_dbtype(1);
    end;
    The DML operations completed fine and vSQL contains the "Select" query now.
    In APEX:
    I am trying to create a SQL report in APEX using SQL query(PL/SQL function returning a sql statement) option. I am trying to figure out what to put in the region source so that the output of the "Select" query is displayed in the report.
    Moreover APEX is hosted in a different database instance. So I would need to call this pl/sql function using a DB Link.
    Please let me know what I need to put in the region source to execute the pl/sql function which returns the "Select" query thereby displaying the query output in the report. Thanks.
    Edited by: user709584 on Mar 19, 2009 2:32 PM
    Edited by: user709584 on Mar 19, 2009 2:34 PM

    try something like this:
    return fn_dbtype(1)@dblink;

  • How to Set Report Region Title Dynamically

    I have code working to periodically refresh a Interactive Report on a page. I have the following code in the page header:
    <script type="text/javascript">
    //automatic reload IRR
    function fnc_reloadIRR () {
    gReport.search('SEARCH');
    window.setTimeout(fnc_reloadIRR, 10000);
    // this means the code execution starts after 10 seconds
    window.setTimeout(fnc_reloadIRR, 10000);
    </script>
    This is working great. The title of the report region is "Intraday Color Code Test - &P1_LAST_REFRESH_TIME."
    I have a hidden page item named P1_LAST_REFRESH_TIME on the page that contains the last time the report was refreshed. I am struggling with resetting this value when the report region is refreshed. ( May not even need this item!)
    To address this, I created an On Demand application process that gets the Last Refreshed string. I then altered the above code like this:
    <script type="text/javascript">
    //automatic reload IRR
    function fnc_reloadIRR () {
    var ajaxRequest = new htmldb_Get( null, &APP_ID., 'APPLICATION_PROCESS=SET_LAST_REFRESH_TIME',0);
    gReport.search('SEARCH');
    window.setTimeout(fnc_reloadIRR, 10000);
    ajaxResult = ajaxRequest.get();
    // this means the code execution starts after 10 seconds
    window.setTimeout(fnc_reloadIRR, 10000);
    </script>
    Note the addition of the ajaxRequest stuff. This, too, is working. That is, if I check the value in ajaxResult, it does contain the correct, current time. So far so good.
    What I can't figure out is how, now, to get a reference to the title attribute of the Interactive Report Region so that I can reset it.
    I AM SOOOOO CLOSE. Can anyone fill in this last part of the puzzle for me?

    To clarify, I really just need to know how to get a reference to the Report Region's title so that I can set it to the value currently stored in "ajaxResult"

  • How to outline report regions

    Hi,
    I have a page with three report regions. Two (with column 1 and 2) on the region 4, and one in region 5 (with column 1).
    The report in region 5 starts 3 or 4 characters earlier on the page then the first report of region 4.
    How to get a correct outline (same starting point for displaying the region) ?
    Hope I made my self clear.
    Any reaction will be appreciated, in advance.
    Leo

    Hello,
    If you can put an example on apex.oracle.com it will be much easier to help you out. Layout issues are really hard to debug if you can't see them.
    Carl

  • How to format report region titles?

    How do I format the report region titles with CSS? Is there a template for the Title lable?
    Pete

    Hello,
    The Report Template or the Report Region Template?
    And yes you can do both.
    Example of report template with css.
    http://htmldb.oracle.com/pls/otn/f?p=11933:7
    Carl
    Message was edited by:
    Carl Backstrom

  • How to hide report region?

    Hi All,
    In my application i am uisng the serach visibility concept when i am click on Search link i am displaying the another report as message, since they have not entered or selected any thing before clicking on serach button.
    <{font size="7" color="red"> No Data Found for Search Criteria. Please <{a href="f?p=&APP_ID.:6:&SESSION.::NO:"> Click here </a>} to re-enter serach criteria!! <{/font>
    Now when this message comes they will click here uisng the above message during that this region should hide and only first region should be visisble. For this i have tried like this
    <{font size="7" color="red"> No Data Found for Search Criteria. Please <{a href="f?p=&APP_ID.:6:&SESSION.::NO:P6_HIDE:hide"> Click here </a>} to re-enter serach criteria!! <{/font>
    But it it throwing error as "Unable to find item ID for item "'show'" in application. How to resolve this problem.
    Or
    Is they any othet way insted of displaying the report can i show in popu message staying no data found.
    Thanks,
    Anoo..

    Hi,
    You can use javascript alert message or some modal popup message (plugin or your own)
    Just create a condition when the actions should be fired. (in your case: click on search button + some_fields are empty / not clicked)
    Regards
    J :D

  • How to retrieve first update SQL statement initiator (locking)

    Hi!
    i have a table called as
    test ( A number, B varchar2(10));
    1) inserted 1000 records
    2) update test set A=A where A=1;
    3) open new session issue update test set B=B where A=1;
    reselt lock;
    opened again a new session and issued this statement
    COLUMN blocker format a15
    COLUMN blockee format a15
    SELECT (SELECT username || '.' || a.SID FROM v$session
    WHERE SID = a.SID ) blocker, ' is blocking ',
    (SELECT username || '.' || b.SID FROM v$session
    WHERE SID = b.SID ) blockee, ' from executing: ',
    (SELECT sql_text FROM sys.V_$SQL
    WHERE address =
    (SELECT sql_address FROM v$session WHERE SID = b.SID ) )
    FROM v$lock a, v$lock b
    WHERE a.BLOCK = 1 AND b.request > 0 AND a.id1 = b.id1 AND a.id2 = b.id2;
    Result as:-
    BLOCKER 'ISBLOCKING' BLOCKEE 'FROMEXECUTING:'
    (SELECTSQL_TEXTFROMSYS.V_$SQLWHEREADDRESS=(SELECTSQL_ADDRESSFROMV$SESSIONWHERESI
    SYS.159 is blocking SYS.144 from executing:
    UPDATE TEST SET B=B WHERE A=1
    question is how can i retrieve my first update sql statement i:e (initiator)....?
    as (UPDATE TEST SET A=A WHERE A=1;)
    Regards,

    Since releasing 10.2.0.1 several years ago Oracle has released patches to 10.2.0.2, 10.2.0.3, and 10.2.0.4. I would highly recommend you read the patch notes and get your system current.
    I note that you did not answer my two follow-up questions leading me to assume you do not have the license to look at the tables and views supporting ASH and AWR. Without them I do not believe you can retrieve the information you seek.
    I no longer have 10gR2 on my laptop so I am not sure but take a look at gv$session.
    Do you have columns named "BLOCKING_SESSION_STATUS", "BLOCKING_INSTANCE" and "BLOCKING_SESSION"? If you do that might lead you to a way you could track it down via gv$sql.

  • How to retrieve value from insert statement

    hi,
    how can i get a certain value from insert statement and store it in a variable.
    suppose i am inserting emp_no , emp_name , emp_salary to employee table
    and i want to store the emp_name in a variable for other processing,
    how can i accomplish this ? i'm guessing that i have to use trigger,
    but dont know the procedure .
    any help will be greatly appreciated
    thanks

    insert into <table> valiues (....) returning <expression> into <variable>
    You could and should have found this using the SQL Language reference manual
    or
    http://www.morganslibrary.org/reference/insert.html
    Sybrand Bakker
    Senior Oracle DBA

  • Report region source error

    Hi all,
    I'm trying to display report ( SQL Query report ) the query is as follows:-
    SELECT E.C001, E.C002, AE.C001, AE.C002
    FROM APEX_COLLECTIONS COLLECTION_NAME = 'EXAMPLE' A
    INNER JOIN
    APEX_COLLECTIONS COLLECTION_NAME = 'ANOTHER_EXAMPLE' AE
    ON
    E.SEQ_ID = AE.SEQ_ID;
    but it gives me generic column error ====> ORA-00933
    Can anybody help me out
    Thanks
    Deep.

    Hi Jeff,
    Thanks for quick response, but I didnt get your point what are you trying to say, can you show me with an example in this thread.
    I was narrowing down the problem and hence was writting the query:-
    SELECT E.C001, E.C002
    FROM APEX_COLLECTIONS
    WHERE COLLECTION_NAME = 'EXAMPLE' E
    but the above query giving me the error, if I dont use an alisa name it doesnt gives me any error, so it means I cannot use alias name into collections is it?
    Thanks
    Deep

  • How to retrieve the hyperlink source/destination for an image

    Hi
    I am using Indesign CS4 on windows. I am trying to make my way learning InDesign via the SDK documents. However I am not able to understand how I can do the following
    In InDesign I have placed an image and using the "interactive" menu added an hyperlink to the image. Now, in my code, given the itemRef for the image, how can i get the hyperlink associated with it?..
    I could probably go through the HyperlinkTable and loop through all the hyperlink lists to co-relate which image in my document has the hyperlink.
    However what I want to do is given the itemRef of my image, how do i get hyperlink associated with it
    thanks for your help
    --Sam

    Yes, I could of course filter the image myself (I'm using my own modifed version of the ACME GifEncoder to save the image, so that I could even do it during the encoding without ImageFilter). So my problem could be reduced to reduce an array of more than 255 colors to 255 colors by eliminating colors which are very near from each other.
    The point is that I don't have any algorithm to make an efficient color reduction with error diffusion like every graphic software would do. I would have imagined that such a standard algorithm would be somewhere in the JAVA API. If not, I'm gonna have to invent and implement my own algorithm...
    Yannick

  • How to find orientation of  image displayed in a report region

    Hello,
    I have Apex 3.1 application showing an image in a report.
    The images are held as files on the web server and filename and description held in a database table
    I can use SQL to retrieve the data into report columns and then HTML expression to display the image as a fixed size as shown below. This works fine for landscape pictures but obviously distorts portrait ones.
    I wanted to check the orientation of the image and adjust width and height if portrait. I was considering using javascript to get image.height and image.width but am not sure how to reference the column and feed back into the HTML expression.
    Is this this the best approach and any help how to reference the column would be appreciated
    Many thanks
    Colin
    The Report Region Source is -
    select      "PHOTOFILE"."FNAME" as "FNAME" ,
    "PHOTOFILE"."ID" as "ID",
    "PHOTOFILE"."DESCRIPTION" as "DESCRIPTION",
    "PHOTOFILE"."FNAME" as "IMG2"
    from      "PHOTOFILE" "PHOTOFILE"
    where id=:P4_IMAGE_IDColumn Attributes IMG2
    Column Formatting
    HTML Expression
    <B><I><U><font face="verdana size="16"><center> #DESCRIPTION# </I></U>
    <font face="verdana size="20">&P4_DESCRIPTION.
    </B></center></font>
    <br/>
    <img src="#IMG2#" width=600 height=400  >

    This example may help you, although a bit different from what you want to achieve:
    http://apex.oracle.com/pls/otn/f?p=31517:212
    The point was:
    1. display image region should be fixed size (300px wide and 300px height)
    2. if the image size is bigger than that, the region should expand automaticaly.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How to run a EXECUTE IMMEDIATE statement in a Interactive Report

    Hello all!!
    I need to make a dinamic construction of a query to execute in a Interactive Report, but the Region Source only allows simple SELECT statements. There is any way to run a EXECUTE IMMEDIATE statement in a Interactive Report Region Source?
    Regards Pedro.

    Thank you Andy for your reply.
    I have been testing for a while the use of a collection in the interactive report but i am unable to load data in the interactive report.
    I created the collection successfully in the SQL Commands with the code:
    declare
    v_sql varchar2(32000);
    begin
    v_sql:='select ename, job from emp';
    APEX_COLLECTION.CREATE_COLLECTION_FROM_QUERY('coleccao_emp',v_sql,'NO' );
    end;
    I tested successfully the creation of the collection with the query:
    SELECT c001, c002
    FROM APEX_collections
    WHERE collection_name = 'COLECCAO_EMP'
    My problem is: the data of the collection are returned in the SQL Commands but when i run the query statament in an interactive report, report or even a Pl/Sql region in my application the data aren't displayed, only the message (No data found).
    Can someone explain why, besides the collection is populated the interactive can not print the results.
    Regards Pedro.

  • Partial Paging on Report Regions

    I haven't seem a large use of Partial Paging on Report regions on any of the example packaged application
    Is there a way I can implement partial paging on a subset of a report region ? e.g. I have a grid like the following
    project 1
    task 1
    task 2
    project n
    task 1
    task 2
    If I click on projects the tasks belonging it should expand .
    In my ASP application I just hide and display with DIV statements. Now I am upgrading to APEX I want to use Partial Paging. How flexible are report regions in APEX in regards to customising to this level and can it be done ?
    Stephen

    Hello,
    >>
    I haven't seem a large use of Partial Paging on Report regions on any of the example packaged application
    >>
    We will look into it. Since PPR is built in now we should turn it on pretty much everywhere.
    Carl

  • SQL Query Too Large For Report Region

    Oracle Friends:
    I have a SQL query that is 24,000 characters long. APEX fails when I try to create a report using this query, probably because it is too long.
    I get an "ORA-01461: can bind a LONG value only for insert into a LONG column" after I paste it and try to go to the next page.
    Any ideas? I can't make my query any smaller without creating intermediate tables.
    Any help would be most appreciated.
    Regards,
    Rich Locus

    Hi,
    If possible, try to reduce the no. of characters from your SQL query. Ex. use shorter aliases etc in your query. Also, as suggested above, create some views which can form a part of your query and then use those views in your main query to reduce the total no. of characters.
    The report region source can take some limited no. of characters only. Exact figure is not known to me.
    Try the above suggestion and see if this works or not.
    Regards,
    Mangal

Maybe you are looking for

  • How to import URL image into Adobe Muse ?

    Hello dear Adobe Community, I have a (silly) question, I'm building my website on muse and I can't find the way to import URL image. Are you forced to have all your image stocked in website ? I used to have everything on Google Plus to save me some s

  • Solaris 10 Patch Question

    Assuming two identical systems installed side-by-side and operated by the same owner. Both machines are registered with Sun Microsystems and possess valid licenses for Solaris 10. The owner has determined the same Software Update (formerly called a �

  • Birthday alarms every night at midnight driving me insane!

    I keep getting birthday alarms going off every time someone has a birthday. The alarm goes off at midnight. I have birthdays turned off in the Calendar app. I have all alarms off in the Preferences/Mail,Contacts,Calendars/Calendars. I tired deleting

  • Goods movement in QC confirmation for inprocess operation

    Dear Friends, I am doing inprocess inspection for routing operations. After results recording, I get the window where I am entering yield. If I go to confirmation tab, I can enter the activities and qualntity. But ther I am not getting goods movement

  • Migration Characterset Issue

    Hi, I am involved in a Data Migration project. The database version I am using is Oracle 10.2.0.5 and the NLS_CHARACTERSET is set to UTF8 on the database. The requirement is to provide the data extract in Unicode for the new databse. I have set the N