Setting page items from Stored Procedure/Package
Hi,
Can anyone tell me if it is possible to set the values of page items from stored pl/sql code. I have some reasonably complex biz logic that I want to package and store in the database (not just call an anonymous pl/sql block through a page process). However within that stored code I want to set items on my page based on input parameters, other items on the page or calculations eg.
I want to do something like:
:P6_INT_ACC_START_DT := p_bony_auction_dt + 1;
when trying to compile this code I get invalid bind variable error
I also tried:
V('P6_INT_ACC_START_DT') := p_bony_auction_dt + 1;
but got invalid use of V function error
Any ideas?
Thanks, Robert
Call apex_util.set_session_state:
apex_util.set_session_state(p_name => 'P6_INT_ACC_START_DT', p_value => p_bony_auction_dt + 1);
...although be aware of date-to-varchar2 conversion and use date format masks explicitly.
Scott
Similar Messages
-
Set page item from a stored procedure
Dear reader
We would like to have a stored procedure to run every 10 minutes. When the procedure starts, the user has to be warned that the update process is running.
When the procedure is finished, the user should receive a message that the update process is finished.
What I had in mind was to set a Page 0 item 'P0_REFRESH' and set his value depending on the status of the update. Then add a dynamic action with a change event. So everytime the value of this page item changes, the user will receive a correct message.
Does anyone know if it is possible to set a page item from a stored procedure?
Kind regards
XnniAndyPol
I found a solution by querying the user_jobs table. In Apex, I created two page 0 items that hold the current status of the job (online, offline) and the old value of the job.
Online of offline in the current status item is determined by a decode on "this_sec".
The enext step was to include a html region in P0 that contains some javascript. This javascript will display a message when the values of the new status is different from the old status ;)
Many thanks for bringing up the ideas.
Greetz
Xnni -
Setting Page Items from SQL Query
Hi, </br></br>
I am using "SQL Query (PL/SQL function body returning SQL query)" for a report. In the body of the sql query, after calling a function, I have the following statement: </br></br>
APEX_UTIL.SET_SESSION_STATE( p_name => 'P13_MESSAGE', p_value => 'Contact Tech Support' ); </br></br>
and I find that I cannot save the query. I get an error message: </br></br>
<b>Unexpected error, unable to find item name at application or page level.
ERR-1002 Unable to find item ID for item "P13_MESSAGE" in application "4000". </b>
</br></br>
I do have the field 'P13_MESSAGE' on my page. </br></br>
Can't this API call be used within such a query type? Is there an alternative to this? </br></br>
Thanks in advance </br></br>
VasanScott,</br></br>
I have given the source of the region, below. Its type is 'SQL Query (PL/SQL Function body Returning SQL Query'). </br></br>
"Get_State_Hit" is a procedure in a package. I have not shown the name of the package here.</br></br>
Please give me your suggestion. </br></br> Thanks </br></br> Vasan </br></br>
========= </br></br>
DECLARE </br>
l_sql varchar2(100); </br>
BEGIN <br>
IF(:P13_MATCH_TYPE = 'ALL') THEN</br>
Get_State_Hit ( one set of values from user-interface );</br>
apex_util.set_session_state( p_name => 'P13_MESSAGE', p_value => ' MsgString 1' );</br>
ELSE</br>
Get_State_Hit ( another set of values from user-interface );</br>
apex_util.set_session_state( p_name => 'P13_MESSAGE', p_value => ' MsgString 2' );</br>
END IF; </br>
l_sql := 'Select Col 1, Col 2, ..., Col 9 from ABC_Vw'; </br>
RETURN l_sql;</br>
EXCEPTION</br>
WHEN OTHERS THEN</br>
l_sql := 'Select * from Default_Vw' ;</br>
apex_util.set_session_state(p_name => 'P13_MESSAGE', p_value => 'Contact Tech Support');</br>
RETURN l_sql; </br>
END;</br></br>
==========</br></br>
Message was edited by:
Vasan -
Setting Page Item from Hyperlink
Hi,
I am currently developing an APEX application that will show a Google map of our kiosk locations. It builds the javascript in a PL/SQL package using htp.print. For each marker it displays for the kiosk, I'm customizing the info window displayed when the marker is clicked to show the kiosk name, the address and some hyperlinks. One of these hyperlinks will go to another APEX page that displays orders for that kiosk. So, what I'm trying to accomplish is to set a page item value on the page when the hyperlink is clicked that will be used in a page query to pull the orders. I am not much of a javascript programmer, so I'm having some issues. Here is what i'm currently attempting:
Withiin the FOR loop that builds my markers, I have defined a 'function' as follows:
htp.print('function setKioskCode (P4_KIOSK_CODE) {');
htp.print('var kioskcode = '||''''||<location from cursor loop>||''''||';');
htp.print('$x('||''''||'P4_KIOSK_CODE'||''''||').value = kioskcode;');
htp.print('}');Then, this is how I'm building the hyperlink in the info window (i've removed the link tags and single quotes so I could post the code). Using this method, I get an error on the load of the map page that says ' Expected ")" '. I can't find any syntax errors in what i have done from what I can tell (I could definitely be wrong!).
l_order_link := href="f?p='||v('APP_ID')||':6:'||v('SESSION')||'" onclick="javascript:setKioskCode('||''''||'P4_KIOSK_CODE'||''''||');">OrdersWhen I remove the parameter value from the javascript call like this. It loads the map successfully, but, of course, the hyperlink on the marker info window doesn't work.
l_order_link := href="f?p='||v('APP_ID')||':6:'||v('SESSION')||'" onclick="javascript:setKioskCode();">OrdersAny help would be much appreciated. And please let me know if you need any further info.
Thanks,
Troy
Edited by: tfitz on Oct 21, 2010 1:53 PMThanks for the reply, Jari.
I have determined you definitely have to use the v('APP_ID') and v('SESSION') in the href statement. Otherwise, it puts the &APP_ID. and &APP_SESSION. in the URL.
I tried the 'onclick' syntax you provided and it still does not work. I get the error I reported above. It's looking for the closing parenthesis and doesn't like a parameter being provided. If i remove the parameter from the function, the page loads and the hyperlink goes to the proper page but it doesn't populate the page item. I don't know why it doesn't like a parameter for the function.
Thanks, Troy. -
Problem with execute SSIS package from stored procedure
Hi,
I would like to execute SSIS package from stored procedure. Therefore, I implemented sp which exec SSISDB.CATALOG.CREATE_EXECUTION method. When I try to test it from SSMS on remote server, I got error that
I was able to solve by adding “WITH EXECUTE AS …”. Then I got another error: The server principal "Domain\user" is not able to access the database "SSISDB" under the current security context. On Internet, I found a couple post that describe
how to access SSIS catalog (one of them by Ke Yang -
http://blogs.msdn.com/b/mattm/archive/2012/03/20/ssis-catalog-access-control-tips.aspx). It didn’t help. I’m still getting the error message.
How to debug this issue?
Any suggestion?
Thanks
SQL Server 2014 BISSMS does not propagate user credentials thus the error
Arthur
MyBlog
Twitter -
Calling DTS package from Stored Procedure
I am getting error calling DTS package from CF.
So i want to call DTS package from SQL Server Stored
Procedure.
DTS package create text file. So no need of input or output
parameter.
What is the syntax?.
thanks for ur help.Ted Kruger explains how this can be done in his blog post
Run SSIS Package from Stored Procedure
For every expert, there is an equal and opposite expert. - Becker's Law
My blog -
How to generate a report from stored procedure
I would like to generate a report from stored procedure.
I used to work on sql server. this can be done as easy as put a select statement at the end of stored procedure.
The resule can be displayed on the development IDE, like sql developer or consume by Java JDBC client.
is there equivalent way to do this in Oracle stored procedure?Hi,
What type of report you are looking..for.. ??
As you said that "I used to work on sql server. this can be done as easy as put a select statement at the end of stored procedure. "
When you execute it will return the result set and you will display directly on the FrontEnd.. Is my Understanding is correct Up to here.
See, In oracle you have call some custom stored procedures as you did in SQL Sever, but you have return the Results Sets, with help of Out put paramter, Either Cursors or Varrays..
or Else you can generate the Html reports based on your requirement, HTML can be used in the stored procedures of Oracle which will generate for your, you need to code it.
I could not able get the relevant link for your reference.
I will get back to you on this.
- Pavan Kumar N -
Best method to transfer large strings (XML data) to/from stored procedure
Hi!
I'm trying to call a PL/SQL procedure from Java. The procedure inputs a string (XML) that is parsed, and returns a result string (also XML).
Typical size of the string is 5kb -> 1mb.
I can see two possible solutions:
1) String / LONG
2) CLOB (Using DMBS_LOB.createTemporary and getting a CLOB locator and passing the locator to the stored procedure)
Does anyone have other suggestions?
What is the fastest method for transferring XML structures from to and from stored procedures?
AndersAnders,
I would say it depends on your requirement. Both the methods have some advantages and disadvantages.
Using a CLOB means that you have to use vendor specific libraries but this is more extendible and I fast too.
Using String/Long will be more portable in the long run but again you lose on speed/performance.
Just a doubt of mine... If I got it correct, you are transforming one XML to another XML based on some conditions. Why dont you use XSL and XSL StyleSheet Processor packaged with XDK for this? I think this would be the fastest way.
Hope this helps. -
Access page item from Javascript
I have searched the forum, and based on my findings this is what I've done so far:
I have a page item where the Google Map key is stored. I want to access it from Javascript so that I can call the Google map with the key. (Note: The key can't be hardcoded as it will be pulled from DB according to the environment/url the app is running on. e.g. - dev, test, production.)
Here's a javascript code block:
<script>
var google_key = $x('P1_GOOGLE_KEY').value;
var l_url = "http://maps.google.com/maps?file=api&v=2&key=" +
google_key +
"&sensor=false";
</script>I have tried, $v('P1_GOOGLE_KEY') , $x('P1_GOOGLE_KEY') , &P1_GOOGLE_KEY. and none of them work.
How do I access a page item from Javascript?
Thx!
MarcMarc,
I am going to take a shot in the dark, but are you referencing this item outside of a function in your head tag? So basically it tries to reference the item on load? If so this is not going to work because the item does not exist yet. If you are using jQuery change your code to look like:
$(document).ready(function(){
var google_key = $x('P1_GOOGLE_KEY').value;
var l_url = "http://maps.google.com/maps?file=api&v=2&key=" +
google_key +
"&sensor=false";
});This will tell the javascript to fire after everything has fully loaded. If you are not using jQuery then you can use a little javascript snippet from here to add a ready event to your page. or you can copy paste this into a script tag.
(function () {
var ie = !!(window.attachEvent && !window.opera);
var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);
var fn = [];
var run = function () { for (var i = 0; i < fn.length; i++) fn(); };
var d = document;
d.ready = function (f) {
if (!ie && !wk && d.addEventListener)
return d.addEventListener('DOMContentLoaded', f, false);
if (fn.push(f) > 1) return;
if (ie)
(function () {
try { d.documentElement.doScroll('left'); run(); }
catch (err) { setTimeout(arguments.callee, 0); }
else if (wk)
var t = setInterval(function () {
if (/^(loaded|complete)$/.test(d.readyState))
clearInterval(t), run();
}, 0);
document.ready(function (){
var google_key = $x('P1_GOOGLE_KEY').value;
var l_url = "http://maps.google.com/maps?file=api&v=2&key=" +
google_key +
"&sensor=false";
Good Luck,
Tyson Jouglet -
Import only stored procedure packages
Hi,
I would like to import only stored procedure packages, procedures and functions (don't want
tables, views, etc.) from a dump file.
Can I do that?You can use exclude parameter of Datapump Import to exclude the tables and views.To know how to exclude tables this thread is helpful
http://forums.oracle.com/forums/thread.jspa?threadID=425226
And also for exclude and include this link is helpful
http://www.oracle-base.com/articles/10g/OracleDataPump10g.php -
URGENT : Return Bulk data from Stored Procedure
Hi,
Tell me, how do I return a bulk of data which
does not exist in the data base
but is concluded while the Stored Procedure is executed
from the Stored procedure
to the C++ program.
For Example:
Table ABC
Field1 Field2 Field3
A 1 3
B 1 5
C 2 10
Table DEF
Field1 Field2 Field3
D 10 24
E 3 16
F 8 19
SP_TESTING
Depending on the values in both the tables
for some range of conditions,
a conclusion X is derived for each range value of the
condition range.
Now I need to return this bulk of data X with the
condition they belong to
back to the C++ code calling it....
NOTE : A stored procedure is requited as there is a lot
of processing
required before we conclude the result X for each value
in the condition range.
If I execute this code from C++ instead of Stored
procedure
it is very slow and speed is a prime requirement of my
system.
Also i'm not using any MFC class to access database.
I'm using ConnectionPtr, RecordsetPtr and _CommandPtr
from msado15.dll for database access...
One solution to this could be use of Temp tables.
As this process is used by a lot of different stored
procedures having a common
temp table to all will need something like 50 NUMERIC
fields, 50 VARCHAR fields
and so on, which doesn't seem like a very good solution
to this problem.
Sounds like something I would have done while in school,
implement a dumb solution.
So, please suggest me a solution as to how do I return
bulk data in the form
of recordsets from stored procedure.
Regards
ShrutiUse Out parameter mode
SQL> CREATE OR REPLACE procedure a1 (x OUT NUMBER, y OUT NUMBER) AS
2 BEGIN
3 x:= 1;
4 y:= 2;
5 END;
6 .
SQL> /
Procedure created.
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 a NUMBER :=3;
3 b NUMBER :=4;
4 BEGIN
5 a1 (a,b);
6 DBMS_OUTPUT.PUT_LINE( 'a = ' || a );
7 dbms_output.put_line( 'b = ' || b );
8 END;
9 .
SQL> /
a = 1
b = 2
PL/SQL procedure successfully completed.By default parameters are copied to the OUT parameter mode .
COPY hint in PLSQL don’t send a pointer to calling program unit but NOCOPY
does.
Khurram -
Ora-06550 returning data from Stored Procedure and Entity Data Model
Hi.
I'm creating an application that uses a WCF Service to return data. I also created a proyect with the EDMX design and mapped most of my DBModel to a classes context. I have added some of the procedures as well. One of them receive some parameters and return a Sys_RefCursor, that is populated according to the parameters.
I have declared the "<add >" tags in the Web.Config and imported the function of the Procedure. When I call the Asyncronous function I get different exceptions:
1. If I call the function, with all of the parameters i get:
Oracle.DataAccess.Client.OracleException: ORA-06550: línea 1, columna 8:
PLS-00306: número o tipos de argumentos erróneos al llamar a
'SP_HECHOSJURITER'
ORA-06550: línea 1, columna 8:
(wrong number or types of arguments in call to 'SP_HECHOSJURITER')
2. If i just set 1 parameter in the SP, returning the same type of data, I get:
Error al recibir la respuesta HTTP a
http://localhost/Procalculo.CGFM.SIGOC.DatosServices/ServiceDatos.svc.
(failed to receive http response. error 12152)
3. If I don't set any parameters in the procedure, it works fine, and return correct data.
It exclusively happen with one entity.
Any clue?
I appreciate any help.When you return result sets from stored procedures to Entity Framework, you are very likely using implicit result sets. Implicit result sets don't need to be declared as a parameter in code, only in the <add> tags to define the metadata in the .NET config file.
For example, in the EF Oracle By Example, you'll see that the stored procedure in the function import has three parameters, but only two are declared in the code. The third one was defined in the config file.
http://download.oracle.com/oll/obe/EntityFrameworkOBE/EntityFrameworkOBE.htm -
How to retrieve Table of Records output param from stored procedure ?
Hi,
I'm trying to retrieve data from a PL/SQL stored proc. It seems I can't modify this procedure (I'm not allowed to and I don't know PL/SQL :)).
My only documentation is the PL/SQL code and its comments. And that's the first I have to deal with output of a defined complex PL/SQL type
So the signature of the procedure is :
FUNCTION FUN_AFF_EVELEG_IHM (
pEntumTyp IN NUMBER,
pEntnum IN VARCHAR2,
pEveListSize IN OUT NUMBER,
pEveList IN OUT pkg_funaff_eveleg.TableRecordEVL,
pErrCode IN OUT VARCHAR2,
pMessage IN OUT VARCHAR2)
RETURN NUMBER;pkg_funaff_eveleg.TableRecordEVL type is defined as "TABLE of RecordEVL"
pkg_funaff_eveleg.RecordEVL type is defined as "RECORD" (struct of 12 different fields : NUMBER or VARCHAR2)
What is the correct syntax to call the stored procedure then ? I don't find how to manage the pEveList output param. Is it a Cursor ? An ARRAY ? And how to register it ?
My code so far :
public static void callFunaffEVL(Connection con, String rcs) {
// CallableStatement procCstmt=null;
OracleCallableStatement oraCstmt = null;
try {
// Identifiy the Stored procedure
// package synonyme : pkg_aff_EVELEG_IHM
// stored procedure name : FUN_AFF_EVELEG_IHM
String command = new StringBuilder("{? = call pkg_aff_EVELEG_IHM.FUN_AFF_EVELEG_IHM(?,?,?,?,?,?");
// 1 RETURN
// 2 pEntumTyp IN NUMBER
// 3 pEntnum IN VARCHAR2
// 4 pEveListSize IN OUT NUMBER,
// 5 pEveList IN OUT pkg_funaff_eveleg.TableauRecordEVL,
// 6 pErrCpde IN OUT VARCHAR2,
// 7 pMessage IN OUT VARCHAR2)
// Create a Callable Statement Object:
oraCstmt = (OracleCallableStatement) con.prepareCall(command);
// Assign IN and OUT parameters
oraCstmt.registerOutParameter(1, OracleTypes.NUMBER); // RET
oraCstmt.setInt(2, 0); // ENTNUMTYP
oraCstmt.setString(3, rcs); // ENTNUM
oraCstmt.registerOutParameter(4, OracleTypes.NUMBER); // pEveListSize
oraCstmt.registerOutParameter(5, OracleTypes.ARRAY); // pEveList
oraCstmt.registerOutParameter(6, OracleTypes.VARCHAR); // pErrCode
oraCstmt.registerOutParameter(7, OracleTypes.VARCHAR); // pMessage
// Execute the Procedure or Function Call:
oraCstmt.execute();
// Process the OUT Placeholders:
int ret = oraCstmt.getInt(1);
String errCode = oraCstmt.getString(6);
String message = oraCstmt.getString(7);
System.out.println("RCS : " + rcs);
System.out.println("ret : " + ret);
System.out.println("errCode : " + errCode );
System.out.println("message : " + message);
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
// Close the CallableStatement Object:
try {
oraCstmt.close();
} catch (SQLException e) {
e.printStackTrace();
Return : java.sql.SQLException: Parameter type Conflict: sqlType=2003
Any help ? I found several examples that might refer to this case, but everything I tried end by a SQL exception of one type or another...
(and sorry for my poor english :))
CyAs I said, "pkg_funaff_eveleg.TableRecordEVL" is TABLE of RecordEVL.
i.e : I can find 2 defined types under the package pkg_funaff_eveleg :
TYPE TableRecordEVL is TABLE of RecordEVL INDEX BY BINARY_INTEGER;
TYPE RecordEVL is RECORD (
EVLENTNUM_PK EVENEMENTS_LEGAUX.EVLENTNUM_PK%TYPE,
EVLENTNUMTYP_PK EVENEMENTS_LEGAUX.EVLENTNUMTYP_PK%TYPE,
EVLSEQ_PK EVENEMENTS_LEGAUX.EVLSEQ_PK%TYPE,
EVLTYPSRC EVENEMENTS_LEGAUX.EVLTYPSRC%TYPE,
EVLPK1 EVENEMENTS_LEGAUX.EVLPK1%TYPE,
EVLPK2 EVENEMENTS_LEGAUX.EVLPK2%TYPE,
EVLPK3 EVENEMENTS_LEGAUX.EVLPK3%TYPE,
EVLPK4 EVENEMENTS_LEGAUX.EVLPK4%TYPE,
EVLPK5 EVENEMENTS_LEGAUX.EVLPK5%TYPE,
EVLPK6 EVENEMENTS_LEGAUX.EVLPK6%TYPE,
EVLCODEVTSRC EVENEMENTS_LEGAUX.EVLCODEVTSRC%TYPE,
EVLLEGEVECOD EVENEMENTS_LEGAUX.EVLLEGEVECOD%TYPE,
EVLSEQREF_FK EVENEMENTS_LEGAUX.EVLSEQREF_FK%TYPE,
EVLCOMMENT EVENEMENTS_LEGAUX.EVLCOMMENT%TYPE,
EVLETATCOD EVENEMENTS_LEGAUX.EVLETATCOD%TYPE,
EVLHISDATPUB EVENEMENTS_LEGAUX.EVLHISDATPUB%TYPE,
EVLHISPUBPRE EVENEMENTS_LEGAUX.EVLHISPUBPRE%TYPE,
EVLHISDATEFF EVENEMENTS_LEGAUX.EVLHISDATEFF%TYPE,
EVLHISEFFPRE EVENEMENTS_LEGAUX.EVLHISEFFPRE%TYPE,
EVLHISPOIDATEFF EVENEMENTS_LEGAUX.EVLHISPOIDATEFF%TYPE,
EVLHISORICOD EVENEMENTS_LEGAUX.EVLHISORICOD%TYPE,
EVLHISSUPPORTCOD EVENEMENTS_LEGAUX.EVLHISSUPPORTCOD%TYPE,
EVLHISNUMSUPPORT EVENEMENTS_LEGAUX.EVLHISNUMSUPPORT%TYPE,
EVLHISNUMINF EVENEMENTS_LEGAUX.EVLHISNUMINF%TYPE,
ANNNUMBODPCL CBODACCPROD.CODANN2.ANNNUMBOD%TYPE
);If needed, I can translate each "EVENEMENTS_LEGAUX.EVLENTNUM_PK%TYPE", but they must be VARCHAR2 or NUMBER
Do I answer your question ? -
Creating Sap Crystal Report Through Oracle Stored Procedure Packages
Hi,
1.How we can create crystal report through oracle stored
procedure packages pls tell me the steps through adding command then
tell me the syntax what should i write in command to call the stored
procedure packages or if have some other option then also tell.
2.can
we link stored procedure column to other table column that used in
report.Hi Ganesh,
As this error comes when you are trying to insert non-numeric value into a numeric column in db it seems that your field might be numeric and you are trying to send it as a string in database.
Please check your Store Proc carefully..
Reference Thread: Oracle/PLSQL: ORA-01722
--Dhana -
System command execution from stored procedure
Hello World,
How to run System command from stored procedure ?
For example :
Delete a file
running a programm,
Is it possible ?
H.MYears ago I did this by writing an output file with commands into a directory and had a cron job looking for this file. At the end of the run the file was removed.
Never checked if there are other possibilities nowadays.
cu
Andreas
Maybe you are looking for
-
Error in BAPI_MATERIAL_SAVEDATA
Hello all. Im trying to update a material using BAPI_MATERIAL_SAVEDATA, I have to update the field PLANTDATA-VARIANCE_KEY among others. But the BAPI returns with the following error: <i>Key fields for user data PLANTDATA and checkbox structure PLANTD
-
Support for JSP's located in WEB-INF directory
Several application servers support the use of placing JSP pages underneath the WEB-INF directory, to insure that only server side workflow forwards requests to those pages and not direct URL access. IN addition the JSTL specification supports the us
-
I have to create 130 separate pages that pull all their data from one spreadsheet. They are arranged by colums of data and then have a row identified by the district. I know I could separate the data for each row onto a indiv. sheet but that would ta
-
Ipod touch wont turn after sync and I tunes is not recognize it
Ipod touch will not turn on after sync and i tunes will not reconginze it. I have uneinstalled and then reinstalled itunes and still nothing.
-
Multiple hierarchies single dimension single report
I am trying to add multiple hierarchies from a single dimension in a single report. To create the hierarchy in BI admin I followed the instructions found here Oracle BI EE 10.1.3.3/2 – One Dimension – Multiple Hierarchies « Business