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;
Similar Messages
-
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,
MatthiasDear 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 -
Demonstrating PL/SQL Functions Using SQL Developer
Good afternoon,
I'm starting to write some PL/SQL functions to replace some of the SQL that I use most frequently. A couple of very simple examples would be:
create or replace function func_test (p_1 number) return number
is
x number;
y number;
begin
x :=1;
y :=2;
return p_1 * x * y;
end func_test;
create or replace function func_test2 (p_1 varchar2) return varchar2
is
return_val varchar2(10);
begin
select p_1 into return_val from dual;
return return_val;
end func_test2;
However, at my workplace I haven't been granted create function privileges yet until I can demonstrate some examples, which is understandable.
For the time being, without these privileges, is there a way I can build/test functions in principle locally using SQL Developer without the need to write the functions to our database? I.e. can I demonstrate the above in SQL Developer, but without wrapping in create or replace syntax?
I hope this isn't too vague.
Using Oracle 11gR2 (not logged in to workplace database at the moment for specific version no.)
SQL Developer 3.4
Thanks,
TPsb92075 02-Nov-2013 19:12 (in response to TinyPenguin)
populating test DB with data is a solvable problem.
You don't need client data to test code (functions).
You only need sample test data; which generally is less than a few dozen records per table.
Absolutely, of course. Our client database is pretty messy though, and includes data prior to the implementation of more recent business rules that I need to take account of. Useful perspective though, thanks.
rp0428 02-Nov-2013 19:14 (in response to TinyPenguin)
Sure, but then I wouldn't have access to all the data in our client database to test functions under various circumstances.
Huh? Why not? It's your database so what keeps you from creating a database link to your client database where all the data is?
Also, I suppose it's not good practice to constantly write/replace/drop functions to/from a database when developing them? Better to test the function in principle and then write to the database?
Huh? Why not? What you think a dev database is for if not for development?
Based on your two posts so far in this thread it's understandable why they don't want to give you privileges yet. Those sample 'functions' you posted are NOT a good use for functions.
In sql developer you can just create and save the queries you use most often. There is no need to create functions for that.
But if you do need an anonymous function now and then just create one using sql*plus syntax:
Our IT department are pretty sensitive about how they allow access, even to the dev environment. As you've identified, I'm not naturally a programmer so the option to play around with the data to develop some representative examples about how we can simplify and devolve SQL reporting to more members of staff is useful to me. I just wrote those two function quickly for the purpose of posting some sample data, which I thought would be helpful. Thanks for illustrating how to return their output using an anonymous block.
FrankKulash 02-Nov-2013 19:13 (in response to TinyPenguin)
Hi,
The obvious solution is to get the privileges. If your employer really wants you to do something, they need to give you the necessary privileges to do it. It's silly for them to tell you to do something, but refuse to let you do it.
Failing that, you can install Oracle on your own machine, as suggested above. It's free and legitimate if you're only using it for learning and developing. Oracle Express Edition is very easy to install.
As a last resort, you can write functions and procedures that are local to an anonymous block, like this:
Thanks Frank. Yeah I'm going to speak with our DBA next week about privileges. I've got XE/SQL Developer installed on my own computer - I wrote those sample functions using them - I just wasn't sure how to call/return anonymous blocks as both you and rp identified to develop at work as an interim solution.
Thanks a lot All,
TP. -
How can i get data from another database SQL Server use database link from
I have a database link from Oracle connect to SQL Server database with user cdit connect default database NorthWind.How can I get data from another database(this database in this SQL Server use this database link)?
hi,
u should see following documentation:
Oracle9i Heterogeneous Connectivity Administrator's Guide
Release 1 (9.0.1)
Part Number A88789_01
in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
regards
umar -
Unable to retreive the return value of pl/sql function using DB Adapter
Dear Experts,
I am using DB Adapter in my BPEL Process. Using DB Adapter I am invoking a PL / SQL function. I am able to send two input parameters for the pl/sql function. But I dont know how to retrieve the return value from the function. Please suggest me.
Thanks,
RajeshYes I am returning a value from PL/SQL function.
Please see the code segments below,
FUNCTION "TD_INSERT" (a TDINIT_TYPE, stops TDDETAIL_TABLE )
RETURN VARCHAR2
AS
td_no Number;
td_id Number;
stop TDDETAILFULL_TYPE;
length number;
BEGIN
insert into TD_INIT values( ----passing all the values here --------- );
select max(tdno) into td_no from TD_INIT ;
length := stops.count;
for i in 1.. length loop
stop := stops(i);
insert into TD_DETAIL_FULL values(
td_no, ------- );
end loop;
commit;
RETURN td_no;
END;
Thanks,
Rajesh -
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 call a specific page without using a link
Hi there ,
I am using Jdeveloper Studio Edition Version 11.1.1.1.0 , ADF BC.
Here is the question: I’d like to find a way to call a page using a text input as an alternative way to use the menu hierarchy.
That is, On the main page I have a text Input; assuming that each page is assigned to a specific code the following would be the scenario:
The user enters the code in the text Input and after form submission, the prospective page would be appeared.
Best Regards,
Yasaman Parandian
P.S: Regarding security issues; I am so looking for a solution in which JHS_ tables are used.Yasaman,
Your question is not related to JHeadstart but requires general ADF Faces and ADF Taskflow skills.
Please use the JDeveloper forum for your question. Once, you got it to work by manually changing a generated page, this forum can help you with using custom templates to keep your page generatable.
Steven Davelaar,
JHeadstart team. -
Can window and aggregate SQL functions used in Pro*C embedded SQL?
It appears that the window functions such as dense_rank() over(partition by ... order by ...) are not available in Pro*C embedded SQL. Can somebody please confirm that that is really the case?
Thanks
Rawender GuronPlease refer to this thread: "Is this forum also used for Pro*'C Questions? "
Is this forum also used for Pro*'C Questions? -
PL/SQL function: using parameter of type PL/SQL record?
Hi,
Is it possible to call the following function from within c#:
CREATE FUNCTION myfunc (par1 table%ROWTYPE) RETURN <sometype>
IS ...
Can ODP.Net handle rowtype records? I have found no hints in the manuals.
thanks,
stephanHello Stephan,
Can ODP.Net handle rowtype records?ODP does not currently support %rowtype (or object) types.
PLSQLAssociativeArray is the only supported collection type at this time.
- Mark -
How to call a servlets specific function from a link?
hi all ! Im trying to call a function callled A from a link in my JSP. Im not using any buttons. How do I make this work?
Thanks in advance.Hi,
A solution to call A might include a custom JSP element. Inside the code for the
element, you can get a reference to whatever object that "does an A", and make a call on the respective method/function/behavior. You need to extend the standard tag handler classes.
Good luck! -
Encore CS5 hangs when called by Premiere Pro CS5 using Dynamic Link
Need help from folks,
Have done so far:
1. unistall CS5 package , reinstall CS5 package Production Premium. Reinstall all updates. Still get the problem.
2. Problem seems to be pop-up screen do not accept any 'click' to input answer to Encore CS5
3. Premiere Pro CS5 working fine
Please help.
TTThanks again pointing out the Adobe CC Cleaner URL
When I said CCleaner previously, I was refering to a program that clean out garbages from PC (broken links, shortcuts, temp files, etcetera..)
But late on, I have found out Adobe CC Cleaner (for Creative Cloud and CS5, CS6...) for cleaning Adobe craps after un-install.
I just wish the hotline could mention it and not having me to swim to find out that tool does exists saving some precious time.
Here is the status and what I have done to fix the problem:
...yeah, I was shooting in the dark...
1. Uninstall completely Adobe Premiere Production CS5 (remove preferences)
2. Run Adobe CCleaner (choose "all")
3. Shutdown PC, reboot and Cleanup and Defragment C: drive
4. Re-install completely Adobe Premiere Production CS5 (all products)
5. Re-apply completely Adobe Premiere Production CS5 (all products)
(note: for some reason, I need to do it three times to get the complete updates done, just retry and no changes between retry)
6. Result : PremierePro still working fine, still hangs on Encore
(Encore dialog screen was frozen as before from the begining and I had to use "Window-Task-Manager" to "end-the-task" of Encore)
7.Conclusion: the problem is on the PC not AdobePremiereProduction
8. Decision: Restore previous checkpoint of Window-7 Professional components
9. Redone steps 1,2,3,4,5
10. The result is the same as mentioned in point 6 and the conclusion is the same as mentioned in point 7.
11. Ultimate Decision: Ground-zero style resfresh (see the follwoing steps)
12. Separate Data from Window-7 (Move out all data from PC and unplug all connected portable hard drives
13. Factory restore of Window-7 Professional using DVD-rescue (hard drive C: wiped out and reformatted)
14. Apply all Updates for Window-7 Professional (over 121 updates, over 700Mb and many shutdown-reboot)
15. Reconfigure Wireless for connecting to Internet
16. Re-Install McAfee Antivirus
17. Re-Install some usefull Softwares (Microsoft Office 2010 Professional, etcetera... Shareport for wireless USB Printer)
18. Lot of Canon and Sony Softwares not re-installed because not used and not needed for now
19. Clean install AdobePremiereProduction CS5 (no need to run Adobe CCleaner)
20. Apply all updates for AdobePremierProduction CS5 (result is intermittent and have to retry few times to get it completed)
21. Apply one by one updates for every single Adobe product to get it done\
22. Shutdown and cleanup C: drive and defragment C; drive
22. From now on, I am sure to have a FRESH an CLEAN PC with a CLEAN CS5
23. RESULT: AdobePremierePro-CS5 still working perfectly AS BEFORE
24. RESULT: AdobeEncore-CS5 standalone do not hang ANY MORE
but get error on MICROSOFT VISUAL C++ ? (with no details and some question marks) new
24. Get message saying QUICKTIME not installed (with warning)
25. Okay, install QUICKTIME from Apple to please CS5
26. Shutdown PC, reboot PC just to be sure everything kick in properly
27. RESULT: same as in point 24 (get error on MICROSOFT VISUAL C++ ? (with no details and some question marks)
28. It's SHOOT in the DARK, ON MORE TIME, BABY
29. Focusing on MicroSoft Visual C++ component: Comparing Installed products between my OLD PC and the freshly factory restored one
30. The old PC has Microsoft Visual C++ 2005,2008 and 2010 (both x64 and x86)
31. the new PC only has Microsoft Visual C++ 2008,2010 (both x64 and x86)
32. Decision : Install Microsoft Visual C++ 2005 (both x64 and x86) (trying to have same softwares on both PC)
33. Reboot PC after install
34. AMAZING RESULT: Adobe-Encore-CS5 is functionning OKAY
35. Testing time: I created a very small project in AdobePremierePro-CS5 and I was able to DynamicLink to Encore-CS5 and I was able to create on disk a DVD
and I was able to play that DVD
36. DID I DO ALL THOSE STEPS FOR NOTHING, WHY IT WAS SO COMPLICATED,
I WILL TEST IT AGAIN WITH MY BIG PROJECT (76 Ggis and 1 hour 18 minutes Blu-Ray) sometimes this week
I SPENT TOO MUCH TIME TROUBLESHOOTING AND I AM LOOSING MY CREATIVITY (....LOL...)
BELIEVE ME, I AM EXHAUSTED AND NEED SOME REST.
37. The End -
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 LocusHi,
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 -
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
------------------------------------------------------------------- -
Can we call sql function in java
as i know i can call stored procedures ,but can i call pl/sql functions.
Using JDBC you can execute any valid sql statement.
For a pl/sql function you use a CallableStatement and the syntax:
{?= call <procedure-name>[<arg1>,<arg2>, ...]}
http://java.sun.com/j2se/1.5.0/docs/api/java/sql/CallableStatement.html -
Show a report region only when link in other report is clicked
Hi Friends,
I am having 2 report regions.In my first report region i am having a column as a link. I want to show the 2nd report
region only when the link in the 1st report region is clicked. There is a button in the 2nd report region i want to show
that button only when the link in the first report is clicked.
The code for my first report is
select * from tasks;i have a link column task_id as
f?p=&APP_ID.:10:&SESSION.::&DEBUG.::P10_TASK_ID:#TASK_ID#My 2nd report code is
select * from task_details where task_id=:P10_TASK_ID;Plz help,
Thanks,
TJHi Andy,
I tried this but having one problem. When i press a link the vaule of P10_TASK_ID is set and the 2nd report is shown.
When i go to other page and come back to this page the 2nd report is showing even with out pressing the link this is
because the value set for :P10_TASK_ID is still there. Where can i put the value back to null so that the 2nd report is
not shown with our pressing the link in the 1st one.
Thanks
TJ
Maybe you are looking for
-
Each time I want to add more pictures to my library, it deletes all existing and re-loads (during syncing). I always use the same computer, never plugged my ipad into any other computer. I also get error messages sometimes when I am trying to downl
-
Hello together, I've a problem with some songs in my playlists on my new ipod touch. The error message says that the replay of the song isn't possible because the song isn't available or through DRM is restricted. All the songs are buyed in the iTune
-
Working with entitlements with OIM 9.1.0.2
Hi all, My customer want to use entitlements within OIM 9.1.0.2 In the tools reference (chapter 14) explain this in a some cryptic way. My questions are: Manual says that available entitelements are syncronized on LKV from target, how is this sync co
-
I was installing Leopard to my Mac Mini and iPhoto etc. was ok, but iWeb was off. Why?? My iLife (was coming also, when I by Mini) is 6. Even I doesn't need iWeb very much I'd like it to be in my Mini.
-
Hi experts, I m new to SRM5.0. Can any one explain me abt EBP-SUS integration? Wt is the need of this integration? wt r the prerequisites to this? I m using EBP4.0 and SRM5.0. Kindly help me on this. Regards Raaams.