How I can call Store procedure by TABLENAME.FIELD_VALUE ?
Hello,
I have one table called store_proc_list.
In the table there are two fields ie ID, SP_NAME.
In SP_NAME I have set the store procedure name.
Now,
What I wanted to do is .
I am writting one store procedure and in that
and I want to execute the another store procedure (by name), which I will get from
SELECT sp_name FROM store_proc_list WHERE id=1
How I can do it ?
I tried to do it but I could not get that how we can execute stored procedure by the name which I will get from the table.field_value for the specified condition.
sample will more helpful.
Thanks
Kamlesh Gujarathi
[email protected]
I am curious to know how does Execute immediate help in executing the stored prod dynamically...
SQL>CREATE OR REPLACE PROCEDURE test_proc1
2 AS
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE('This is test_proc1');
5 END;
6 /
Procedure created.
SQL>
SQL>CREATE OR REPLACE PROCEDURE test_proc2
2 AS
3 lv_proc_name VARCHAR2(30) := 'TEST_PROC1';
4 BEGIN
5 EXECUTE IMMEDIATE lv_proc_name;
6 END;
7 /
Procedure created.
SQL>sho err;
No errors.
SQL>
SQL>exec test_proc2;
BEGIN test_proc2; END;
ERROR at line 1:
ORA-00900: invalid SQL statement
ORA-06512: at "AIP.TEST_PROC2", line 5
ORA-06512: at line 1
Regards
Arun
Similar Messages
-
How to call store procedure in query generator
Hi All,
How to call store procedure in query generator.
Regards
Rajkumar Gupta
Edited by: Rajkumar Gupta on Dec 7, 2010 2:11 AMHi,
Please check the following threads.
How to use Stored Procedure in sap business one
How to add parameters to a stored procedure in B1 Query generator
How to execute the procedure in sap b1
Hope it helps,
Vasu Natari. -
About JDBC CALL STORE PROCEDURE with out parameter is greater than 4000
Hi Guys,
I have a problem call store procedure with a large string.
as i know varchar2 can contain 32767 characters in pl/sql .
But when i used varchar2 as a out parameter in a store procedure, if the out parameter is greater than 4000 characters , it always give me error message as 'the buffer is too small'.
why it happened?
I read some article that says i need configure a property in data-source.xml , and jdbc 10g driver already solved this problem, but i used jdev 10.1.3.2 ,the driver should be fine.
How can i solve this problem?
Thanks in advance,
AppCatObject is Foundation, Execute Script
This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.*;
PreparedStatement stmt = null;
Connection conn = null;
ResultSet rs = null;
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
conn = ds.getConnection();
stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
rs = stmt.executeQuery();
rs.next();
patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
} finally {
try {
rs.close();
} catch (Exception rse) {}
try {
stmt.close();
} catch (Exception sse) {}
try {
conn.close();
} catch (Exception cse) {} -
How i can call java program in VB2005 ?
Hi members...
Please...please...please...
If any one now how i can call java program in VB.net program and open it ,please i want now the way to do it by details and by examples and step step to do it ,,..
thanks ...If your server does not return to the command prompt, write a java programm which starts your server and returns to the command prompt.
An example for an application like this:
import java.io.IOException;
public class StartApp
public static void main(String[] args)
if (args.length > 0)
StringBuffer cmd = new StringBuffer();
for (int index = 0; index < args.length; index++)
cmd.append(args[index] + " ");
try
Runtime.getRuntime().exec(cmd.toString());
catch (IOException ioe)
System.out.println("Error: command not found: " + cmd.toString());
else
System.out.println("Error: missing arguments");
An example for starting your server with that programm:
/usr/bin/java -jar ./StartApp.jar /usr/bin/java -jar ./myServer.jar
It works. Have fun. -
ADF 11, USING EJB, CALL STORE PROCEDURE, A PROBLEAM?
ADF 11, USING EJB, CALL STORE PROCEDURE, A PROBLEAM?
I have a store procedure:
CREATE OR REPLACE PACKAGE BODY PK_HR1
IS
FUNCTION FUNC04
RETURN CUR_RESULT
IS
X_CUR CUR_RESULT;
BEGIN
OPEN X_CUR FOR
select mako, tenko, diachiko from kho;
RETURN X_CUR;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END FUNC04;
END PK_HR1;
In the entities class, I have a NamedStoredProcedureQuery:
@Entity
@NamedStoredProcedureQuery(name="Kho.FUNC04",
resultClass=Kho.class,
procedureName="PK_HR1.FUNC04" )
public class Kho implements Serializable {
In session bean, i have a method
public class SessionEJBBean implements SessionEJB, SessionEJBLocal
public void test() throws Exception{
try {
//code here ...
List<Kho> listKho = em.createNamedQuery("Kho.FUNC04").getResultList();
System.out.println("aaaa");
} catch (Exception ex) {
ex.printStackTrace();
} finally {
I try running, but always show errror
this errors:
Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00221: 'FUNC04' is not a procedure or is undefined
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Error Code: 6550
Call: BEGIN PK_HR1.FUNC04(); END;
Query: ReadAllQuery(jp.co.mfr.sgs.bean.Kho)
help help me?You need to use a CallableStatement for this.
--olaf -
I log in in the Enterprise manager with the user "Nadia" that I created . I Created an escheme TEST and all the tables .
I Created also the package with this user. It has a procedure that returns 1 cursor.
This user has:
atributte: CONNECT, DBA AND RESOUCE
System: EXECUTE ANY PROCEDURE AND UNLIMITED TABLESPACE
Is it correct?
My application is access the oracle 9i with this user too.
I have to call the procedure this way:
SID.PACKAGE.PROCEDURE
Im my vb code, I am call this way too.
Code VB 6:
With cmd
.ActiveConnection = CNP
.CommandText = "NADIA.EXT_DADOS.DADOS_VISITANTE" ????
.Prepared = False
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("@Documento", adInteger, adParamInput, 15, 8384474)
.Parameters.Append .CreateParameter("@nome", adChar, adParamInput, 1, lsTipo)
Set ObReg = .Execute(, , adAsyncFetchNonBlocking)
End With
When execute, message errors show:
The NADIA.EXT_DADOS.DADOS_VISITANTE needs to be declared.
Wha is wrong?
thank you
NádiaIt looks like you are getting appropriate feedback in one of the other threads on this topic that you've posted:
To call Store procedure
But I would have to say that I hope this is just a test system. I would never grant DBA, EXECUTE ANY PROCEDURE, and UNLIMITED TABLESPACE to a "normal" user in a production system.
Good luck,
Mark -
HELP!!! How I can call to EJB from another EJB??
I have two EJBs, for each EJB I have a jar, how I can call to EJB jar to another???
I have tried the following, in the first EJB I have import the second EJB jar and call it with context, lookup, PortableRemoteObject etc.. but the instruction lookup not find the second EJB reference.
The name in the lookup instruction is the JNDI name of the second EJB but not find a reference to it.
Please help me!!! Thanks!!
The error is:
javax.naming.NameNotFoundException: Missing node. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:34)
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.extract(NotFoundHelper.java:50)
at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:161)
at com.inprise.j2ee.jndi.java.CorbaContext.resolveName(CorbaContext.java:242)
at com.inprise.j2ee.jndi.java.CorbaContext.lookup(CorbaContext.java:261)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:483)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:493)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:493)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:937)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:942)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at ejbclient.EnterpriseClientBean.addition(EnterpriseClientBean.java:115)
at ejbclient.EnterpriseClientBean.actionPerformed(EnterpriseClientBean.java:97)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
at avax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstrok.. Here it goes.. I am writing a sample code..
public class EJB1LogBean implements SessionBean {
// test is a method of stateless session beam
public void test ( TestVal val )
throws RemoteException{
try {
EJB2LogHome ejb2Home= (EJB2LogHome)getHome("java:comp/env/ejb/EJB2LogHome",1);
EJB2Log ejb2Log = ejb2LogHome.create ( val );
} catch ( CreateException e ) {
System.out.println("Create Exception occurred ");
e.printStackTrace();
} catch ( RemoteException e ) {
System.out.println( "RemoteException Occured");
e.printStackTrace();
throw new RemoteException () ;
} catch(Exception ee) {
ee.printStackTrace();
private EJBHome getHome(String jndiName,int type) {
try {
Context context = new InitialContext();
Object ref = context.lookup( jndiName );
switch(type)
case 1:
EJB2LogHome ejb2LogHome = ( EJB2LogHome )
PortableRemoteObject.narrow( ref, EJB2LogHome.class );
return ejb2LogHome;
} catch ( Exception e ) {
e.printStackTrace();
return null;
}//EJB1LogBean ends
Here as you can see, EJB1LogBean(session bean) is calling a second EJB, EJB2LogBean (entity bean). TestVal is a sample value object passed. It is plain java class and can vary from app to app and it has got nothing to do with ejbs.
"java:comp/env/ejb" is a J2EE standard and while getting a home interface, you have to append the home interface class name to "java:comp/env/ejb". Here I am passing "java:comp/env/ejb/EJB2LogHome" and "1" to getHome method, whose job is to get a reference to a home interface. getHome method is a local method. "1" is passed just to give a flexibility to getHome method as you can have more ejbs to invoked. In that case, you can go on adding different case statements for 2, 3 etc.
The only thing you have to keep in mind is that your deployment descriptor for EJB1LogBean will contain the entires for both the beans i.e. for EJB1LogBean and EJB2LogBean. This is because EJB2LogBean is wrapped by EJB1LogBean.
Hope this helps.
Please let me know if you need anything more.
- Amit -
How to get the store procedure name inside this store procedure?
how to get the store procedure name inside this store procedure?
Why cant you get the procedure name as hard code as the proc name is going to change.
Are you looking for getting the parent proc name from child proc name which is getting executed within parent proc?
Try the below:
--Parent Proc
Alter Proc sp_test
as
Begin
Declare @s varbinary(MAX) = Cast('sp_test' as Varbinary(MAX));
SET CONTEXT_INFO @s;
exec sp_test2
End
--Child proc
Alter proc sp_test2
as
SELECT Cast(CONTEXT_INFO() as varchar(100));
--Test execution
Exec sp_test
Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
[Blog] -
How we can call or execute a SHELL script through Oracle forms or Reports
How we can call or execute a SHELL script through Oracle forms or Reports.Its urgent.......
Use HOST command.
-
How i can call an item that the name of the bloc is a param --URGENT--
how i can call an item that the name of the bloc is a param
exp:
DECLARE
B VARCHAR2(20);
begin
B:='BLOC1';
:B.Text1:='Hello'; --- a want thisLooks like your talking 'bout Forms, don't you?
What you're looking for is the copy built-in, syntax is e.g.
COPY ('MY TEXT', 'EMP.ENAME'); -
How to call store procedure from an oci program
Hello,
I work on Oracle 8.1.7 under AIX.
I must call from an OCI C++ program a store procedure that have an result set as param out.
I'm not sure how can I call the procedure/function. I want to execute this statement and fetch the results.:
" CALL Department.get_all (:1) " is this OK?
" Call department.GetAll() into :1 "
I have seen some example from an PL/SQL block but that's not ok for me.
what i have done:
i have created an package
create or replace package department as
type cursor_type is ref cursor;
procedure get_emp( i_deptno in number, rs out cursor_type );
procedure get_all( rs out cursor_type );
function GetAll return cursor_type;
end department;
create or replace package body department as
procedure get_emp ( i_deptno in number, rs out cursor_type )
as
begin
open rs for
select empno, ename
from emp
where deptno = i_deptno;
end;
procedure get_all ( rs out cursor_type )
as
begin
open rs for
select empno, ename
from emp;
end;
function GetAll return cursor_type
as
l_cursor cursor_type;
begin
open l_cursor for select ename, empno from emp;
return l_cursor;
end;
end;Hi,
I am new to OCI facing the same problem you have mentioned, If you have found out how to solve it , can you post the answer for the same.
Thanks
Mani -
Call store procedure from pre-mapping
Hi,
I am currently working on OWB client version 10.2.0.4.36.My requirement is to call store procdure from pre-mapping tranformation.How to achieve this & how to pass parameters to the store procedure?
Please let me know.
Thanks,
SivaThanks for the quick reply.I am doing the same way as suggested.But am getting warning,when I validate it and is expecting to synchronize it.What warning you got exactly and i think you have not deployed the procedure.
The reason for this procedure is to select max value from one of the table and then drop & recreate the sequence with max value + 1.
Inside the procedure,am doing this all dynamically.which means am passing Columnname,tablename & sequencename to this procedure.
Do you think is this good approach or any other advisable approach?Can you explain you requirement then only we can suggest the better way .
Cheers
Nawneet -
HOW TO EXECUTE A STORE PROCEDURE THAT RETURN MULTIPLE ROWS FROM A QUERY
I NEED TO CREATE AND USE A STORE PROCEDURE THAT IS GOING TO DO A SELECT STATEMENT AN THE RESULT OF THE SELECT STATEMENT IS RETURN IN SOME WAY TO THE REQUESTER.
THIS CALL IS MADE BY AN EXTERNAL LANGUAGE, NOT PL/SQL OR FORMS APPLICATION. USING FOR EXAMPLE ODBC AND VISUAL BASIC. WHAT I NEED TO DO IS ADD A DATA ACCESS LAYER TO MY APPLICATION AND I ALREADY HAVE IT DONE FOR MS SQL SERVER, BUT I NEED THE SAME FUNCTIONALITY ACCESSING AN ORACLE DATABASE.
FLOW:
1. VB CREATE A ODBC CONNECTION TO A ORACLE DATABASE
2. VB EXECUTE A STORE PROCEDURE
3. THE STORE PROCEDURE RETURNS TO THE VB APPLICATION THE RESULT OF THE QUERY THAT IS INSIDE OF THE STORE PROCEDURE.(I.E. THE STORE PROCEDURE IS A BASIC SELECT, NOTHING COMPLEX)
4. VB DISPLAY THE RESULT IN A GRID
FOR SURE I CAN DO THE SELECT DIRECTLY TO ORACLE, BUT FOR PERFORMANCE REASONS AND SCALABILITY, I'LL LIKE IT TO DO IT USING A STORE PROCUDURES
IS THIS POSIBLE?, HOW?
THANKSCertainly, it's possible. First, define a stored procedure that includes an OUT parameter which is a REF CURSOR. Then, call the stored procedure via ODBC omitting the OUT parameter from the list of parameters. IT will automatically be returned as a result set. Syntax for both is below...
CREATE PROCEDURE foo (inParam in varchar2, resultSet OUT REF CURSOR )
In ODBC:
{call foo( 'someData' )}
Justin -
Problem of retrieve a set of data when calling store procedure using vb with ODBC
when I use ODBC, it can return 1 record (1 field) using pass and retrieve the parameter. but it cannot success when return a set of data (using recordset to store it), when i do it, the error message (Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if availabl. No work was done.). Why ? and how can solve it ?\
Thanks in advance.oh, really ? it is not use ODBC to connecto to oracle ?
Here is my program code:
STORE PROCEDURE:
PROCEDURE getInforcePolicy(PClient_ID IN VARCHAR2, PPolicy_No IN VARCHAR2, BasicCur OUT oraoledb.m_refcur, RiderCur OUT oraoledb.m_refcur)
IS
BEGIN
OPEN BasicCur FOR SELECT * FROM
inforce200111 WHERE Client_ID = PClient_ID and Policy_No = PPolicy_No and coverage_No = 1;
OPEN RiderCur FOR SELECT * FROM
inforce200111 WHERE Client_ID = PClient_ID and Policy_No = PPolicy_No and coverage_No <> 1;
END getInforcePolicy;
PACKAGE oraoledb AS
TYPE m_refcur IS REF CURSOR;
END oraoledb;
Program:
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Dim cmd As New ADODB.Command
Dim paramclient As New ADODB.Parameter
Dim parampolicy As New ADODB.Parameter
Dim I As Integer
cn.Open "ridev", "abc","abc"
cmd.ActiveConnection = cn
Set paramclient = cmd.CreateParameter("PClient", adVarChar, adParamInput, 10)
Set parampolicy = cmd.CreateParameter("PPolicy", adVarChar, adParamInput, 10)
paramclient.Value = "0000023011"
parampolicy.Value = "HK0010021U"
cmd.Parameters.Append paramclient
cmd.Parameters.Append parampolicy
cmd.CommandText = "{call getInforcePolicy}"
Set rs = cmd.Execute
Do While Not rs.EOF
Loop
Set rs2 = rs.NextRecordset
Do While Not rs2.EOF
loop
Where the RIDEV is a datasource that created from Data Source in Control Panel using the driver call "Microsoft ODBC for ORACLE" -
(Resolved) How to execute 2 store procedures in 1 transaction?
public void method1(){
Session session = getSessionFactory().acquireSession();
StoredProcedureCall spc1 = new StoredProcedureCall();
spc1.setProcedureName("PKG.SP1");
spc1.addNamedArgumentValue("param", "aaa");
session.executeNonSelectingCall(spc1);
StoredProcedureCall spc2 = new StoredProcedureCall();
spc2.setProcedureName("PKG.SP2");
spc2.addNamedArgumentValue("param", "bbb");
session.executeNonSelectingCall(spc2);
The above method is defined in SessionFacadeBean (just like the EJB in SRDemo),
I want the above 2 procedures executed in 1 transaction. If spc2 failed, the spc1 should not be committed. How can I do this?
Regards,
Jason
Message was edited by:
Jason.LuI have changed code as follows:
public void method1(){
DatabaseSession session = getSessionFactory().getSharedSession();
session.beginTransaction();
try{
StoredProcedureCall spc1 = new StoredProcedureCall();
spc1.setProcedureName("PKG.SP1");
spc1.addNamedArgumentValue("param", "aaa");
session.executeNonSelectingCall(spc1);
StoredProcedureCall spc2 = new StoredProcedureCall();
spc2.setProcedureName("PKG.SP2");
spc2.addNamedArgumentValue("param", "bbb");
session.executeNonSelectingCall(spc2);
} catch (Exception e) {
session.rollbackTransaction();
} finally {
session.release();
It seems that the "session.rollbackTransaction();" will be executed if spc2 fails.
toplink logs are as follows:
[TopLink Info]: 2007.11.12 10:20:36.690--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--default login successful
[TopLink Finer]: 2007.11.12 10:20:36.690--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--TX beginTransaction, status=NO_TRANSACTION
[TopLink Finer]: 2007.11.12 10:20:36.705--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--TX Internally starting
[TopLink Finer]: 2007.11.12 10:20:36.705--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--external transaction has begun internally
[TopLink Fine]: 2007.11.12 10:20:36.705--ServerSession(1901666)--Connection(11203640)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--BEGIN PKG.SP1(param=>'aaa'); END;
[TopLink Fine]: 2007.11.12 10:20:36.971--ServerSession(1901666)--Connection(22861541)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--BEGIN PKG.SP2(param=>'bbb'); END;
[TopLink Warning]: 2007.11.12 10:20:37.440--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070608)): oracle.toplink.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SP2'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Error Code: 6550
[TopLink Finer]: 2007.11.12 10:20:37.455--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--TX rollbackTransaction, status=STATUS_ACTIVE
[TopLink Finer]: 2007.11.12 10:20:37.455--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--TX Internally rolling back
[TopLink Finer]: 2007.11.12 10:20:37.455--ServerSession(1901666)--Thread(Thread[HTTPThreadGroup-4,5,HTTPThreadGroup])--external transaction has rolled back internally
The problem is the 1st store procedure is committed (it should be rolled back!), and the database is updated.
Thanks,
Jason
Maybe you are looking for
-
How can I play a video on iPad and still be able to record a voiceover
I know the question is a bit confusing... so here it is: I am currently working on a brand activation where people watch a World Cup highlight, and then have the chance of recording their own commentary, then it gets posted to facebook and the more l
-
I have set up Photoshop Elements11 as the External Editor in iPhoto just as Terence Devlin said. However when I save the edited photo it does not appear in iPhoto. A drop down menu asks where I want to save the photo and I do not know what to choose.
-
I bought my computer on Ecuador, so it is in spanish the physical keybord, but after updating to Mavericks and updating Pages, each time I write something it corrects me to british language, for example if i write down analyze with a z, it would corr
-
Hi we need to send mail to the QA person once the GR is posted for Purchase order . There is no QM impletementation here. so thats to inform the QA person of the arrival of goods for sample and inpsection. Checked MLBR output type..but that mail goe
-
Get IView Properties and portal details Programatically
Hello Experts, I have created one WDA application and deployed the same on portal. I need to access iView properties of the iView programatically. Is there any class in WD which will gives me iView properties like, PCD location, application parameter