Calling : sql functions
Hi
I have a question. If I open a connection and call an sql function n number of times in a loop and then commit and close the connection, does it involve n number of database hits? is it very expensive in terms of time taken?(But, functions are precompiled I guess, so it should not take much time), any suggestions...
Thanks
Gaurav
does it involve n number of database hits?Yes. Or, depending on how you define "database hit", it may involve even more if the function does several SQL operations.
is it very expensive in terms of time taken?Depends on the function. N times as expensive as calling it once. If the function doesn't do anything complicated, you may be able to call it several hundred times a second. Try it to see how long it takes.
Similar Messages
-
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 -
Calling SQL function in SQL query fails
Hi There,
I am trying to execute INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('?')) using ODBC C
SQLBindParameter APIs.
If I execute the INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('<name>milind</name>')) works fine.
Can anybody please help me out here?
Thanks,
Milind
/* blob.c
* The following C code demonstrates how to read an input file, piecewise
* (in chunks), and write it into a BLOB or LONG RAW column in the database.
* It then reads that BLOB or LONG RAW data, piecewise, from the database
* and writes it back to the OS as an output file that you specify.
* Enter the following SQL statement via SQL*Plus to create the table
* 'images_data' for use with this sample. Make sure you log into
* Oracle as a user appropriate for running this example.
* For BLOB, use the following table:
* CREATE TABLE images_data (
* name VARCHAR2(100),
* imagesize NUMBER,
* image BLOB);
* For LONG RAW, use the following table:
* CREATE TABLE images_data (
* name VARCHAR2(100),
* imagesize NUMBER,
* image LONG RAW);
* Change the connection information at the beginning of the procedure OpenOra
* to your DSN, username and password.
* To run this program, open a Command Prompt and use the following syntax:
* Syntax: <program_name> <infile_name> <outfile_name>
* Example call: C:\> blob my_photo.jpg copy_of_my_photo.jpg
#include "stdafx.h"
#include <stdio.h>
#include <io.h>
#ifndef NUTC
#include <windows.h>
#endif
#include <sql.h>
#include <sqlext.h>
#ifdef NUTC
#include <sys/types.h>
#include <sys/stat.h>
#endif
* Global variables
HENV hOdbcEnv = NULL; /* Environment handle */
HDBC hDbConn = NULL; /* Connection handle */
int sr; /* Return value */
#define BUFSIZE 32020 /* Chunksize */
* Connect routine
void OpenOra()
char szDSN[] = "XY10g2"; /* Data Source Name (DSN) */
char szUID[] = "odbc1"; /* Username */
char szAUTH[] = "pdmuser"; /* Password */
* Allocate environment handle
sr = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hOdbcEnv);
if (sr != SQL_SUCCESS)
printf ("Error allocating environment handle\n");
* Set the ODBC Version
sr = SQLSetEnvAttr(hOdbcEnv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3, SQL_IS_INTEGER);
if (sr != SQL_SUCCESS)
printf ("Error setting ODBC version\n");
* Allocate connection handle
sr = SQLAllocHandle (SQL_HANDLE_DBC, hOdbcEnv, &hDbConn);
if (sr != SQL_SUCCESS)
printf ("Error allocating connection handle\n");
* Connect
sr = SQLConnect(hDbConn, (UCHAR *)szDSN, SQL_NTS,(UCHAR *)szUID, SQL_NTS, (UCHAR *)szAUTH, SQL_NTS);
if (sr != SQL_SUCCESS)
printf("Connection failed\n");
* Disconnect routine
void CloseOra()
* Disconnect and free connection and environment handles
sr = SQLDisconnect(hDbConn);
if (hDbConn != SQL_NULL_HANDLE)
SQLFreeHandle(SQL_HANDLE_DBC, hDbConn);
if (hOdbcEnv != SQL_NULL_HANDLE)
SQLFreeHandle(SQL_HANDLE_ENV, hOdbcEnv);
* Read INFILE into the database and read data back out and save as OUTFILE.
void readCertImage(char read_name, long filesize, char write_name)
SQLCHAR iSqlCmd[300] = "INSERT INTO XML_DATA (NAME, DATASIZE, DATA) VALUES (?,?,XMLType('?'))";
SQLCHAR iSqlCmd1[300] = "SELECT DATA FROM XML_DATA WHERE NAME = ?";
FILE ifile, ofile; /* File pointers */
time_t startTime, endTime;
time_t startTimeIO, endTimeIO;
int IOtime = 0;
unsigned char buf[BUFSIZE]; /* Buffer to hold chunk */
unsigned char buf1[BUFSIZE]; /* Buffer to hold chunk */
SQLINTEGER type[3]; /* Type of data */
SQLPOINTER pToken; /* Which column is piecewise */
HSTMT hstmt = NULL; /* Statement handle */
long i; /* Byte Counter */
long count; /* Piecewise Counter */
long rd; /* Amount to read */
* Log on
OpenOra();
ifile = fopen(read_name, "r"); /* Open the file for reading in ASCII mode */
* Allocate statement handle
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
if (sr != SQL_SUCCESS)
printf("Error allocating statement handle\n");
* Prepare insert statement
sr = SQLPrepare(hstmt, iSqlCmd, SQL_NTS);
if (sr != SQL_SUCCESS)
printf("Error preparing insert statement\n");
* Bind Parameters
/* Name of BLOB */
sr = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0,read_name, strlen(read_name), &type[0]);
if (sr != SQL_SUCCESS)
printf("Error binding name variable\n");
/* Size of BLOB */
sr = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_NUMERIC, 0, 0,&filesize, 0, &type[1]);
if (sr != SQL_SUCCESS)
printf("Error binding length variable\n");
* As this will be a piecewise insert do not need to pass a buffer here.
* Instead pass the parameter number for identification purposes.
/* BLOB data */
sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)3, 0, &type[2]);
if (sr != SQL_SUCCESS)
printf("Error binding data variable\n");
type[0] = SQL_NTS; /* Null terminated string */
type[1] = 0; /* Ignored for numbers */
type[2] = SQL_LEN_DATA_AT_EXEC(filesize); /* Data at execution time */
time( &startTime );
* Execute the insert
sr = SQLExecute(hstmt);
if (sr == SQL_NEED_DATA)
printf("\nAbout to perform piecewise insert of data\n\n");
else if (sr != SQL_SUCCESS)
printf("Error executing insert statement\n");
* Retrieve the pointer to the buffer containing the address
* of the location where the source BLOB will be sent
sr = SQLParamData(hstmt, &pToken);
if (sr != SQL_NEED_DATA)
printf("Error - no piecewise operations required\n");
* Write the data in BUFSIZE chunks
i = 0; /* Initialize bytes inserted
count = 0; /* Initialize pieces/chunks inserted */
do
count++; /* Increment chunk number */
* If remaining bytes to read is greater than BUFSIZE,
* read another BUFSIZE chunk. Otherwise, read remaining
* chunk of bytes (which will be less than BUFSIZE)
if (filesize - i >= BUFSIZE)
rd = BUFSIZE;
else
rd = (filesize - i);
printf("%5ld:%10ld - About to write %ld bytes to the database\n",count,i,rd);
* Reads one rd sized chunk of data into buffer from source file (BLOB)
time( &startTimeIO );
fread(buf, rd, 1, ifile);
time( &endTimeIO );
IOtime = IOtime + (endTimeIO - startTimeIO);
* Sends the contents of the buffer to the ODBC driver
SQLPutData(hstmt, buf, rd);
/* Recalculate total bytes sent */
if (filesize - i >= BUFSIZE)
i+= BUFSIZE;
else
i+= (filesize - i);
} while (i < filesize);
/* Check to see if all data has been sent */
sr = SQLParamData(hstmt, &pToken);
if (sr == SQL_NEED_DATA)
printf("Error - still need data\n");
printf("%5ld:%10ld - Done writing data\n",++count,i);
time( &endTime );
printf("BLOB Write completed StartTime: %d, EndTime: %d, IOTime: %d in seconds.\n", endTime, startTime, IOtime);
printf("BLOB Write completed in %d seconds.\n", (endTime - startTime) - IOtime);
fclose(ifile); /* Close the INFILE */
printf("\nData inserted into database\n\n");
* Now read the data back. Reuse the previous statement handle.
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
sr = SQLAllocHandle(SQL_HANDLE_STMT, hDbConn, &hstmt);
if (sr != SQL_SUCCESS)
printf("Error allocating statement handle\n");
* Prepare select statement, bind variable and execute
sr = SQLPrepare(hstmt, iSqlCmd1, SQL_NTS);
if (sr != SQL_SUCCESS)
printf("Error preparing select statement\n");
sr = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 0, 0, read_name, strlen(read_name), &type[0]);
if (sr != SQL_SUCCESS)
printf("Error binding name variable\n");
time( &startTime );
sr = SQLExecute(hstmt);
if (sr != SQL_SUCCESS)
printf ("Error executing insert statement\n");
ofile = fopen(write_name, "w"); /* Open the file for writing in ASCII mode */
sr = SQLFetch(hstmt);
if (sr != SQL_SUCCESS)
printf ("Error fetching data\n");
* Read the data in BUFSIZE chunks.
i = 0; /* Initialize bytes inserted */
count = 0; /* Initialize pieces/chunks inserted */
memset(buf, NULL, BUFSIZE);
do
* Retrieve a BUFSIZE chunk of data into the buffer
sr = SQLGetData(hstmt, 1, SQL_C_CHAR, buf, BUFSIZE, &type[2]);
if (sr == SQL_ERROR)
printf("Error fetching data\n");
break;
time( &startTimeIO );
count++; /* Increment chunk number */
/* Determine if this is a full chunk or the last chunk */
if (filesize - i >= BUFSIZE)
printf("%5ld:%10ld - About to write %ld bytes to file\n",count,i,BUFSIZE);
fwrite(buf, BUFSIZE, 1, ofile); /* Write BUFSIZE chunk to file */
else
printf("%5ld:%10ld - About to write %ld bytes to file\n",count,i,filesize-i);
fwrite(buf, filesize-i, 1, ofile); /* Write remaining chunk to file */
time( &endTimeIO );
IOtime = IOtime + (endTimeIO - startTimeIO);
/* Recalculate total bytes retrieved */
if (filesize - i >= BUFSIZE)
i+= BUFSIZE;
else
i+= (filesize - i);
} while (sr == SQL_SUCCESS_WITH_INFO);
printf("%5ld:%10ld - Done writing file\n",++count,i);
time( &endTime );
printf("BLOB Read completed StartTime: %d, EndTime: %d, IOTime: %d in seconds.\n", endTime, startTime, IOtime);
printf("BLOB Read completed in %d seconds.\n", (endTime - startTime) - IOtime);
fclose(ofile); /* Close the OUTFILE */
printf("\nData written to file\n");
* Log off
SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
CloseOra();
* Main routine
void main(argc, argv)
int argc; /* Number of command line arguments */
char argv[]; / Array of command line arguments */
long filesize = 0; /* Size of INFILE */
FILE ifile; / Pointer to INFILE */
#ifdef NUTC
struct stat statbuf; /* Information on a file. */
#endif
/* Check for the proper number of command line arguments entered by user */
if (argc != 3)
printf("\nCommand line syntax: <program_name> <infile_name> <outfile_name>");
printf("\n Example call: blob input.exe output.exe\n");
exit(1);
/* Open INFILE */
if( (ifile = fopen(argv[1], "rb" )) == NULL )
printf( "\nThe file '%s' could not be opened\n",argv[1]);
exit(1);
else
printf( "\nThe file '%s' was opened successfully\n",argv[1]);
#ifdef NUTC
/* Determine length of the INFILE */
if (fstat(fileno(ifile), &statbuf) == 0)
filesize = statbuf.st_size;
else
filesize = 0;
#else
filesize = filelength(fileno(ifile));
#endif
printf( "The file is %d bytes long\n",filesize);
/* Close INFILE */
fclose(ifile);
/* Insert and retrieve BLOB */
readCertImage(argv[1], filesize, argv[2]);
}During binding, strings are generally skipped. As such, you should first try replacing XMLType('?') with XMLType(?). You don't need to specify '?' because the system knows the proper type from your SQLBindParameter call.
Also, you should try replacing:
sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)3, 0, &type[2]);
with
sr = SQLBindParameter(hstmt, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, 0, 0,(SQLPOINTER)buf, BUFSIZE, &type[2]); -
How to call a SQL function from an XSL expression
Hi
In R12, in Payroll Deposit adivce/Check writer, We need to sort the earnings tag <AC_Earnings> in to two different categories as regular and other earnings. In the DB and form level of element defintiion we have a DFF which differentiates between the two kinds of earnings. But the seeded XML that is gerneated by the check writer does not have this field.
The seeded template displays all the earnings in one column. How can we achieve this in the template without modifying the seeded XML.
The one approach i have is to write a function and based on the return value sort the data. For this I need to know :
1) How to call a SQL function from an XSL expression that is allowed in BI template.
If anyone ahs faced similar requirements please share your approach.
Thanks
SrimathiThank u..
but i'd seen that link wen i searched in google..
Is it possible without using any 3rd party JARs and all?
and more importantly plz tell me what should be preferred way to call a javascript function?
Do it using addLoadEvent() or Windows.Load etc
OR
Call it thru Xsl? (I donno how to do dis)
Thanks in Advance..
Edited by: ranjjose on Jun 3, 2008 8:21 AM -
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 PMtry something like this:
return fn_dbtype(1)@dblink; -
Passing parameters to PL/SQL function called in VO
Hi,
I am writing a VO that is calling a PL/SQL function. The VO query looks like this.
select xx_dummy_func (:1,:2) from dual
Now, how can I assign these two parameter values at run time?
Generally when we have a query parameters We do xxVO.setwhereclauseparam. But in the above scenario, its not a whereclause but instead a procedure parameter. Please let me know how to do it.
Thanks in advance,
Regards,
-AbmThats correct, basically, setwherecaluse param api, just replaces bind variables with the index values, whereever they are in the query!
--Mukul -
For each row of a table call a pl/sql function
Hi,
i have a search form in adf like this:
parameter1:___
parameter2:____
buttonSearch
Table with results
field1 field2 field3
row1 ------ --------- -------
row2 ------ --------- -------
row3 ------ --------- -------
The user inputs the parameters 1 and 2 then press buttonSearch and the query execute and returns rows 1 to 3.
What i need is for each row call pl/sql function and passed the parameter 1 and 2 and field 1 to 3 (plsql function recives 5 parameters (parameter1, parameter2, field1 , field2 and field3) )
my buttonSearch call a java class that execute ExecuteWithParamters method.
I create the call to my plsql function on Application module class and then export as a java interface.
So i have the function to use in the viewcontroller layer, but i don't know where to use it, and how to pass the paramters: the parameter 1 and 2 that user inputs and the row fields.....
any ideas....
thanks!!Hi,
for this you need to call the PLSQL function upon table rendering, which means that you need a field in the table referencing a managed bean. In the managed bean you can use #{row} and resolve it using a ValueExpression. #{row} gives you access to the current rendered row (this is why you need to do it when the table renders) and thus allows you to call getAttribute(name) to get the values of field 1 - 3. The search field value you should get through the bindings reference (assuming the search form uses ADF). Then you create an operation binding for the executeWithParameters and call operationBindingName.getParamsMap().put(argname, argvalue); on it.
Frank
Ps.: I am concerned about the performance you get and wonder if it isn't possible to create a transient attribute that executes the function and displays the results. As I understand, the search parameters are only to filter the result set, which you still can do -
SQL query slow with call to function
I have a SQL query that will return in less than a second or two with a function in-line selected in the "from" clause of the statement. As soon as I select that returned value in the SQL statement, the statement takes from anywhere from 2 to 5 minutes to return. Here is a simplified sample from the statement:
This statement returns in a second or 2.
select A.pk_id
from stu_schedule A, stu_school B, stu_year C, school_year D,
(select calc_ytd_class_abs2(Z.PK_ID,'U') ytd_unx
from stu_schedule Z) II
where B.pk_id = A.fk_stu_school
and C.pk_id = B.fk_stu_year
and D.pk_id = C.year
and D.school_year = '2011';
if I add this function call in, the statement runs extremely poor.
select A.pk_id,
II.ytd_unx
from stu_schedule A, stu_school B, stu_year C, school_year D,
(select calc_ytd_class_abs2(Z.PK_ID,'U') ytd_unx
from stu_schedule Z) II
where B.pk_id = A.fk_stu_school
and C.pk_id = B.fk_stu_year
and D.pk_id = C.year
and D.school_year = '2011';
Here is the function that is called:
create or replace FUNCTION calc_ytd_class_abs2 (p_fk_stu_schedule in varchar2,
p_legality in varchar2) return number IS
l_days_absent number := 0;
CURSOR get_class_abs IS
select (select nvl(max(D.days_absent),'0')
from cut_code D
where D.pk_id = C.fk_cut_code
and (D.legality = p_legality
or p_legality = '%')) days_absent
from stu_schedule_detail B, stu_class_attendance C
where B.fk_stu_schedule = p_fk_stu_schedule
and C.fk_stu_schedule_detail = B.pk_id;
BEGIN
FOR x in get_class_abs LOOP
l_days_absent := l_days_absent + x.days_absent;
END LOOP;
return (l_days_absent);
END calc_ytd_class_abs2;Query returns anywhere from 6000 to 32000 rows. For each of those rows a parameter is passed in to 4 different functions to get ytd totals. When I call the functions in the in-line view but do not select from them in the main SQL, the report (oh, this is Application Express 4.0 interactive reports, just an FYI) runs fast. The report comes back in a few seconds. But when I select from the in-line view to display those ytd totals, the report runs extremely slow. I know there are the articles about context switching and how mixing SQL with PL/SQL performs poorly. So I tried a pipeline table function where the function for the ytd totals populate the columns of the pipeline table and I select from the pipeline table in the SQL query in the interactive report. That seemed to perform a little worse from what I can tell.
Thanks for any help you can offer. -
How can I order PL/SQL functions in "Called" a "Caller" order in function script file
Does anybody know how to create PL/SQL function script file
in "called" and "caller" (parent/child) order.
Thanks
SoheilDoes anybody know how to create PL/SQL function script file
in "called" and "caller" (parent/child) order.
Thanks
Soheil -
Calling PL/SQL functions in SQL
Hi,
I had a question on the behaviour of PL/SQL function when they are embedded in SQL queries.
I have simple PL/SQl function:
function get_city_id
(vCUSTOMER_GROUP_ID IN NUMBER)
RETURN VARCHAR2 AS
vIDs VARCHAR2(1000);
begin
vIDs := '2,3';
RETURN vIDs;
end;
I use an SQL query call this PL SQL function;
select equipment_id from equipment where equipment_type_id in (get_city_id(0));
When I run this query I get this error:
ERROR at line 1:
ORA-01722: invalid number
I understand that the SQL compiler is complaining that get_city_id() function is not returning a number. but isn't the PL/SQL suppose to be replace with whatever string is returned from the function.
This brings me to the second question: How can we return multiple values from a function to the SQL query, when the function is called in a SQL query. In my above explame, can the get_city_id() function return more than one city id and if yes, the how?
Thanks for the help in advance
regards
AlankarHow can we return multiple values from a function to the SQL query,Have it return a collection, e.g.
CREATE OR REPLACE TYPE VARCHAR2_TT AS TABLE OF VARCHAR2(4000)
CREATE OR REPLACE FUNCTION test_collection
RETURN VARCHAR2_TT
AS
BEGIN
RETURN VARCHAR2_TT(1,2,3);
END;
SELECT *
FROM employees
WHERE emp_id IN
( SELECT column_value
FROM TABLE(test_collection) ); -
Calling a PL/SQL function in the SQL statement
I have a PL/SQL function which i should call in a SQL statement.
Let's say the function is func1(parameter1,parameter2),
it should be called like this :- SELECT func1() FROM mytable ;
Can any one help me out on this ?
---Thanx in advanceyou can call pl/sql functions from pl/sql using
select fn1('param1','param2') from table;
if you dont want to pass paramters, you have to specify default
value while creating function like below
create function fn1(p1 number default null,p2 varchar2 default
null) return...
now you can call using
select fn1 from table; -
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. -
Calling pl/sql function in CKM...pls help
Hi,
I have made a call to PL/SQL function in CKM customization. The code is :
declare
L_PMG_VALUE VARCHAR(3);
begin
L_PMG_VALUE:='PMG';
VALIDATE_PMG_VALUE(L_PMG_VALUE);
end;
When i run it, it throws error which says:
6550 : 65000 : java.sql.SQLException: ORA-06550: line 1, column 64:
PLS-00221: 'VALIDATE_PMG_VALUE' is not a procedure or is undefined
ORA-06550: line 1, column 64:
PL/SQL: Statement ignored
Function is compiled in the database and its working. I have selected the Technology as Oracle and correct Schema Name.
Please helpHi,
try the following way. i have not tried ....i think it helps you.
In which schema you have created that procedure.
Does the ODI user mantioned in topology have execute permissions on the procedure? if the ODI user have execute previlage on the procedure then in CKM customisation call the procedure like <schema>.<procedure>.
Please let me know any issues.
Thanks, -
Calling pl/sql function in controller
HI all
i have a problem in calling a pl/sql function in a controller..
the question is can we call a pl/sql function in a controller if so
will the code below works???
String invoice_id=getInvoiceId().toString();
Number Invoice_amount=getAmount();
DBTransaction txn = getDBTransaction();
String Filesql="BEGIN SELECT sum(AMOUNT_REMAINING) into :1 FROM ap_payment_schedules_all where invoice_id=:2;END;";
OracleCallableStatement Filecs=(OracleCallableStatement)txn.createCallableStatement(Filesql,1);
String AmountRemaining = "";
try{
Filecs.registerOutParameter(1, OracleTypes.VARCHAR, 0, 100);
Filecs.setString(2,invoice_id);
Filecs.execute();
AmountRemaining=Filecs.getString(1);
Filecs.close();
catch(SQLException sqle){
try { Filecs.close(); } catch (Exception e) {;}
throw OAException.wrapperException(sqle);
when i write the above code in a controller ..it is saying getDBTransaction not defined....
can u help me out in this...String RuleName=pageContext.getParameter("CashRule");
String OrgId=pageContext.getParameter("OrgId");
String TransType=pageContext.getParameter("TransactionType");
OAApplicationModule am = (OAApplicationModule)pageContext.getApplicationModule(webBean);
OADBTransaction txn = am.getOADBTransaction();
String Filesql="BEGIN select cle_f246_return_anal_mod_pkg.ret_anal_module(:2,:3,:4) into :1 from dual;END;";
OracleCallableStatement Filecs=(OracleCallableStatement)txn.createCallableStatement(Filesql,1);
String AnalyticalModule = "";
try{
Filecs.registerOutParameter(1, OracleTypes.VARCHAR, 0, 100);
Filecs.setString(2,TransType);
Filecs.setString(3,RuleName);
Filecs.setString(4,OrgId);
Filecs.execute();
AnalyticalModule=Filecs.getString(1);
Filecs.close();
catch(SQLException sqle){
try { Filecs.close(); } catch (Exception e) {;}
throw OAException.wrapperException(sqle);
this is the code i wrote in controller processformRequest...all the parameters are showiing correct values...but i am getting following error at Filecs.close();
org_id is of type Number but i am passing that as a string as setString accepts only strings...will that cause ne problem???
the error is:
oracle.apps.fnd.framework.OAException: java.sql.SQLException: ORA-01722: invalid number ORA-06512: at line 1 at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:896) at oracle.apps.cle.f246.webui.CashReportDetailsCO.processFormRequest(CashReportDetailsCO.java:88) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:813) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1178) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1025) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:991) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:846) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1025) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:991) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:846) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2840) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1834) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:532) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:420) at OA.jspService(_OA.java:75) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:453) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:591) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:515) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:711) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368) at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448) at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239) at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34) at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595) ## Detail 0 ## java.sql.SQLException: ORA-01722: invalid number ORA-06512: at line 1 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743) at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215) at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:967) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3327) at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3433) at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4394) at oracle.apps.cle.f246.webui.CashReportDetailsCO.processFormRequest(CashReportDetailsCO.java:82) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:813) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1178) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1025) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:991) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:846) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1025) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:991) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:846) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2840) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1834) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:532) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:420) at OA.jspService(_OA.java:75) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:453) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:591) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:515) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:711) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368) at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448) at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239) at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34) at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595) java.sql.SQLException: ORA-01722: invalid number ORA-06512: at line 1 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743) at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215) at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:967) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3327) at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3433) at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4394) at oracle.apps.cle.f246.webui.CashReportDetailsCO.processFormRequest(CashReportDetailsCO.java:82) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:813) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1178) at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1025) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:991) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:846) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:1025) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:991) at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:846) at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:382) at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363) at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2840) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1834) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:532) at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:420) at OA.jspService(_OA.java:75) at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59) at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:453) at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:591) at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:515) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:711) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368) at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448) at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110) at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260) at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239) at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34) at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303) at java.lang.Thread.run(Thread.java:595) -
Can I call a function with an arguement of %ROWTYPE directly from SQL?
I have the following function in a 10g DB:
CREATE OR REPLACE FUNCTION f_is_eligible2 (in_dm_row IN amplify_dm%ROWTYPE)
RETURN NUMBER
IS
I know I can call that function from another pl/sql function but I'm wondering if I can call that function directly from a SQL statement, something like this:
SELECT f_is_eligible2(dm.*)
FROM amplify_dm dm
or
SELECT f_is_eligible2(dm%rowtype)
FROM amplify_dm dm
neither of those worked so I'm thinking it's not possible but I thought I'd ask anyway.
Thanks in advance!Not possible as said - but - based on what I'm seeing - you could simply pass the parameter(s) that are key on that table and - accomplish the same thing by modifying the function.
not sure why you'd need the whole row if I'm interpretting the code excerpt.
Maybe you are looking for
-
WBS element assigned to GL account
Hi All, I wanted to know how do we understand which is WBS element assigned is to particulat GL account. Thanks Santhi
-
How to configure network on Oracle Solaris 10
Hi All, I have created a new virtual machine on Windows Server 2003 and installed Oracle Solaris 10 on VMWare. Now I need to configure network on my Solaris virtual machine, So that i can access Solaris machine outside the VMWare. Can somebody help m
-
Howto process non .jsp files wiht the jsp processor?
I am building an application that uses a tag to include some resources to the page. This tag simple get in the context the bean assossiated with the tag and include it in its own stead. An engine process the request setting in the request scope a bea
-
Hi experts, I hope someone could help me with my problem. We have installed DMS connector on our EP 7.0, configured it, but even though the connection to R/3 is all right the document explorer shows me just 'dmsrm' folder (which corresponds to Prefix
-
No option to select Outlook for syncing - 64bit Win7 and Outlook 2010
The option to sync with Outlook is not there ! It's there on my XP 32 bit machine but not my new 64bit Win7 laptop with 64bit Outlook installed. Is thsi a compatibility issue ?