Execute a stored procedure from a JSP.(Help...)
How can I execute a stored procedure from a JSP.
Wich tags I need to use ???
I'm using the oracle thin JDBC.
please help me.
null
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Mario Bellido ([email protected]):
How can I execute a stored procedure from a JSP.
Wich tags I need to use ???
I'm using the oracle thin JDBC.
please help me.<HR></BLOCKQUOTE>
I just try a simple call with a data tag just like this (see category.jsp in the onlineorder example provided with Jdev 3.2.3):
<!-- Tutorial - ApplicationModule Tag -->
<%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
<jbo:ApplicationModule configname="OnlineOrders.OnlineOrdersModule.LocalConfig" id="OnlineOrdersModule" username="BC4J" password="BC4J" />
<!-- Tutorial - DataSource Tag -->
<jbo:DataSource id="category" appid="OnlineOrdersModule" viewobject="CategoryView" ></jbo:DataSource>
<jbo:ExecuteSQL appid="OnlineOrdersModule" >
insert into tablejsp values ('testtable')
</jbo:ExecuteSQL>
<jbo:ExecuteSQL appid="OnlineOrdersModule" >
call testjsp()
</jbo:ExecuteSQL>
<jbo:Commit appid="OnlineOrdersModule" />
testjsp is a stored PL/SQL procedure without arguments.
null
Similar Messages
-
Error while executing a stored procedure from forms6i
When I execute a STORED PROCEDURE from ORACLE DB 10g this procedure works perfectly fine.
But when I execute the same from the FORMs 6i I get the following error:
PDE-PLU022 Don't have access to the stored program unit
XMLPARSERCOVER in schema CARE.
where XMLPARSERCOVER is the class and
CARE is the schema.
Regards,
Jignesh SI have tried this with both the owner of the schema and the intended user, -from both forms and directly.
All rights was granted on the stored procedure. Since posting I have found that one of the tables that the procedure might insert into, was not explicitly granted to the intended user, and after rectifying that the error message went away.
-however, the procedure now silently "finishes" without any evidence that it ever ran, if invoked from the forms application. When invoked from SQL Plus (or JDev, or Toad) it runs as expected.
I have no public synonym for the procedure, -is that necessary?
The stored procedure in question is implemented in java, and published as a stored procedure. It does rather heavy lifting, when running, using a view against another server , updating local tables and quite a lot of data validation/cleansing, and logging. All recourses are within the same schema.
Any ideas? -
Error ORA-04031 while executing a stored procedure from Pro C++ code
I am getting the error ORA-04031(Unable to allocate 4096 bytes of shared memory("Shared Pool",.....)) while trying to execute a stored procedure from my pro*C application. This happens only after a few hours since the application has been running. I am closing the cursor after every database call.
Does anyone know why it is happening and any possible solutions?
TIA
Srithaj.One thing that can be done is to flush the shared pool before starting the application.
alter system flush shared pool;
Another is to increase the shared pool size by setting the parameter shared_pool_size in init_sid.ora file.
null -
Calling Oracle Stored Procedure from BC4J JSP App
I am on an extremely tight deadline and am trying to get my JSP application to use an Oracle Stored Procedure. I need to take some input from the user and send these values as parameters. Has anyone worked with Stored Procedures in JDev3.1? Please reply with some sample code if possible.
Thanks.Hi,
Someone posted a similar request the other day. Here is my response to them:
Basically, you need to create a custom method from your JSP's ViewObject, which calls the stored procedure. You can then call the ViewObject's custom method from the JSP client.
Here is how I have done it:
1. Choose the ViewObject that your JSP is based on and choose 'Edit' from the context menu.
2. On the Java tab of the ViewObject wizard, choose Generate Java File checkbox for the View Object Class and click the Finish button. A file is created under the ViewObject node in the Navigator named 'viewobjectImpl.java'.
3. Open the viewobjectImpl.java file in the code editor and create a method to call your stored procedure (see sample code below).
4. Compile the VOImpl.java file.
5. Choose the view object again, and choose Edit again from the context menu.
6. On the Client Methods tab, you should now see your method appear in the Available field. Select it and shuttle it to the Selected field.
7. Click Finish to leave the VO wizard, and rebuild your Business Components project.
8. In your JSP, call the custom method (see sample code below).
sample code for custom method calling a stored procedure from VOImpl.java file:
public int getTotalHits(String mon, String year) {
CallableStatement stmt = null;
int total;
// the call to the PL/SQL stored proc
String totalhits = "{? = call walkthru.total_hits(?,?)}";
// use the AM conxn 2 call storedproc
stmt = getDBTransaction().createCallableStatement(totalhits, 1);
try
// Bind the Statement Parameters and //Execute this Statement
stmt.registerOutParameter(1,Types.INTEGER);
stmt.setString(2,mon); stmt.setString(3,year);
stmt.execute();
total = stmt.getInt(1);
catch (Exception ex)
throw new oracle.jbo.JboException(ex);
finally
try
stmt.close();
catch (Exception nex)
return total;
sample render code for calling custom method from JSP custom bean:
public void render() {
int totalhits;
try
Row[] rows;
// Retrieve all records by default, the qView variable is defined in the base class
qView.setRangeSize(-1);
qView.first();
rows = qView.getAllRowsInRange();
// instantiate a view object for our exported method
// and call the stored procedure to get the total
ViewObject vo = qView.getViewObject();
wtQueryView theView = (wtQueryView) vo;
totalhits = theView.getTotalHits(session.getValue("m").toString(),session.getValue("y").toString());
out.println(totalhits);
} catch(Exception ex)
throw new RuntimeException(ex.getMessage());
} -
Execute oracle stored procedure from C# always returns null
Hi,
I'm trying to execute a stored procedure on oracle 9i. I'm using .Net OracleClient provider.
Apparently, I can execute the stored procedure, but it always returns null as a result (actually all the sp's I have there returns null)! I can execute any text statement against the database successfully, and also I can execute the stored procedure using Toad.
This is not the first time for me to call an oracle stored procedure, but this really is giving me a hard time! Can anyone help please?
Below are the SP, and the code used from .Net to call it, if that can help.
Oracle SP:
CREATE OR REPLACE PROCEDURE APIECARE.CHECK_EXISTENCE(l_number IN NUMBER) AS
v_status VARCHAR2(5) := NULL;
BEGIN
BEGIN
SELECT CHECK_NO_EXISTENCE(to_char(l_number))
INTO v_status
FROM DUAL;
EXCEPTION WHEN OTHERS THEN
v_status := NULL;
END;
DBMS_OUTPUT.PUT_LINE(v_status);
END CHECK_CONTRNO_EXISTENCE;
C# Code:
string connStr = "Data Source=datasource;Persist Security Info=True;User ID=user;Password=pass;Unicode=True";
OracleConnection conn = new OracleConnection(connStr);
OracleParameter param1 = new OracleParameter();
param1.ParameterName = "v_status";
param1.OracleType = OracleType.VarChar;
param1.Size = 5;
param1.Direction = ParameterDirection.Input;
OracleParameter param2 = new OracleParameter();
param2.ParameterName = "l_number";
param2.OracleType = OracleType.Number;
param2.Direction = ParameterDirection.Input;
param2.Value = 006550249;
OracleParameter[] oraParams = new OracleParameter[] { param1, param2 };
OracleCommand cmd = new OracleCommand("CHECK_EXISTENCE", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(oraParams);
conn.Open();
object result = cmd.ExecuteScalar();
conn.Close();Hi,
Does that actually execute? You're passing two parameters to a procedure that only takews 1 and get no error?
Your stored procedure doesnt return anything and has no output parameters, what are you expecting to be returned exactly?
If you're trying to access V_STATUS you'll need to declare that as either an output parameter of the procedure, or return value of the function, and also access it via accessing Param.Value, not as the result of ExecuteScalar.
See if this helps.
Cheers,
Greg
create or replace function myfunc(myinvar in varchar2, myoutvar out varchar2) return varchar2
is
retval varchar2(50);
begin
myoutvar := myinvar;
retval := 'the return value';
return retval;
end;
using System;
using System.Data;
using Oracle.DataAccess.Client;
public class odpfuncparams
public static void Main()
OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl");
con.Open();
OracleCommand cmd = new OracleCommand("myfunc", con);
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter retval = new OracleParameter("retval",OracleDbType.Varchar2,50);
retval.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(retval);
OracleParameter inval = new OracleParameter("inval",OracleDbType.Varchar2);
inval.Direction = ParameterDirection.Input;
inval.Value="hello world";
cmd.Parameters.Add(inval);
OracleParameter outval = new OracleParameter("outval",OracleDbType.Varchar2,50);
outval.Direction = ParameterDirection.Output;
cmd.Parameters.Add(outval);
cmd.ExecuteNonQuery();
Console.WriteLine("return value is {0}, out value is {1}",retval.Value,outval.Value);
con.Close();
} -
Execute Oracle Stored Procedure from Excel
Is it possible to execute an Oracle Stored Procedure from Microsoft Excel and return the result of the Oracle Store Procedure into the excel spreadsheet.
Yes. You can use Oracle Objects for OLE to accomplish this. It comes with Excel examples and an online help file with many more examples.
-
Incorrect Update Count by executing a stored procedure from Java
Hi Guys,
I am calling a stored procedure from the java program which is modifying the rows of a table. Now I want to know how many rows have been modified by executing the stored procedure. I am writing the following code for the purpose:
OracleCallableStatement stmt =
(oracle.jdbc.driver.OracleCallableStatement)con.prepareCall("{callsp_um_setForumID(?,?)}");
stmt.setInt(1,101);
stmt.setInt(2,666);
n = stmt.executeUpdate();
System.out.println(n + " row(s) updated");
This procedure is actually modifying the table(When I query the databse it has modified 1 row). But it is returning a value 0 and is printing "0 row(s) updated".
Is there a way by which I can find out the number of rows updated by executing the stored procedure?
Thanks
Sachin
[email protected]I'm no expert on this, but I have a similar call where I fetch
an Oracle REF CURSOR from a call to a stored function. If you
fetch the cursor as an Object from your CallableStatement, you
can then cast it to a ResultSet e.g.
mystatement.executeUpdate();
ResultSet rs = (ResultSet) mystatement.getObject(1);
Then you should be able to loop through your ResultSet as usual.
Good luck!
Chris -
Executing a stored procedure from an Ifs Program
I have a need to execute a stored procedure in another schema
within the same database, and I need to receive an OUT parameter
to continue processing. The oracle.ifs.server.sql.IfsConnection
is not in my class path. Can someone tell me which jar file to
adde to my classpath to have this funcitonality that IFS claim.
Regards,
JeffGuys I need help with this one as soon as possible.
-
Executing a stored procedure from a java program
Hi.. how can i call a oracle stored procedure from a java
program. the OSP has four IN parameters and one OUT parameter(a
cursor). when i try this way.. i get an error
con = DriverManager.getConnection(url, "stored", "stored");
CallableStatement cs =
con.prepareCall(
"{call stored_proce_1(?,?,?,?,?)}");
cs.registerOutParameter(1, OracleTypes.CURSOR);
cs.setString(2, "14541");
cs.setString(3, "gen");
cs.setInt(4, 0);
cs.setInt(5, 5);
ResultSet rs =cs.getResultSet();
while(rs.next()){
System.out.println(rs);
appreciate ur help.
qsI'm no expert on this, but I have a similar call where I fetch
an Oracle REF CURSOR from a call to a stored function. If you
fetch the cursor as an Object from your CallableStatement, you
can then cast it to a ResultSet e.g.
mystatement.executeUpdate();
ResultSet rs = (ResultSet) mystatement.getObject(1);
Then you should be able to loop through your ResultSet as usual.
Good luck!
Chris -
Execute APEX stored procedure from outside APEX
I am looking at developing an application in APEX, but there needs to be a batch component that I would like to call from our corporation's scheduler. Is there a way for me to call an APEX stored procedure from a 3rd party scheduling software?
We use this method on all other oracle databases here, but are new to using APEX.
Thank you,
TrevorThis applicaiton is for the internal administration of an External database.
So there is an external web application that will have a user sign in, and request some transactions. These requests need to be brought inside our firewall to the APEX tables, where our admin staff will access the requests via this internal administrative applicaiton. It will tie into our Customer Information System, giving our staff all the data they need in one application. Requested transactions, and customer information. Once processed, the status of each transaction will be pushed back out to the external database for our customers to view.
The transfer of data, along with some other logic, is written in PL/SQL stored procs. To keep within our devlopement guidleines, I would like to kick them off using our existing scheduler. That way I only have one internal database to worry about. -
Error while executing java stored procedure from a pl/sql procedure
We have a requirement where we need to execute JAVA code stored in an Oracle database (Java Stored Procedure). This code uses some JAR files which we have already loaded without any errors in the database.
The class file was also loaded in the database without any errors. But when we execute the method of this class (JAVA code), it gives the following error:
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NoClassDefFoundError
Is there any way of debugging the code and getting to know where exactly the problem is? Or, any tool/software available for doing the same.
Any pointers would be of great help!
Thanks in advanceHi Uday,
My guess is that there is a problem with your java stored procedure that is causing the "ExceptionInInitializer" error to be thrown. According to the javadoc:
is thrown to indicate that an exception occurred during
evaluation of a static initializer or
the initializer for a static variable
Since I didn't see any of your code in your post, I can't help you much more, I'm afraid. Perhaps if you would provide some more details, I may be able to help you some more. I think the following details would be helpful:
1. Complete error message and stack trace you are getting.
2. The section of your java code that you think is causing the problem.
3. Oracle database version you are using.
Good Luck,
Avi. -
Error executing a stored procedure from SSIS using the MERGE statement between databases
Good morning,
I'm trying to execute from SSIS a stored procedure that compares the content of two tables on different databases in the same server and updates one of them. To perform this action, I've created a stored procedure in the destination database and I'm
comparing the data between tables with the MERGE statement. When I execute the procedure on the destination database the error that I obtain is:
"Msg 916, Level 14, State 1, Procedure RefreshDestinationTable, Line 13
The server principal "XXXX" is not able to access the database "XXXX" under the current security context."
Some things to take in account:
1. I've created a temporary table on the same destination database to check if the problem was on the MERGE statement and it works fine.
2. I've created the procedure with the option "WITH EXECUTE AS DBO".
I've read that it can be a problem of permissions but I don't know if I'm executing the procedure from SSIS to which user/login I should give permissions and which.
Could you give me some tip to continue investigating how to solve the problem?
Thank you,
VirgilioRead Erland's article http://www.sommarskog.se/grantperm.html
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How to execute an stored procedure from the Report Region
Have stored procedure "LER_KRONOS_PAYCODE_HOURS_P" compiled and ready.
(previously tested)
Region Source:
DECLARE
v_SITE_ID VARCHAR2(8);
v_SDATE VARCHAR2(8);
v_EDATE VARCHAR2(8);
v_LEVEL3 VARCHAR2(60);
BEGIN
v_SITE_ID :=P4_SITES_LOV;
v_SDATE :=P4_SDATE;
v_EDATE :=P4_SEDATE;
v_LEVEL3 :=P4_LEVEL3;
EXECUTE LER_KRONOS_PAYCODE_HOURS_P(v_SITE_ID,v_SDATE,v_EDATE,v_LEVEL3);
END;
Error When run the page:
ORA-06550: line 11, column 12: PLS-00103: Encountered the symbol "LER_KRONOS_PAYCODE_HOURS_P" when expecting one of the following: := . ( @ % ; immediate The symbol ":=" was substituted for "LER_KRONOS_PAYCODE_HOURS_P" to continue.You need the execute keyword only when you run it directly from sqlplus.. that will tell sqlplus to append the keyword begin and end after the procedure call.
Example.
SQL > exec proc1 (input1);
will tell sqlplus to run it as a block.. saying
sql> Begin
proc1(input1);
end;Inside the procedure , in your code, you dont need the execute keyword.
But, why do you want to execute a procedure inside the source for a report region..? -
How to call a stored procedure from my JSP?
Hi to all,
I have a very simple jsp page and a simple sql server stored procedure!
I need to call this stored procedure by passing two parameters.
My result set will have 4 columns.
I would really appreciate any input on how to issue this call to a SP.
I am new to JSP.
Regards,
Sam
Sam,
BEA provides examples that are shipped with the product under
<beahome>\weblogic700\samples\server\src\examples\
Look at the jsp directory for JSP examples that access a database and look at
say the jdbc\oracle\storedprocs.java for an example of java code calling out to
a stored procedure - - by combining one of the jsp database examples with this
stored procedure example you should be 'good to go'
Chuck Nelson
DRE
BEA Technical Support
-
How to invoke a stored procedure from SubmitEditForm.jsp
Instead of directly inserting or updating
the data I would like to invoked
the stored procedure.
Has anybody done this?Sam,
BEA provides examples that are shipped with the product under
<beahome>\weblogic700\samples\server\src\examples\
Look at the jsp directory for JSP examples that access a database and look at
say the jdbc\oracle\storedprocs.java for an example of java code calling out to
a stored procedure - - by combining one of the jsp database examples with this
stored procedure example you should be 'good to go'
Chuck Nelson
DRE
BEA Technical Support
Maybe you are looking for
-
Read-only Collaborator can edit Contract Document properties
We have a master agreement with a read-only collaborator. The security profile for this collaborator role is identical to the stock "Document Reviewer" profile, i.e. only View is set. However this supposedly read-only collaborator is able to edit Con
-
Have 2 Win 8 machines, running Firefox 25 and one lap top with Win 7. All three are using Mcafee Security Suite ver 12.8 with Anti Virus 16.8. The subscription runs out in February 2014. I would like to make a change and am concerned about compatibil
-
How to prevent session getting killed
Hi All, I am trying to execute a procedure which contains a long running query . The query takes so much time to execute that the session gets killed . Can anybody please let me know what should I do to prevent my session being killed/ Is there any p
-
Badi or user exit for Cash Journal
Dear friends, As I am not able to post a special GL transaction through cash journal, i request you to help me for a badi or user exit which may be available for cash journal. Regards Dhirav shah
-
How to achieve perfect 100% web view
Hi all, We are a web design agency, and we prepare many of our web designs in Photoshop, and then export to PDF for clients to view the designs. Ever since (I think it was) version 7, we seem to have a very, very hard time getting our PDFs to present