How to call sql procedure with parameter from java
Hello,
i am trying to call one sql procedure with two parameters from java.
the first parameter is In parameter, the second is OUT.
the return value of this java method should be this second parameter value.
the following is my java code:
protected String getNextRunNumber() {
String runnumber=null;
String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
CallableStatement state = null;
try{
Connection con= getDatabaseConnection();
state = con.prepareCall(sql);
state.setString(1, m_appKeyExport);
state.registerOutParameter(2,Types.NUMERIC,0);
state.execute();
ResultSet resultR = (ResultSet)state.getObject(2);
while (resultR.next()) {
runnumber=resultR.getBigDecimal(1).toString();
catch (SQLException e){System.out.println("You can not get the export next run number properly");}
return runnumber;
i got error message like:
java.lang.ClassCastException: java.math.BigDecimal
As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.
Please help me to solve this problem.
Thanks a lot.
state.execute();
i try to use debug to find the problem, in this line, i saw
OracleCallableStatement(OraclePreparedStatement).execute() line: 642 [local variables unavailable]
is this the problem?
Similar Messages
-
How to call a procedure with refcursor from another plsql unit
example I created a pkg with the a procedure that returns a REFCURSOR.
Now I need to call this procedure from another pkg and use the refcursor values in other pkg.
Help please.......
PROCEDURE CustomerSite_Get (p_Registry IN VARCHAR2,
p_CustomerNumber IN VARCHAR2, p_Cursor IN OUT t_cursor);
PROCEDURE CustomerSite_Get (p_Registry IN VARCHAR2,
p_CustomerNumber IN VARCHAR2, p_Cursor IN OUT t_cursor)
IS
-- 0903: Include BillToName
BEGIN
OPEN p_Cursor FOR
SELECT S.LOCATION CustomerSite, S.SITE_USE_ID CustomerSiteID, C.CUSTOMER_NAME BillToName
FROM RA_CUSTOMERS C,
RA_ADDRESSES A,
RA_SITE_USES S,
UWA_REGISTRY R,
UWA_REGISTRY_BILL_TO B
WHERE C.CUSTOMER_ID = A.CUSTOMER_ID
AND A.ADDRESS_ID = S.ADDRESS_ID
AND S.SITE_USE_ID = B.SITE_USE_ID
AND R.REGISTRY_ID = B.REGISTRY_ID
AND B.TRIP_BILLING != 'N'
AND R.DELETE_FLAG != 'Y'
AND R.Registry = p_Registry
AND R.CUSTOMER_NUM = p_CustomerNumber
ORDER BY S.LOCATION;
END CustomerSite_Get;
thanks,
Anitha.
Edited by: user521218 on May 6, 2009 1:24 PMHi Anitha,
try this,
-- PKG_A
Procedure CustomerSite_Get( p_Registry IN Varchar2
, p_CustomerNumber IN Varchar2
, p_Cursor IN OUT t_cursor) Is
Begin
PKG_B.CustomerSite_Get( p_Registry
, p_CustomerNumber
, p_Cursor );
End;
-- PKG_B
Procedure CustomerSite_Get(p_Registry IN Varchar2
,p_CustomerNumber IN Varchar2
,p_Cursor IN OUT t_cursor) Is
Begin
Open p_Cursor For
SELECT S.LOCATION CustomerSite
,S.SITE_USE_ID CustomerSiteID
,C.CUSTOMER_NAME BillToName
FROM RA_CUSTOMERS C
,RA_ADDRESSES A
,RA_SITE_USES S
,UWA_REGISTRY R
,UWA_REGISTRY_BILL_TO B
WHERE C.CUSTOMER_ID = A.CUSTOMER_ID
AND A.ADDRESS_ID = S.ADDRESS_ID
AND S.SITE_USE_ID = B.SITE_USE_ID
AND R.REGISTRY_ID = B.REGISTRY_ID
AND B.TRIP_BILLING != 'N'
AND R.DELETE_FLAG != 'Y'
AND R.Registry = p_Registry
AND R.CUSTOMER_NUM = p_CustomerNumber
Order BY S.LOCATION;
End CustomerSite_Get;regards,
Christian Balz -
Problem calling Procedure with parameter from Dynamic Page
I received an error saying the Page not found
here's how to reproduce the error.
1. Create procedure in portal30 schema.
Create or Replace PROCEDURE PORTAL30.ADD_TWO_VALUES
v_one IN NUMBER,
v_two IN NUMBER,
v_result OUT NUMBER)
as
begin
v_result :=v_one+v_two;
end;
2. Create Dynamic Page with following code
<ORACLE>DECLARE
v_total NUMBER;
BEGIN
ADD_TWO_VALUES(:v_one,:v_two, v_total);
htp.p('The total is => ');
htp.p('<input type="TEXT" VALUE='||v_total||'>');
htp.para;
htp.anchor('http://<machine.domain:port#>/pls/portal30/PORTAL30.DYN_
ADD_TWO_VALUES.show_parms', 'Re-Execute Procedure');
END;</ORACLE>
3. I clicked on Customize Link and entered 2 numbers as values for v_one and v_two.
4. Got "The page cannot be found" error in I.E. or "The requested URL /pls/portal30/PORTAL30.DYN_SAMPLE_ADD.show was not found on this server." on Netscape
However when I subsitute "ADD_TWO_VALUES(:v_one,:v_two, v_total);" in the dynamic page for "ADD_TWO_VALUES(3,2, v_total);", it runs just fine.
What's wrong here? Can I not use a parameter from a dynamic page and call a procedure with it? Help is needed urgently and will be greatly appreciated.
-AhsunHi,
I tried with your code with few changes ,please try with them.
Create or Replace PROCEDURE <myschema>.ADD_TWO_VALUES
v_one IN NUMBER,
v_two IN NUMBER,
v_result OUT NUMBER)
as
begin
v_result :=v_one+v_two;
end;
I created the procedure in <mySchema> and granted that to <application_schema> and made some changes
<ORACLE>
DECLARE
v_total NUMBER;
BEGIN
<procedure_schema>.ADD_TWO_VALUES(:v_one,:v_two, v_total);
htp.p('The total is => ');
htp.p('<input type="TEXT" VALUE='||v_total||'>');
htp.para;
htp.anchor('http://<your_host>/pls/<portal_schema>/<application_schema>.DYN_FOR_OTN.SHOW_PARMS', 'Re-Execute Procedure');
END;
</ORACLE>
Hope this helps.
rahul -
How to call stored procedure with multiple parameters in an HTML expression
Hi, Guys:
Can you show me an example to call stored procedure with multiple parameters in an HTML expression? I need to rewrite a procedure to display multiple pictures of one person stored in database by clicking button.
The orginal HTML expression is :
<img src="#OWNER#.dl_sor_image?p_offender_id=#OFFENDER_ID#" width="75" height="75">which calls a procedure as:
procedure dl_sor_image (p_offender_id IN NUMBER)now I rewrite it as:
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number)could anyone tell me the format for the html expression to pass multiple parameters?
Thanks a lot.
SamHi:
Thanks for your help! Your question is what I am trying hard now. Current procedure can only display one picture per person, however, I am supposed to write a new procedure which displays multiple pictures for one person. When user click a button on report, APEX should call this procedure and returns next picture of the same person. The table is SOR_image. However, I rewrite the HTML expression as follows to test to display the second image.
<img src="#OWNER#.Sor_Display_Current_Image?p_n_Offender_id=#OFFENDER_ID#&p_n_image_Count=2" width="75" height="75"> The procedure code is complied OK as follows:
create or replace
PROCEDURE Sor_Display_Current_Image(p_n_Offender_id IN NUMBER, p_n_image_Count in number) AS
v_mime_type VARCHAR2(48);
v_length NUMBER;
v_name VARCHAR2(2000);
v_image BLOB;
v_counter number:=0;
cursor cur_All_Images_of_Offender is
SELECT 'IMAGE/JPEG' mime_type, dbms_lob.getlength(image) as image_length, image
FROM sor_image
WHERE offender_id = p_n_Offender_id;
rec_Image_of_Offender cur_All_Images_of_Offender%ROWTYPE;
BEGIN
open cur_All_Images_of_Offender;
loop
fetch cur_All_Images_of_Offender into rec_Image_of_Offender;
v_counter:=v_counter+1;
if (v_counter=p_n_image_Count) then
owa_util.mime_header(nvl(rec_Image_of_Offender.mime_type, 'application/octet'), FALSE);
htp.p('Content-length: '||rec_Image_of_Offender.image_length);
owa_util.http_header_close;
wpg_docload.download_file (rec_Image_of_Offender.image);
end if;
exit when ((cur_All_Images_of_Offender%NOTFOUND) or (v_counter>=p_n_image_Count));
end loop;
close cur_All_Images_of_Offender;
END Sor_Display_Current_Image; The procedure just open a cursor to fetch the images belong to the same person, and use wpg_docload.download_file function to display the image specified. But it never works. It is strange because even I use exactly same code as before but change procedure name, Oracle APEX cannot display an image. Is this due to anything such as make file configuration in APEX?
Thanks
Sam -
How to call report rdf with parameter passing..
Hai
I am using 10g developer suite and 10 g report. I want to call some report in the when_button_pressed trigger. like c:\ report\ test.rdf file. we don't have separate application server.more than 10 users using forms and report. Without application server (dedicated application server ) we are using oracle.
How to call the report rdf file from form ? how to pass the parameters ? how to start the report server ? I tried many answers I am not getting correct coding plese help me to find out correct code .. run the report perfectly... from form.
digging here not get correct coding... please help me.. urgent
vasanth.Hai,
It seems same 6i reports coding, I am not aware of that.. Soon I will tell you..
Thanks a lot.
regards
vasanth -
How to call a procedure with SYS_REFCURSOR OUT parameter
Hi,
Using Oracle 11g R2.
I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
create or replace procedure testprocedure (result OUT sys_refcursor)
as
begin
open result for
select 1 from dual
union all
select 2 from dual;
end;
I'd like to call this procedure similar to the way a query is called and executed. Like this
select * from testprocedure
I've seen plenty of examples on the web which show how it is possible to loop through results of a sys_refcursor inside of an anonymous block and display the results using dbms_output.putline, but this isn't the method I am looking for.I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure
No - you can only use schema object types (SQL) in SQL queries and only then if you call a function.
The function can return a SQL collection type or it can be a PIPELINED function whose return value is a SQL collection type. Either way your query will use the TABLE function and be of the form:
select * from TABLE(testfunction);
This is sample code for a PIPELINED function based on the SCOTT.EMP table. The function takes a department number parameter and returns the EMP rows for that department:
-- type to match emp record
create or replace type emp_scalar_type as object
(EMPNO NUMBER(4) ,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(2)
-- table of emp records
create or replace type emp_table_type as table of emp_scalar_type
-- pipelined function
create or replace function get_emp( p_deptno in number )
return emp_table_type
PIPELINED
as
TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
emp_cv EmpCurTyp;
l_rec emp%rowtype;
begin
open emp_cv for select * from emp where deptno = p_deptno;
loop
fetch emp_cv into l_rec;
exit when (emp_cv%notfound);
pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
end loop;
return;
end;
select * from table(get_emp(20)) -
How to call stored procedure having parameter as oracle type from java???
Hello,
I have created following type & stored procedure in oracle. How can i call this stored procedure from my java class?
I want to pass 2d array to this procedure.
CREATE OR REPLACE TYPE type_survey AS OBJECT ( emp_id number,emp_name varchar(100));
CREATE OR REPLACE TYPE tbl_survey AS VARRAY(100) OF type_survey;
CREATE OR REPLACE PROCEDURE INSERTEMP (pp in tbl_survey)
IS
BEGIN
FOR I IN pp.FIRST .. pp.LAST
LOOP
INSERT INTO SURVEY (id) VALUES (pp(I).emp_id);
END LOOP;
END;
/CREATE OR REPLACE TYPE type_survey AS OBJECT ( emp_id number,emp_name varchar(100));
CREATE OR REPLACE TYPE tbl_survey AS VARRAY(100) OF type_survey;
CREATE OR REPLACE PROCEDURE APP_DATA.INSERTEMP (pp in tbl_survey,result out varchar)
IS
BEGIN
FOR I IN pp.FIRST .. pp.LAST
LOOP
INSERT INTO SURVEY (id) VALUES (pp(I).emp_id);
END LOOP;
result:='done';
END;
public static void passArray() throws SQLException
Connection conn=null;
try{
conn=getOracleConnection();//this method returns connection object
catch (Exception e)
e.printStackTrace();
String[][] val=new String[2][2];
* val[0][0]="1";*
* val[0][1]="aaa";*
* val[1][0]="2";*
* val[1][0]="bbb";*
StructDescriptor desc1=StructDescriptor.createDescriptor("TYPE_SURVEY",conn);
STRUCT p1struct1 = new STRUCT(desc1,conn,_val_); *//showing error at this line*
ArrayDescriptor arraydesc = ArrayDescriptor.createDescriptor("TBL_SURVEY",conn);
ARRAY array = new ARRAY(arraydesc,conn,*p1struct1*);
CallableStatement cstmt = conn.prepareCall("{ call INSERTEMP(?,?)}");
cstmt.setObject(1,array);
cstmt.registerOutParameter(2, OracleTypes.VARCHAR);
cstmt.execute();
String res=cstmt.getString(2);
System.out.println(res);
in the above java code, I have passed 2d array of string to STRUCT constructor and passed STRUCT object i.e. p1struct1 to ARRAY constructor. is it correct? that means @bottom line, I want to pass val array to my stored porcedure. How can i do this? above code is showing following error......
Exception in thread "main" java.sql.SQLException: Fail to convert to internal representation: [Ljava.lang.String;@146c1d4
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.oracore.OracleTypeNUMBER.toNUMBER(OracleTypeNUMBER.java:540)
at oracle.jdbc.oracore.OracleTypeNUMBER.toDatum(OracleTypeNUMBER.java:54)
at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:717)
at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:1375)
at oracle.sql.STRUCT.<init>(STRUCT.java:159)
at com.flologic.ArrayDemo.passArray(ArrayDemo.java:29)
at com.flologic.ArrayDemo.main(ArrayDemo.java:57) -
Calling Stored Procedure with parameters from a C program
Hello, I need to call a PL/SQL stored procedure from a C program.
Something like this sample program provided by Oracle -
main()
int i;
EXEC SQL BEGIN DECLARE SECTION;
*/* Define type for null-terminated strings. */*
EXEC SQL TYPE asciz IS STRING(20);
asciz username[20];
asciz password[20];
int dept_no; / which department to query */*
char emp_name[10][21];
char job[10][21];
EXEC SQL VAR emp_name is STRING (21);
EXEC SQL VAR job is STRING (21);
float salary[10];
int done_flag;
int array_size;
int num_ret; / number of rows returned */*
int SQLCODE;
EXEC SQL END DECLARE SECTION;
*/* Connect to Oracle. */*
strcpy(username, "SCOTT");
strcpy(password, "TIGER");
EXEC SQL WHENEVER SQLERROR DO sqlerror();
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("Enter department number: ");
scanf("%d", &dept_no);
fflush(stdin);
*/* Set the array size. */*
array_size = 10;
done_flag = 0;
num_ret = 0;
*/* Array fetch loop - ends when NOT FOUND becomes true. */*
EXEC SQL EXECUTE
BEGIN personnel.get_employees
*(:dept_no, :array_size, :num_ret, :done_flag,*
*:emp_name, :job, :salary);*
END;
END-EXEC;
The question is - how is the Stored procedure get_employees declared ? Or more specifically, how is the salary parameter declared in get_employees ? Any help is highly appreciated.Hope following will help
NOTE: Not tested
Calling a stored procedure
This program connects to ORACLE using the SCOTT/TIGER
account. The program declares several host arrays, then
calls a PL/SQL stored procedure (GET_EMPLOYEES in the
CALLDEMO package) that fills the table OUT parameters. The
PL/SQL procedure returns up to ASIZE values.
It keeps calling GET_EMPLOYEES, getting ASIZE arrays
each time, and printing the values, until all rows have been
retrieved. GET_EMPLOYEES sets the done_flag to indicate "no
more data."
#include <stdio.h>
#include <string.h>
EXEC SQL INCLUDE sqlca.h;
typedef char asciz[20];
typedef char vc2_arr[11];
EXEC SQL BEGIN DECLARE SECTION;
/* User-defined type for null-terminated strings */
EXEC SQL TYPE asciz IS STRING(20) REFERENCE;
/* User-defined type for a VARCHAR array element. */
EXEC SQL TYPE vc2_arr IS VARCHAR2(11) REFERENCE;
asciz username;
asciz password;
int dept_no; /* which department to query? */
vc2_arr emp_name[10]; /* array of returned names */
vc2_arr job[10];
float salary[10];
int done_flag;
int array_size;
int num_ret; /* number of rows returned */
EXEC SQL END DECLARE SECTION;
long SQLCODE;
void print_rows(); /* produces program output */
void sql_error(); /* handles unrecoverable errors */
main()
int i;
char temp_buf[32];
/* Connect to ORACLE. */
EXEC SQL WHENEVER SQLERROR DO sql_error();
strcpy(username, "scott");
strcpy(password, "tiger");
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf("\nConnected to ORACLE as user: %s\n\n", username);
printf("Enter department number: ");
gets(temp_buf);
dept_no = atoi(temp_buf);/* Print column headers. */
printf("\n\n");
printf("%-10.10s%-10.10s%s\n", "Employee", "Job", "Salary");
printf("%-10.10s%-10.10s%s\n", "--------", "---", "------");
/* Set the array size. */
array_size = 10;
done_flag = 0;
num_ret = 0;
/* Array fetch loop.
* The loop continues until the OUT parameter done_flag is set.
* Pass in the department number, and the array size--
* get names, jobs, and salaries back.
for (;;)
EXEC SQL EXECUTE
BEGIN calldemo.get_employees
(:dept_no, :array_size, :num_ret, :done_flag,
:emp_name, :job, :salary);
END;
END-EXEC;
print_rows(num_ret);
if (done_flag)
break;
/* Disconnect from the database. */
EXEC SQL COMMIT WORK RELEASE;
exit(0);
void
print_rows(n)
int n;
int i;
if (n == 0)
printf("No rows retrieved.\n");
return;
for (i = 0; i < n; i++)
printf("%10.10s%10.10s%6.2f\n",
emp_name, job[i], salary[i]);
/* Handle errors. Exit on any error. */
void
sql_error()
char msg[512];
int buf_len, msg_len;
EXEC SQL WHENEVER SQLERROR CONTINUE;
buf_len = sizeof(msg);
sqlglm(msg, &buf_len, &msg_len);
printf("\nORACLE error detected:");
printf("\n%.*s \n", msg_len, msg);
EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
Remember, the datatype of each actual parameter must be convertible to the datatype of its corresponding formal parameter. Also, before a stored procedure is exited, all OUT formal parameters must be assigned values. Otherwise, the values of corresponding actual parameters are indeterminate.
SQLCHECK=SEMANTICS is required when using an anonymous PL/SQL block. -
Execute SQL Task with Parameter - from DB2 to SQL Server
I am pulling data from DB2 to SQL Server.
1st Execute SQL task runs the following against DB2:
SELECT TIMESTAMP(CHAR(CURRENT_DATE - (DAY(CURRENT_DATE)-1) DAYS - 1 MONTH)) as START_MONTH
FROM SYSIBM.SYSDUMMY1;
I'm storing it as a Result Set.
Next I have a Data Flow Task. This pulls data from DB2 where the date matches the parameter.
FROM SCHEMA.TABLE t
WHERE DATE_TIME_COLUMN= ?
This works fine. Guessing, because the parameter source is DB2 and the Data Flow source is DB2.
The problem is, I want to remove existing data for the same date in the SQL table. IE, if I'm pulling March 2014 data from DB2, I want to be sure there is no March 2014 data in the SQL table. The main use is for re-runs.
So, I added another Execute SQL task after the first one that assigns the variable, and before the Data Flow Task. This runs the following statement against SQL Server:
DELETE FROM
database.dbo.table
WHERE DATE_TIME_FIELD >= ?
The package fails at the new Execute SQL Task with the following error message:
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "DELETE FROM
SBO.dbo.tblHE_MSP_FEE_BUCKETS
WHERE T..." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
correctly.
Task failed: Execute SQL Task
SSIS package "Load_MSP_Fee_Buckets_SQL.dtsx" finished: Success.
The program '[14240] Load_MSP_Fee_Buckets_SQL.dtsx: DTS' has exited with code 0 (0x0).
I am assuming this is something to do with the Parameter source being DB2, and trying to use against SQL?
Any suggestions on how to make this work??
Thanks,
-Al HParameter name is unrecognized
is the key, how come DB2 is related if it runs against SQL Server
What I think is happening you do not use the OLEDB connection to SQL Server.
Likewise, if it is ADO then the query needs to be
DELETE FROM
database.dbo.table
WHERE DATE_TIME_FIELD >= @MyDate
Arthur My Blog -
How to call a procedure with two arguments
Hi,
I have a procedure with two arguments, ie. myprocedure(p1 in number,p2 in number) to display a blob image.
how can I call out this blob image in url.
I tried http://127.0.0.1:7777/pls/apex/SCHEMA.myprocedure?p1=1&p2=2 , but it don't work..
Thanks
vincentVincent,
As long as you have been granted the ability to execute the procedure and there are no spaces in the url and you have not misspelled the parameter names then this looks right.
Here is a link to a procedure to download a file which takes two parameters.
http://mywebsite.com/pls/htmldev/schema.package.function.download_file?p_session_id=1221970786026206&p_seq_id=724
Cheers,
Tyson Jouglet -
How to call EJB deployed on OC4J from java stored procedure?
Hello,
I'd like to call EJB from java stored procedure. My example works fine from command line, but the problem seems to be with deployment of this code into database. Especialy I'm wondering how to reference jars like oc4jclient.jar, ejb.jar, ... from java stored procedure.
Is there some example how to do that ?
Can You help me please ?
Many thanks,
Radim Kolek,
Eurotel Prague.Hi,
You may want to check up this thread
Calling JBoss EJBs from Java stored procedure
Hope this helps,
Sujatha.
OTN Group. -
Help in calling stored procedure with parameter in JSP
I need to know how to call this stored procedure in JSP
here is my Stored procedure in oracle 9i:
CREATE OR REPLACE procedure broker_activity
(p_broker_id IN number,p_TotalValue out number,p_CrossValue out number, p_blockValue out number, p_MktWeight out number,p_BuyingVal out number, p_sellingVal out number, p_NetValue out number)
AS
begin
declare
-- buying value
cursor c_BuyingVal is select buyer_firm, sum(volume*price) value from last_sale where buyer_firm = p_broker_id group by buyer_firm;
-- selling value
cursor c_SellingVal is select seller_firm,sum(volume*price) value from last_sale where seller_firm = p_broker_id group by seller_firm;
v_BuyingCurVal c_buyingVal%rowtype;
v_SellingCurVal c_sellingVal%rowtype;
n_buy_val number :=0;
n_sell_val number :=0;
n_total_value number := 0;
begin
--buying value
open c_BuyingVal;
fetch c_BuyingVal into v_buyingCurVal;
n_buy_val := nvl(n_buy_val,0) + v_buyingCurVal.value;
--Exit when c_BuyingVal%NOTFOUND;
close c_buyingVal;
p_BuyingVal := n_buy_val;
--selling value
open c_SellingVal;
fetch c_SellingVal into v_SellingCurVal;
n_sell_val := nvl(n_sell_val,0) + v_SellingCurVal.value;
-- Exit when c_BuyingFirm%NOTFOUND;
close c_SellingVal;
p_SellingVal := n_sell_val;
--total value
p_TotalValue := n_buy_val + n_sell_val;
--cross val
select sum(volume*price) into p_CrossValue from last_sale where board = 'C' and (buyer_firm = p_broker_id or seller_firm = p_broker_id);
--block Sale
select sum(volume*price) into p_BlockValue from last_sale where board = 'B' and (buyer_firm = p_broker_id or seller_firm = p_broker_id);
--Net Value
p_NetValue := n_buy_val - n_sell_val;
--markte_weight
select (sum(volume*price) * 2)/100 into p_MktWeight from last_sale ;
end;
end;http://developer.java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
-
How to call form and pass parameter from OA Page
Hi,
I have one requirement to call a custom form from OA page by clicking the button and the same time i need to pass one parameter from this
oa page to that form.
how to do this by personalization?
i surfed lot and i got some idea, some one said "pass the value as global variable and receive the global parameter when the new form instance trigger" .
Can anyone please give about about this ?
Thanks in advance,
SANThis seems to be related to EBS and since this forum is dedicated to Fusion you might want to post the question to E-Business Suite forums and
Support forum for EBS customizations.
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/ -
How to execute a procedure or function from Java Stored procedure
Hi,
I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?
Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.
Thanks in advance.
PS. The variable passed in function is just a dummy variable.
-----Begin Java code-------
import java.sql.SQLException;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.ResultSet;
//Oracle Extensions to JDBC
import oracle.jdbc.driver.OracleDriver;
public class Test2{
public static String Testing(String d) {
Connection connection = null; // Database connection object
try {
// Get a Default Database Connection using Server Side JDBC Driver.
// Note : This class will be loaded on the Database Server and hence use a
// Se[i]Long postings are being truncated to ~1 kB at this time.what your after is
Connection conn = DriverManager.getConnection
("jdbc:oracle:oci:@<hoststring>", "scott", "tiger");
CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;");
cs.registerOutParameter(1,Types.CHAR);
cs.setString(2, "aa");
cs.executeUpdate();
String result = cs.getString(1);
a more complete description can be found in the documentation at
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1001934
Dom -
Calling stored procedures in Sybase from java
Hi,
I am using the following stored procedure in Sybase
use xyzdb
go
-- drop procedure if it already exist
if object_id('up_name_select') is not null
begin
drop procedure up_name_select
end
go
create procedure up_name_select
@zid numeric(7,0),
@firstname char(40),
@lastname char(40)
as
select zid,
firstname,
lastname
from name
where zid = @zid or
(lastname like @lastname or firstname like @firstname)
go
-- update documentation records in object_docs
delete object_docs
from object_docs
where object_name = "up_name_select"
go
insert into object_docs values("up_name_select","Selects records from the name table based upon the values of the input parameters.")
go
-- update documentation records in column_docs
delete column_docs
from column_docs
where object_name = "up_name_select"
go
insert into column_docs values("up_name_select","@zid","System generated ID for an individual contact.")
insert into column_docs values("up_name_select","@firstname","First name of the contact. SQL wild card characters are accepted.")
insert into column_docs values("up_name_select","@lastname","Last name of the contact. SQL wild card characters are accepted.")
go
-- print success message and grant permissions
if object_id('up_name_select') is not null
begin
print "Procedure up_name_select created."
grant execute on up_name_select to developer_role
end
go
This stored procedure selects the values from the table "name" for a given where condition (if I am not wrong).
Can any one give me sample java code to select the records from the table "name" for a given zid.
Thankyou in advance.
Regards
sgatl2calling stored procedures from java
here is the sample code
CallableStatement cs = con.prepareCall("{call selectlogin (?)}");
cs.setString (1, "value");
ResultSet rs = cs.executeQuery ();
while (rs.next ())
//your code for display
} more on gooooooogle
http://www.google.com/search?q=calling+stored+procedures+from+java+with+sample+example&client=netscape-pp&rls=com.netscape:en-US
Maybe you are looking for
-
My computer wont let me open itunes
it's been about 2 weeks were i can't open my itunes library every time i try to open it a thing pops up that says iTunes.exe-Bad Image and it says 'The application or DLL C:\Program Files\common Files\Apple\Apple Application Support \Video Toolbox.dl
-
How can I use photos in FCEHD?
How can I use photos in FCEHD? (I'm new to the thing - done just one video project so far). When I imported photos from Aperture (first into the folder on desktop, and then from desktop to the Browser in FCEHD3.5, the photos have a black bar/a gray s
-
Calling packaged stored procedure from php fails
The following php fails with:- Warning: ociexecute() [function.ociexecute]: OCIStmtExecute: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'SPMEMBERDETAILS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
-
Lots of Clean/Expire, few Connection threads
My application is talking to lots of RMI Servers. I think I am either holding onto some remote refernces... or I'm "churning" through a bunch real fast. Its a rather large application and these remote references could be... in many many different pla
-
I've searched for script or functions to create a log file from a script I run each night. The main script just sets variables and then calls other scripts (18 of them). The last script sends me an email with various information and at times I've f