Substitution Syntax in PL/SQL Process
Hey all, I've got a good one for you. I used to be able to do the following in a pl/sql page process.
declare
l_vc_arr2 HTMLDB_APPLICATION_GLOBAL.VC_ARR2;
begin
SELECT ca.account_number BULK COLLECT INTO l_vc_arr2
FROM hz_cust_accounts ca,
hphc_enrollment_detail ed
WHERE ca.cust_account_id = ed.cust_account_id
and ed.enrollment_detail_id in (&P8005_ED_ID_STRING.) -- <= ***************
AND ROWNUM < 1000;
:P8005_ACCOUNT_NUMBER_STRING := HTMLDB_UTIL.TABLE_TO_STRING(l_vc_arr2,',');
exception when others then
:P8005_ACCOUNT_NUMBER_STRING := 0;
end;
It upgraded fine and continues to run fine, but I can' make changes to it and I can't do this again. This is an easy way to create an in clause. Any suggestions on what I should do?
Thanks,
Anton
I wouldn't call Tom's str2tbl technique a "cumbersome workaround". It is a very elegant technique that does the job wonderfully and comes in handy in many situations.
Here is a quick working example
http://htmldb.oracle.com/pls/otn/f?p=24317:210
The SQL query for the report is
select * from emp
where (:P210_EMPNOS is null
or empno in (select *
from table(str2tbl(cast(:P210_EMPNOS as varchar2(1000))))))The source for the SQL types and function is
CREATE OR REPLACE TYPE "MYTABLETYPE" as table of number
create or replace function str2tbl( p_str in varchar2 )
return myTableType
as
l_str long default p_str || ',';
l_n number;
l_data myTableType := myTabletype();
begin
loop
l_n := instr( l_str, ',' );
exit when (nvl(l_n,0) = 0);
l_data.extend;
l_data( l_data.count ) := ltrim(rtrim(substr(l_str,1,l_n-1)));
l_str := substr( l_str, l_n+1 );
end loop;
return l_data;
end;
/Thanks
Similar Messages
-
#FLOW_OWNER# in pl/sql process
I am trying to use #FLOW_OWNER# substitution string in pl/sql processes so I dont have to hard code the schema name. This substitution string works fine if I use it in a report for example 'select * from #FLOW_OWNER#.APEX_APPLICATION_PAGE_IR_COL'
However if I use it an insert in pl/sql process, I get the following error.
ORA-06550: line 5, column 2: PL/SQL: ORA-00911: invalid character ORA-06550:
Here is the code
insert into ssm_help(application_id,application_item_id,help_item,help_desc,help_type_id)
(select :P11_APPLICATION_ID, :P11_APPLICATION_ITEM_ID, report_label,'Enter Help',(select help_type_id from ssm_help_type where help_type_code='REPORT_COLUMN')
FROM
#FLOW_OWNER# .APEX_APPLICATION_PAGE_IR_COL;
Any ideas what the problem is ? Thanks.Hi,
I once used the global substitution variable APEX_APPLICATION.G_FLOW_SCHEMA_OWNER, but I had to encapsulate the query in an EXECUTE IMMEDIATE block.
Here's my example:
DECLARE
l_flows_owner VARCHAR2(32);
l_query VARCHAR2(2000);
l_count NUMBER(10,0);
BEGIN
l_flows_owner:=APEX_APPLICATION.G_FLOW_SCHEMA_OWNER;
l_query:='SELECT COUNT(DISTINCT APPLICATION_ID)
FROM '||l_flows_owner||'.APEX_APPLICATIONS';
EXECUTE IMMEDIATE l_query INTO l_count;
RETURN l_count;
END;This will work in your case too.
-Udo -
Problem setting a hidden item value when button clicked with dynamic action or pl/sql process
Apex 4.1
Oracle 11g
I have a page that consists of a main region and several sub regions. I have a pl/sql process in After Header SET_DISPLAY(:P400_DISPLAY :='MAIN';)
Three subregions have a contional display where P400_DISPLAY = STORE. This works in hiding the sub regions.
Now I want to change the P400_DISPLAY value to STORE to show the subregions when I hit a button.
I tried creating a dynamic action for on click of the add button but get the following error:
The selected button uses a 'Button Template' that does not contain the #BUTTON_ID# substitution string
I went to the templates and found:
Substitution Strings
Substitution strings are used within sub templates to reference component values. This report details substitution string usage for this template.
Substitution String
Referenced
From
Description
#LINK#
Yes
Template
To be used in an "href" attribute
#JAVASCRIPT#
No
To be used in an "onclick" attribute
#LABEL#
Yes
Template
Button Label
#BUTTON_ATTRIBUTES#
No
Button Attributes
#BUTTON_ID#
No
Generated button ID will be either the button's Static ID if defined, or if not will be an internally generated ID in the format 'B' || [Internal Button ID]
I then tried creating a page process, pl/sql, :P400_DISPLAY :='STORE'; when the appropriate button is pressed. The button action is submit page. However, it does not change the P400_DISPLAY value and the subregions stay hidden.
Suggestions please on how to fix the template or change the P400_DISPLAY value?The root issue is that, although you change the value of your page item, it isn't visible to other areas of the page until it is in the session. So, any other action based on the value of your page item; the visibility of a control, a report based on the item's value, etc. will all be unaffected by changing the value of the page item until it has been changed in the session. Even after this the items are stored in the session, you must thereafter do something to cause the value to be reevaluated. To see the effect of this, observe that your page loads and evaluates the value of your page item, it sees that is "MAIN" and hides the regions. However, it doesn't reevaluate them after this.
So; your choices to get this value set in the session are to either Submit the page, or use JavaScript to set the value in the session. If you use the latter of these, you'll have to do some further work to cause the visibility tests to be re-run, So, let's stick with with the submit method.
What you've done above sounds correct for this but, there are a lot of decisions you could have made that might have caused things not to happen in the correct sequence.
Firstly, let's confirm that what I describe above is your problem. From the development environment, load the page, click the button to change the value and submit. Now, click the link labelled Session. Is it still set to MAIN? If so; this is your issue.
Let's start with the your After Header computation. Did you set it to *only* run if the current value of your page item is NULL??? If not, that's your problem.
Load Page -> Item set to 'Main' by Computation -> Click Button -> Item set to STORE -> Submit -> Load Page -> Item set to 'Main' by Computation
See the problem?
Assuming this isn't the issue, you created a Branch to the same page, right? What is your process point for the Branch? Is it *After* Validation, Computation etc? Because if not, you aren't changing the value before the submit happens.
I bet it is the first issue but, take a look at these.
Cheers,
-Joe -
Apex: output message from pl/sql process
Apex 4.2
THis is kind of an Apex and Pl/Sql question, but more so Apex because I'm using that environment. I have a pl/sql process with an IF - Else statement. It's a real simple process where you check:
IF P101_Count > 1 Then
Do stuff;
Else
Output an error message.
The process runs when I click a button.
I am just not sure how to get an error message to display to the screen. I am not sure of the syntax.
Any help on this topic would be greatly appreciated. Thanks in advance.Well, there a lots of ways to do this but, if you just want to see it on the screen, the easiest way is to add a Page Item (a Text Field for example). Then, in the Else portion just set it equal to the message that you are trying to display.
If ( :P101_Count > 1 ) Then
-- Do Stuff
Else
:P1_MY_MESSAGE := 'Hello World!';
End If;
-Joe -
Hello All,
I am creating my first PL/SQL Process in APEX and I am having some issues. The Code is as follows:
DECLARE
a INT;
BEGIN
Select ON_TRACK_NUM INTO a from TBL_CMR_TRIAL Where PK_TRIAL = 2;
IF a=1 THEN UPDATE TBL_CMR_PROJECT
SET ON_TRACK = 'Yes'
WHERE PK_PROJECT = :P4_FK1_PROJECT;
ELSEIF a=0 THEN UPDATE TBL_CMR_PROJECT
SET ON_TRACK = 'No'
WHERE PK_PROJECT = :P4_FK1_PROJECT;
END IF;
END;
I have larger plans for this code but this is the first step where I have hard coded in the number 2. Pretty much it is supposed to look at the ON_TRACK_NUM field for this particular row and if it is 1 change another field in another table to Yes or if 0 then No.
The errors I am getting are:
1 error has occurred
ORA-06550: line 12, column 8: PLS-00103: Encountered the symbol "A" when expecting one of the following: := . ( @ % ; ORA-06550: line 17, column 4: PLS-00103: Encountered the symbol ";" when expecting one of the following: if
I feel like I am probably really close to getting this right but I have some small syntax wrong. Could anyone please take a look and give a hand? Thanks.You can't use a as a variable name. Try a_num.
DECLARE
a_num int;
BEGIN
Select ON_TRACK_NUM
INTO a_num
from TBL_CMR_TRIAL
where PK_TRIAL = 2; -
Export to excel the output of a pl/sql process
Hi,
I have a pl/sql process on load of a page.
The code uses html tags like HTP.P('<TABLE BORDER="0" CELLSPACING="0">');
HTP.P('<TR>'); HTP.P('<TD COLSPAN="6">');
HTP.P('Title'); HTP.P('</TD>');
HTP.P('</TR>'); HTP.P('</TABLE>');
and several loops to display the names of employees in seven rows and three colums.Is it possible to export this data to excel/.csv format?
Thanks in advance...
AnuYou could also take the example from my blob that Denes mentioned and instrument it to output in either CSV or HTML. This way, you could have a single procedure that worked for both formats.
All you would need to do is handle each field differently - pad a TD and /TD (with proper brackets, of course) if its HTML or just append a comma if it's CSV.
Thanks,
– Scott –
http://spendolini.blogspot.com/
http://sumnertech.com/ -
Alert/Warning messages from PL/SQL process
Hi all,
I have a PL/SQL process that I execute from javascript : doSubmit(MY_PROCESS). I want to output an alert box if some errors occurs in the process, for instance : alert('message'). Does anyone know how to do that ?
Best regards,
Othman.Thanks Andy for the reply.
My process executes "after submit", so I cannot call directly the javascript as one mentioned. The call to "html_Get" seems to be quite complicated for a simple alert message which is not really a Application process shared component.
So I'll go for a solution where users won't see error messages ...
Best regards,
Othman. -
Calling JS function in pl/sql process
Hello!
I have a js function defined in 'HTML Header' :
<script language="JavaScript" type="text/javascript">
function disp_alert()
alert("Data is invalid! Correct the data and click CONFIRM again.")
</script>
I also have a pl/sql process on this page. I want to call disp_alert function in a following way:
if ... then call function
else dbms_output.put_line('...');
end if;
How can I call this js function in 'if'??
TomThere ARE ways to accomplish something like this, but they're much more complex.
You must create a JavaScript that uses APEX's built in AJAX components; a form button will call the JavaScript, which will in turn call a PL/SQL procedure saved as an "On Demance Shared Application Process." This procedure can run any checks you like against the DB, and return data to the Javascript to display in an alert.
You can see an example of this in use at an APEX page I created: http://htmldb.oracle.com/pls/otn/f?p=19864:5
This isn't the same thing, but is accomplishing what it does through an APEX form, a javascript call on the text field to a PL/SQL Process that returns rows from the database dynamically...thus allowing the client side JavaScript to call server side PL/SQL. -
PL/SQL process and popup URL
Hi,
I have a PL/SQL process which is called on submit but a button. This Pl/SQL creates a file on the web-server and I then want to open this file in a new browser window using the URL path to it. Can this be done from pl/sql or do I need to embed some javascript somewhere in the page. My eg block is :-
begin
pack.proc(15);
owa_util.mime_header('application/vnd.ms-word');
htp.init ;
owa_util.redirect_url('http://server:port/my_dir/myfile.doc');
end;
The redirect doesnt do anything.
Thanks for any assistance,
BrandonHi Teku,
You just have a look at this thread, where u can find a solution for your problem.
INSERTING Records into Second table based on First table Primary Key
hope this helps.
Bye,
Srikavi -
Before header pl/sql process creates blank space at top of page
Hi,
I'm finding that w/v 1.6.1 I get a blank space at the top of my page that appears to be somewhat proportional to the amount of code and/or # processes on that page that are before header. moving to after header and before regions also shows this behavior.
There are no blank line outputs happening in the pl/sql processes, so I've got no idea why htmldb is putting blank space there.
Anyone seen anything like this? Oracle 9.2.0.7, winxp pro
Thanks
mattHi,
I've had the same problem. I'm assuming that you have a region in the "After Header" position?
If so, you could add the following in the region's Region Header:
<div style="display:none">
and put this in the Region Footer:
</div>
The region is defined in a table, which by definition is a block object. Block objects always begin on a new line and end with a new line - the above will put the region into a div and then hide the div.
Regards
Andy -
Hello,
We wanted to develop a parametrable SQL filter that can make comparison, sorting and updating operations with our RDBMS (Sybase SQL Server 11.9.2.3 connected to Websphere Application Server 3.5.4).
Since a generic item (it's a product) of our RDMS contains 400 attributes and that we have approximatively 70000 items in our database, performance is quite important for us !
A typical operation of our software is to compare one product (and his 400 attributes one by one in a discriminate order) for filtering purpose.
So we got several architecture alternatives :
- Stay in the Java world and load all needed objects in memory (using for exemple a relationnal/object mapping framework like Castor) and then compare them... but it's too bad in term of performance !
- Delocalize compare methods in the SQL world by using JDBC Query or JDBC call to stored procedure...
Does anybody known the best way to deal with this sort of heavy SQL process in the Java World ?
All samples, documentations, filtering or compare algorithms are welcome !
Thanks a lot
Ghislain SillaumeIf you mean that the Java/CASTOR option would be to pull in a large number of the products into memory, map them into object to do a comparison, then that would be unwise at best. If you only need to pull in a few of the products, that may be sufficiently fast (as fast or faster than doing it in the DB.
It seems to me that a technique based on writing stored procedures to do your comparisons would be your best bet, assuming that a few sufficiently paramaterized stored procs would suffice. This, coupled with adequate indexes and well design queries should perform quite well. If you need to then pull the product definitions into a Java program, you can use an OR mapper or hand coding to do it quite easily once you figured out what the results should be...
Chuck -
Dynamic SQL in PL/SQL process
Hi all,
I just found out Dynamic SQL doesn't work in PL/SQL process.
working example using SQL:
declare
retval number;
begin
select count(*) into retval from emp;
:P1_EMP_COUNT := retval;
end;
NOT working example using dynamic SQL:
declare
retval number;
l_sql varchar2(4000);
begin
l_sql := 'select count(*) into retval from emp';
execute immediate l_sql;
:P1_EMP_COUNT := retval;
end;
What have I done wrong? Could anyone please help?? :)
ChrisHi Jarola,
Actually, your version works just as well. I had a typo in my code so I got a typo... Thank you very much. Now I got 2 version of codes that works... Sorry about the fact the Since I mark the other suggestion as "Correct", I can only mark your post as "Helpful" but yours is actually "Correct" just as well... How can I somehow get you the credit you deserved? Please let me know, Okay? Thanks again...
Chris :) -
Javascript in pl/sql process block
Hi,
Can someone please tell me why this code is not working.....
I have put this in my pl/sql process....
htp.p('<script language=javascript>');
htp.p('var r=confirm("This is a duplicate record , do you want to proceed?");');
htp.p('if (r==true)');
htp.p('{document.wwv_flow.submit();}');
htp.p('else{ }');
htp.p('</script>');
Please help
thanks and regards,
deepaWhat you need, in your case, is the reverse approach
– calling PL/SQL from JavaScript code – which is
possible, using AJAX...
It seems like what you are trying to do is a
validation process. Pressing the button should fire a
JavaScript code, which in turn will fire an on-demand
PL/SQL procedure, and according to the returned
results will display a confirm dialog boxHi Arie,
This is exactly what I am struggling to do, but I don't think is working...is there a good example somewhere, with good documentation saying what goes where? I've tried looking at Carl's On-Demand page example and I just can't tell if I'm following it correctly.
Based on what is entered in P4_PROJECT_NUM, I need to verify that the value isn't already in the database when the user tabs out of the field.
My javascript for page 4 (in HTML Header):
function checkCO()
var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=validate_value',4);
get.add('ID', $x('P4_PROJECT_NUM').value)
gReturn = get.get();
if(gReturn) // if function return true
alert($x('P4_PROJECT_NUM').value + ' already exists in database.');
get = null;
//-->
</script>
My onDemand process, from the Application Processes:
declare
v_count number;
cursor cr_check_co is
select count(*)
from usd_changeorders
where chg_ref_num = v('ID');
begin
open cr_check_co;
fetch cr_check_co into v_count;
close cr_check_co;
if (nvl(v_count, 0) = 0) then
return true;
else
return false;
end if;
end;
I am calling the javascript from the onBlur event of the field I want verified.
I am getting an alert, but it is displaying every time, whether the value is valid or not.
Can you tell me what I am doing wrong?
Thanks!!
Janel -
PL/SQL process returning message with more than 4000 chars
In our apex application we are using a pl/sql process returning a message.
This message should be shown to the user.
Our problem is now, that the application items in APEX seem to be limited to 4000 chars and the message can be longer.
We are also not able to use a collection, because we can't print the content of a collection in the "Process Success Message".
Here is the content of a page process which is running on page load after header:
Name - Type: PL/SQL anonymous block
Source - Process: :AI_TEST := p0001_pkg.get_text;
Messages - Process Success Message: &AI_TEST.
Image from process [https://twitter.com/OliverLemm/status/324058809138032640/photo/1/large]
If the page is called the result is this error message:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Technical Info (only visible for developers)
is_internal_error: false
ora_sqlcode: -6502
ora_sqlerrm: ORA-06502: PL/SQL: numeric or value error: character string buffer too small
component.type: APEX_APPLICATION_PAGE_PROCESS
component.id: 16433072916569237418
component.name: get_text
error_backtrace:
ORA-06512: at "APEX_040200.WWV_FLOW_PROCESS", line 100
ORA-06512: at "APEX_040200.WWV_FLOW_PROCESS", line 141
Edited by: Oliver L on 16.04.2013 09:17no an item like P0_TEST on page 0 / global page also does not help.
But the error is not the application item / page item it's the problem that the "Process Success Message" can't handle more than 4000 chars.
I tried to paste a string into the process success message, but the error "Error processing row. ORA-01461: can bind a LONG value only for insert into a LONG column" occured even when i filled the textarea and saved the process.
So there's no problem with the application item or page item.
Edited by: Oliver L on 16.04.2013 10:00 -
How to display confirm message in APEX pl/sql process
I have a pl/sql process that selects success messages from a database table. These messages need to be displayed to the user and confirmed (only one button, to acknowledge/dismiss the mssage) along the way.
Is there a way to do this within the process? I see lots of examples in the Forum of doing this in javascript (which I know very little about) but suspect there must be a simple way to do this in my pl/sql process.
Help?
Thanks,
CarolHi Carol,
You can put you success messages inside page items or application items (when pages are rendered or processed...).
Then using :
1) javascript can display these values
2) rendering the page can display these values
Hope this help
Louis-Guillaume
Homepage : http://www.insum.ca
InSum Solutions' blog : http://insum-apex.blogspot.com
Maybe you are looking for
-
"Error in the alert log file " - please help
Hi ALL, I am getting following errors in the alert log frequently. My database version is: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi PL/SQL Release 10.2.0.1.0 - Production CORE 10.2.0.1.0 Production TNS for IBM/AIX RISC System/
-
Hey all, I'm a fairly new Arch user, and to be honest, a fairly new Linux user in general. Over the years I tried so many times to make the transition from Windows to Linux and after finding Arch, I felt it was finally time, but I digress... I now ru
-
Date Utility - calc age, elapsed time...
I need to calculate elapsed time between 2 dates, for example calc age based on DOB and Today. There must be a utility out there somewhere (free!). I'm sure I'm not the first one with this requirement.
-
Hi All I am doing a Journal Entry Procedure so that only specific users can process all accounts and the rest can only process to specific accounts. And i do not want to have these accounts as 'Confidential' as i need the users to process the account
-
I have a G4 15" iBook witrh an Airport Exteme internal card. 1 GB memory For the past month or so I have had wireless connectivity problems. I know lots of people have:-( Mine manifests itself with no recognition of the existance of the internal airp