Error when calling a stored procedure from a SQL Script
Apologies if this is a really dumb question but I can't seem to call a procedure in package from a SQL script. I have a simple package.procedure containing a loop to populate a table. I would like to include a call to this procedure from my database install script, that also includes my CREATE and INSERT statements. I run the script using "@install_databae" and the CREATE and INSERT statements run fine. The script gives an error when it reaches the line below:
exec lazarus.PopulateGridPositions;
and gives the error.....
BEGIN lazarus.PopulateGridPositions; END;
ERROR at line 1:
ORA-04063: package body "LAZARUS.LAZARUS" has errors
ORA-06508: PL/SQL: could not find program unit being called: "LAZARUS.LAZARUS"
ORA-06512: at line 1
The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.
I've obviously missed some fundamental concept with scripts and SQL. Please can anybody help me?
Histon FTM wrote:
ORA-04063: package body "LAZARUS.LAZARUS" has errors Above, obviously conflicts with the statement that follows:
>
The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.I suggest you take a look in the USER_ERRORS view to see, what the errors are.
And just checking:
You have schema called LAZARUS, which holds a package named LAZARUS, which holds a procedure called POPULATEGRIDPOSITIONS?
Edited by: Toon Koppelaars on Oct 1, 2009 5:55 PM
Similar Messages
-
ORA-03115 error when calling a Stored Procedure
Hi All,
I'm in the process of porting a Pro/C app from NT to Linux. I've installed 8.1.5 on our Linux box and patched it up to 8.1.5.02.
It all kind of works ok, except that I'm sometimes getting ORA-03115 errors when the app calls a stored procedure. The call in question looks like this:
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR resprows[50][3998];
int numret = 0;
int numrows= 50;
int done= 0;
unsigned long resp_id = 0;
EXEC SQL END DECLARE SECTION;
EXEC SQL AT DB_NAME EXECUTE
BEGIN pkg_something.getdata(
:resp_id, /* IN */
:numrows, /* IN */
:done, /* OUT */
:resprows, /* OUT */
:numret /* OUT */
END;
END-EXEC;
The stored procedure basically uses the resp_id value to select rows from a table;
in each row there is a VARCHAR2(4000) column which it copies into the hostarray resprows.
There may be anything from 1 to numrows returned from the SP.
Initially, the resprows rows were defined to be size [4000]. Unfortunately, this caused ORA-02005 errors - I then changed the size to [3998], which seemed to fix the 02005's (although I'm unclear as to the reasons why).
Now I'm getting the 03115 errors when calling the SP. The oracle manual is not very helpful on what this error means.
This all works chipper on NT.
Any ideas?
Thanks in advance,
Nigel.
PS: The database the app is talking to is still hosted on NT.
nullHiston FTM wrote:
ORA-04063: package body "LAZARUS.LAZARUS" has errors Above, obviously conflicts with the statement that follows:
>
The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.I suggest you take a look in the USER_ERRORS view to see, what the errors are.
And just checking:
You have schema called LAZARUS, which holds a package named LAZARUS, which holds a procedure called POPULATEGRIDPOSITIONS?
Edited by: Toon Koppelaars on Oct 1, 2009 5:55 PM -
No method found error when calling java stored procedured
hi:
i am rather confused about this. i have written several
java stored procedures and all of them work fine. but when i tried another one , the error message 'no method found 'occurs
when i call the procedure from sqlplus.
it' s a simple procedure . but it's very strange and happens
from time to time
my compile shell as following
javac -classpath $ORACLE_HOME/jdbc/lib/classes12.zip GenFiles.java
$ORACLE_HOME/bin/loadjava -u zw/zw@aixtest GenFiles.class
and
my definition as following
create or replace procedure files(chargeCyckeID varchar2, cycleStart varchar2,cycleEnd varchar2,
loginName varchar2, filePath varchar2, start1 number, end1 number, step number)
AS LANGUAGE JAVA
NAME 'GenFiles.genFile(String , String , String , String , String , int , int , int )';
and my java code is here :
import java.sql.*;
import java.io.*;
import oracle.jdbc.driver.*;
public class GenFiles{
public static void main(String[] args){
04UU<F7QV\FZ#,V\FZ?*J<#,V\FZ=aJx#,5GB<C{#, ND<~B7>6#,Pr:E?*J<#,Pr:E=aJx#,2=3$#(Iz3IND<~5D<GB<J}#)
public static void genFile(String chargeCycleID, String cycleStart, String cycleEnd, String loginName, String filePath, int start, int end, int step){
try{
String sqllist = "select customer_id,contract_code, usercode,ani,ord,"
+ " agent_code,linkman, customer_name , postcode,paymethod_category_id ,"
+ " ltrim(to_char(cost,'999999990.99')) cost,call_duration,from listani_file where ord> ? and ord<? order by contract_code";
String sqlcalls1 = "select a.ani || ',' || a.PASS || ',' || to_char(a.START_TIME,'yyyy-mm-dd hh24:mi:ss') stime || ',' || trunc(a.CALL_DURATION/60)||':'||ltrim(to_char(mod(a.CALL_DURATION,60),'09')) CALL_DURATION || ',' || ltrim(to_char((CALL_AMOUNT/ceil(CALL_DURATION/60)),'999999990.99')) RATE || ',' || ltrim(to_char(a.CALL_AMOUNT,'999999990.99')) CALL_AMOUNT"
+" from call_fact_mind a "
+" where a.usercode=?"
+ " and a.ani=? "
+ " and a.period_key<='" + end + "'"
+ " and a.period_key>='" + start + "'"
+ " and a.charge_flag='Y' "
+ " and a.CALL_DURATION>6"
+ " and a.CALL_AMOUNT>0"
+" order by a.period_key";
String sqlcalls2 = "select a.ani || ',' || a.PASS || ',' || to_char(a.START_TIME,'yyyy-mm-dd hh24:mi:ss') stime || ',' || trunc(a.CALL_DURATION/60)||':'||ltrim(to_char(mod(a.CALL_DURATION,60),'09')) CALL_DURATION || ',' || ltrim(to_char((CALL_AMOUNT/ceil(CALL_DURATION/60)),'999999990.99')) RATE || ',' || ltrim(to_char(a.CALL_AMOUNT,'999999990.99')) CALL_AMOUNT "
+ " from call_fact_mind a "
+ " where a.usercode=?"
+ " and a.period_key<='" + end + "'"
+ " and a.period_key>='" + start + "'"
+ " and a.charge_flag='Y' "
+ " and a.CALL_DURATION>6"
+ " and a.CALL_AMOUNT>0"
+" order by a.period_key";
Connection con = new OracleDriver().defaultConnection();
try{
int i = start;
//8y>]2=3$Q-;7
while( true){
if( i>=end ) break;
genFile(con, i , i+step, chargeCycleID, loginName, filePath, sqllist, sqlcalls1, sqlcalls2);
i += step;
}catch(Exception ex){
}finally{
if( con != null) con.close();
}catch(Exception exx){}
8y>]2=3$Iz3IND<~
private static void genFile(Connection con, int start, int end, String chargeCycleID, String loginName, String filePath, String sqllist, String sqlcalls1, String sqlcalls2) throws Exception{
PreparedStatement ps1 = null;
PreparedStatement ps2 = null;
PreparedStatement ps3 = null;
ResultSet rs1 = null;
ResultSet rs2 = null;
String fileName = filePath + System.getProperty("file.separator") + start + "_" + end + ".txt";
BufferedWriter writer = null;
try{
writer = new BufferedWriter(new FileWriter(fileName));
ps1 = con.prepareStatement(sqllist);
ps2 = con.prepareStatement(sqlcalls1);
ps3 = con.prepareStatement(sqlcalls2);
ps1.setInt(1, start);
ps1.setInt(2, end);
rs1 = ps1.executeQuery();
//Iz3Ibuffer,V;SPR;6(<GB<J12EP4HkND<~
StringBuffer strBuffer = new StringBuffer();
int i =0;
//Q-;7:OM,=a9{</
String preContractCode = "";
String currentContractCode = "";
while( rs1.next()){
currentContractCode = rs1.getString("contract_code");
if( rs1.getString("ani") == null){
ps2.setString( 1, rs1.getString("usercode"));
rs2 = ps2.executeQuery();
}else{
ps1.setString(1, rs1.getString("usercode"));
ps1.setString(2, rs1.getString("ani"));
rs2 = ps1.executeQuery();
//Hg9{3vOVPB5D:OM,:E#,<SHk:OM,OnM7,contract_costJG:OM,On7QSC
if( ! preContractCode.equals(currentContractCode)){
//TZG0Cf<SHk?UPP
strBuffer.append("\r\n");
String contractHead = "\"1\"" + ",\"" + rs1.getString("linkman") + "\",\"" + rs1.getString("customer_name")
+ "\",\"" + rs1.getString("contract_code") + "\",\"" + rs1.getString("agent_code")
+ "\",\"" + chargeCycleID + "\",\"" + rs1.getString("contract_cost") + "\"";
strBuffer.append(contractHead);
while( rs2.next()){
if( i<1000){
i++;
strBuffer.append("\"2\"" + rs2.getString(1));
}else{
String str = strBuffer.toString();
writer.write(str, 0, str.length());
strBuffer = new StringBuffer();
strBuffer.append(rs2.getString(1));
i = 1;
//<SHk7QSC:O<F
if( rs1.getString("ani") == null){
String trail = "\"2\"" + ",\"" + "ani: " + "\",\"" + rs1.getString("ani") + "\",\"" + "Total Amount: " + "\",\"" + rs1.getString("cost") + "\"\r\n";
strBuffer.append(trail);
}else{
String trail = "\"2\"" + ",\"" + "usercode: " + "\",\"" + rs1.getString("usercode") + "\",\"" + "Total Amount: " + "\",\"" + rs1.getString("cost") + "\"\r\n";
strBuffer.append(trail);
preContractCode = currentContractCode;
writer.close();
rs2.close();
}catch(Exception ex){
}finally{
if( rs1 != null) rs1.close();
if( rs2 != null) rs2.close();
if( ps1 != null) ps1.close();
if( ps2 != null) ps2.close();
i need your help!
regards
daniel wangHi again, Daniel,
I'm only guessing here, but unless you've made lots of mistakes when
you copied your code to your post to the forum, your method signatures
don't match. The definition of "genFile" in your java class is quite
different to what you wrote in your PL/SQL wrapper.
Also, you have defined "genFile" to be a private method -- I think it
needs to be public.
Also, I think the "main" method doesn't need to be in the "GenFiles"
class -- perhaps you should remove it.
Also, I think in your PL/SQL wrapper you need to use fully qualified
names, so use "java.lang.String" and not just "String".
Lastly, I think you should use the "-force" and "-resolve" flags
with the "loadjava" command.
Good Luck,
Avi. -
ODBC 8.1.7 Error when calling a stored procedure that owned by an other user
I am testing my application VB for certified to use the
Client 8 with ODBC Driver 8.1.7.0 , because today this application
have been working with Client 7 and ODBC driver 7.3 version 2.5.
But i have some surprises:
Set qy = con.CreateQuery("", "{CALL OFS.INSERT_DEPT (?,?,?)}")
OFS is the owner of the proc
(other combinations {BEGIN ...;END;} also doesn't work, except the owner executes the stmt)
qy(0) = "6"
qy(1) = "ABCDEF"
qy(2) = "L88"
at this point it gives an VB error:
40041 Object Collection: Couldn't find item indicated by text.
PS: With previous ODBC Driver 7.3 v2.5 this error doesn4t occur.
I have the rights to execute the procedure
GRANT EXECUTE ON OFS.DEPT TO OFS_USERS;
Is there any other way to get this procedure work? Its a BUG ?
My Procedure:
create or replace procedure INSERT_DEPT(
in_deptno in number,
in_dname in varchar2,
in_loc in varchar2)
is
begin
insert into dept(deptno, dname, loc)
values(in_deptno, in_dname, in_loc);
end;
show errors;
GRANT EXECUTE ON OFS.INSERT_DEPT TO OFS_USERS;
Environment:
Client:
VB 5.0 SP3 (using RDO 2.0)
NT 4.0 SP6
Oracle8i Client 8.1.7.0.0
Oracle ODBC Driver 8.1.7.0.0
PS: This error already occured with Oracle ODBC Driver 8.1.7.7.0
Server:
Oracle8i Enterprise Edition Release 8.1.7.4.1
Win 2000 SP2
Thanks in advance.I have no problem executing that statement from ODBCTest on my machine
Client:
Win2k,
Oracle ODBC driver 8.1.7.7
Oracle client 8.1.7.0
Server:
Oracle 8.1.7.0
First, can you try replacing the ?'s with explicit parameters? I can't imagine that an error binding the variables would cause an error like this, but I'd just like to rule it out.
Second, can you grab the ODBC SDK from Microsoft <http://www.microsoft.com/data> if you haven't already and try that statement from within the ODBCTest sample application? If that works for you, then there must be something in the layers between your application and the ODBC driver which are confusing things. Which API are you actually using from VB? I'm guessing ADO, but I'd like confirmation on that.
Third, did you set any parameters to non-default values when you configured your DSN? I left everything as-is on my machine, so I'll try to replicate any changes you might have made to see if that changes anything.
Finally, can you post the connection string you're using?
Justin -
Calling stored procedure from embedded sql
I'm trying to call a stored procedure from embedded sql. I'm following the examples located in
http://download.oracle.com/docs/cd/B19306_01/appdev.102/a96109/pco06pls.htm#i9641
I have the following section in my .pco file before precompiling.
exec sql execute
begin
docs.grant_access_to_all_categories(:p_sam_id);
end;
end-exec.
When running procob on the file with the above code I get the following error.
Error at line 225, column 13 in file pco\docs_stored_procedures.pco
exec sql execute
............1
PCB-S-00576, PLS-201: identifier 'DOCS.GRANT_ACCESS_TO_ALL_CATEGORIES' must be d
eclared
Error at line 225, column 13 in file pco\docs_stored_procedures.pco
exec sql execute
............1
PCB-S-00576, PLS-0: Statement ignored
Any ideas on what I am doing wrong on calling this stored procedure.I get the same error when trying to precompile sample11.pco from the demo directory in the oracle client software.
Error at line 70, column 12 in file sample11.pco
EXEC SQL EXECUTE
...........1
PCB-S-00576, PLS-201: identifier 'EMP_DEMO_PKG.OPEN_CUR' must be declared
Error at line 70, column 12 in file sample11.pco
EXEC SQL EXECUTE
...........1
PCB-S-00576, PLS-0: Statement ignored -
Calling stored procedure from unix shell script
Hello,
I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
Here is the code-
#!/bin/sh
OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
set serveroutput on;
var prd_out varchar2(100);
exec create_pm_window(:prd_out);
exit;
ENDOFSQL`
echo " output is - $OUTPUT"
The problem is :prd_out is not getting copied to shell variable OUTPUT.
I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
Any help is really appreciated.
Thanks'
RakheeFirst step :
make sure the PL/SQL works as expected.
Does the following display the expected output executed from SQL*Plus ?
set serverout on
declare
prd_out varchar2(100);
begin
create_pm_window(prd_out);
dbms_output.put_line('output is '||prd_out);
end;
I don't have your procedure, but using a dummy procedure like :
Scott@my10g SQL>create procedure foo(p_out in out varchar2)
2 is
3 begin
4 select 'Hello '||instance_name into p_out from v$instance;
5 end;
6 /
Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
var mavar varchar2(100);
exec foo(:mavar);
print mavar;
exit;
EOF`
echo "OUT = ${OUTPUT}"
exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
OUT = Hello my10g -
Calling Managed CLR Stored Procedure from C++ SQL Server 2008 fails with Msg 2809
I am trying to call a stored procedure from C++ (VS 2010).
Here is what the stored procedure looks like:
public class Validate
[Microsoft.SqlServer.Server.SqlProcedure(Name = "ClientTest")]
public static void ClientTest(out String res )
{ res = "50";}
To create a stored procedure I deploy at first the assembly
USE [test]
GO
CREATE ASSEMBLY ClientTestAssembly
AUTHORIZATION testLogin
FROM 'C:\Users\test\Documents\Visual Studio 2010\Projects\TestCreationAssemblyCSharp\TestCreationAssemblyCSharp\bin\x64\Debug\TestCreationAssemblyCSharp.dll'
and call
USE test
GO
CREATE PROCEDURE ClientTest (@res NVARCHAR(40) OUTPUT)
AS
EXTERNAL NAME ClientTestAssembly.Validate.ClientTest
I can call my procedure direct in SQL Server Management Studio without any errors
declare @res nvarchar(10)
execute ClientTest @res OUTPUT
print @res
But when I try to call this procedure from C++ using CALL syntax
SQLBindParameter(sqlstatementhandle, 1, SQL_PARAM_OUTPUT, SQL_C_CHAR,
SQL_VARCHAR , 40, 0, version, sizeof(version) ,
&pcbValue);
res = SQLExecDirect(sqlstatementhandle, (SQLCHAR*)("{CALL ClientTest(?) }"), SQL_NTS);
I get the Error 2809 with SQLSTATE 42000 and with statement
The request for 'ClientTest'
(procedure) failed because 'ClientTest' is a procedure object.
However, if I wrap my CLR stored procedure into a T-SQL stored procedure, like
CREATE PROCEDURE myProc (@res NVARCHAR(40) OUTPUT)
AS
EXEC ClientTest @res OUTPUT
and call then myProc instead of ClientTest
res = SQLExecDirect(sqlstatementhandle, (SQLCHAR*)("{CALL myProc(?) }"), SQL_NTS);
everithing works fine and I get 50 as result.
I have no ideas what is the reason for that behavior.
Thanks very much for any suggestion.
ChristinaI'm not an ODBC expert, but you might try following the sample here:
Process Return Codes and Output Parameters (ODBC)
To see if it also behaves differently for your CLR proc.
David
David http://blogs.msdn.com/b/dbrowne/ -
Calling a stored procedure from a url
I am needing to call a stored procedure from a url string (or
anchor) understand that from training to be as follows:
http://host:port/pls/dad/package.procedure?query_string
With that in mind, I am getting an error as follows:
Not Found
The requested URL /pls/portal30/at_hrfm.checkshow.showcheck was
not found on this server.
Here is a sample of my url
http://servername:port/pls/portal30/at_hrfm.checkshow.showcheck
I can see servername:port/pls/portal30, it is just the
procedure I am having a problem with.
Here is a sample of my source code that is created under the
at_hrfm schema (I also tried under portal30 schema).
package body checkshow as
procedure showcheck as
begin
htp.htmlOpen;
htp.headOpen;
htp.title('My Check');
htp.comment ('This should be your Check');
htp.bodyOpen;
htp.header (1,'Check');
htp.print ('checkdate');
htp.bodyClose;
htp.headClose;
htp.htmlClose;
end;
end;I think I figured this out. I don't think the grant to ANONYMOUS is going to work with production XE and the online documentation is in need of an update. It appears that production XE has been locked down and you will need to specify the name of each stored procedure you wish to allow to be executed by adding it to the WWV_FLOW_EPG_INCLUDE_MOD_LOCAL function. This is spelled out in more technical detail here: http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25309/adm_wrkspc.htm#BEJCGJFJ
Another alternative that would work involves creating a separate DAD. Using the DAD approach with my schema made all of my stored procedures callable from a web browser, so I rejected this approach. To make this usable (secure) I would have needed to create and maintain a separate database user for the DAD and then only granted it execute for the stored procedures I wanted to be callable from a URL.
Finally I read about using an on-demand procedure and having it invoke the desired stored procedure. While I didn't try this out, it sounds like another good approach because it maintains session security. If it can be used to return an image I do not know.
- Jim -
Calling packaged stored procedure from Java
Hi All,
I'm trying to call a stored procedure from Java but I'm having
problems with registrating the output parameter. I'm getting
the error: Conflicting parameters.: sqltype=2003
This is the stored procedure which is located in a package in
the Oracle database:
package Pack_GetAgencyInformation as
Type InfoType is record ( agen_code varchar(3), agen_designation
varchar(30), agen_adresse varchar(60), agen_tel varchar(12) );
function GetAgencyInformation( P_AGENCE VARCHAR )
return Pack_GetAgencyInformation.InfoType
end Pack_GetAgencyInformation;
This is the Java source from where I'm calling the procedure:
//DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@164.48.69.125:1521:ventes", "system", "*****
// @machineName:port:SID,
userid, password
CallableStatement cs = conn.prepareCall("{ ? = call
Pack_GetAgencyInformation.GetAgencyInformation( ? )}");
try {
cs.registerOutParameter( 1,
oracle.jdbc.driver.OracleTypes.ARRAY);
} catch (SQLException e) {
e.printStackTrace();
cs.setString(2, "001" );
//ResultSet rset = cs.executeQuery();
The stacktrace:
java.sql.SQLException: Parametertypen conflicteren.:
sqlType=2003
at oracle.jdbc.dbaccess.DBError.throwSqlException
(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException
(DBError.java:210)
at
oracle.jdbc.driver.OracleCallableStatement.registerOutParameter
(OracleCallableStatement.java:220)
at
oracle.jdbc.driver.OracleCallableStatement.registerOutParameter
(OracleCallableStatement.java:350)
at dbAccess.main(dbAccess.java:25)
I think it has to do with the type InfoType which is created in
the Stored Procedure. I'm absolute no Oracle expert and I
prefer not to make changes to the Oracle database. So any
solution in Java is welcome!
BR, H.RietmanI managed to get it to work only by changing the stored
procedure. I have changed the return type record to a Ref
Cursor type (had to change alot of code for this). It seams
that Oracle JDBC drivers DON'T support the Record type as a
return type.
So the next question is: is it possible to typecast a record
type to a ref cursor type in Oracle. In this way I can easily
change the return type for the stored procedures.
/Harald -
Calling Oracle Stored Procedure from Weblogic.
Hi All,
I am using Oracle 11g R2 and weblogic 10.3.5.0
Do you know if it is possible to call a stored procedure from Weblogic.
Basically, what I would like to do is to call the following procedure : EXEC DBMS_SESSION.SET_IDENTIFIER('provider_a') when my application connects to my database, "provider_a" being the user used to connect to the oracle schema.
Thanks.Up !
Thanks. -
Calling invalid stored procedure from java
Will the stored procedure which is invalid get re-compiled automatically when called from a java program?
1.a stored procedure is invalid (oracle 9i)
2.calling the stored procedure from a java program
3.what will happen a.oracle recompiles the stored procedure
b.returns an sql exception
what happens,kindly help
drop your mail to [email protected]
Keep Smiling and Mailing,
Vijay Anand Natesan.thank you ..Kindly let me know if any of your friends have tried this
-
How to call a stored procedure from WorkShop
Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
me .. Today I'm simply trying to find out how to call a stored procedure from
within workshop, using any of the DB Controls .. I see workshop provides a way
create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
to be entered in place of the inline query .. Perhaps I've over looked it. Any
advise on the best way to tackle this task will be appreciated.
AtahualpaAtahualpa--
Maybe this will help:
http://edocs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/database/conStoredProcedures.html
Eddie
Atahualpa wrote:
Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
me .. Today I'm simply trying to find out how to call a stored procedure from
within workshop, using any of the DB Controls .. I see workshop provides a way
create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
to be entered in place of the inline query .. Perhaps I've over looked it. Any
advise on the best way to tackle this task will be appreciated.
Atahualpa -
Calling a stored procedure from within a ViewObject
Is it possible to make stored procedure call from within a BC4J ViewObject? Basically something like this:
select * from table(f1(3)); where f1 is a table function. Using Oracle's pipelined table functions?
If not, is it possible to call a stored procedure from Java and have the returned results be put back into a BC4J RowSet.
In addition, is there a way to create a JDBC Resultset from a BC4J RowSet?
We need to be able to dynamically create our SQL statements (the entire SQL, not just the where clause) but are required to have these sql statements generated/executed from within a pl/sql stored procedure in the database.Is it possible to make stored procedure call from within a BC4J ViewObject? Basically something like this:
select * from table(f1(3)); where f1 is a table function. Using Oracle's pipelined table functions?
Yes. Using our expert-mode query feature this is possible.
is it possible to call a stored procedure from Java and have the returned results be put back into a BC4J RowSet.
Yes. See this article about basing a view object on a REF CURSOR:
http://radio.weblogs.com/0118231/2003/03/03.html
In addition, is there a way to create a JDBC Resultset from a BC4J RowSet?
No. Not directly. What's the business requirement here so I can understand better?
We need to be able to dynamically create our SQL statements (the entire SQL, not just the where clause) but are required to have these sql statements generated/executed from within a pl/sql stored procedure in the database.
REF CURSOR would work fine, or if it's just the statement that needs to be generated dynamically, you could fetch the text of the SQL statement from the stored procedure, then use createViewObjectFromQueryStmt(). Although this has runtime overhead involved with describing the query.
The REF CURSOR based approach is probably best for this. -
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());
} -
Can i call a stored procedure from OracleDashboardPrompt?
Hi,
Can i call a stored procedure from OracleDashboardPrompt once i click the Go button in OBIEE?The input parameters to the procedure are the one that i have given in DashboardPrompt.and based on the result of the procedure(either 0 or 1),i have to display reports.Can anyone help me.
Thanks in Advance...Please find below the possible approach to the scenario:
1.Create a prompt for the column which you need as input to store proc and create a presentation variable for that .
2.Create a dummy report with 1 column which will have the above created presentation variable as filter(We can design this reports in such a way like the first column will get filtered based on the presentation variable)
3.Create a second column and in the column definition we can add a code like
evaluate('StoreProc(%1)','@{firstcolumn}')
4.We can hide the first column in the report and only show the output of store proc to the end user
Hope this helps :)
Maybe you are looking for
-
New hard drive and now can't get library back!
Hi, My hard drive recently crashed and I did not have a backup (I know, I know!). Anyway, new hard drive installed and some of my files were saved including some music files. However, when I try to add them to iTunes, they do not add. I have everythi
-
How to tell if application is hanging or still working?
I occasionally ask photoshop to do very large jobs such as joining many images into panoramas. This can take a very long time, and sometimes Photoshop will show as 'not responding' in red on the activity monitor or force quit window, and will hang un
-
How do i get media from my computer to my apple tv from an non i tunes source?
Hello i just got the latest mac book pro also i got the latest apple tv i was wondering how to send media from the computer to the apple tv from a non itunes source like my i pod does. thank you Shawn
-
Why do i get "please wait while windows configures scan" every time i scan something?
when I go to scan something I get "please wait while windows configures scan"
-
How to get alerted or notified when db goes offline
Hi All, I am basically looking for solution for the below problem. Is there a nice way for a DBA to get alerted/notified as and when a database is not accessible for any reason(say offline,suspect,restoring...) DBA has to get alerted. I am working o