-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ORA-01008: not all variables bound Exception
PostPosted: Thu Nov 09, 2006 1:23 am 
Newbie

Joined: Fri Oct 27, 2006 7:32 am
Posts: 9
Hi All,

I am using Spring Framework and Hibernate...I have a stored procedure which is to called from the program...

Stored Proc is :

CREATE OR REPLACE PROCEDURE getDeptEntries(dnam OUT VARCHAR2,dno IN NUMBER)
AS
sCall VARCHAR2(500);
nTotal VARCHAR2(50);
BEGIN
sCall := 'SELECT dname FROM DEPT WHERE DEPTNO = :dno';
EXECUTE IMMEDIATE sCall INTO nTotal;
dnam := nTotal;
end getDeptEntries;

And the PRogram is......

package secondEx;

import java.sql.Types;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.object.StoredProcedure;

public class TestSP {

public static void main(String[] args) {

System.out.println("DB TestSP!");
TestSP t = new TestSP();
t.test();
System.out.println("Done!");
}

void test() {
DriverManagerDataSource ds = new DriverManagerDataSource();
ds.setDriverClassName("oracle.jdbc.OracleDriver");
ds.setUrl("jdbc:oracle:thin:@localhost:1521:sequenom");
ds.setUsername("sequenom");
ds.setPassword("sequenom");

MyStoredProcedure sproc = new MyStoredProcedure(ds);
Map res = sproc.execute();
printMap(res);
System.out.println("fin execute" );
}

private class MyStoredProcedure extends StoredProcedure {
public static final String SQL = "getDeptEntries";
private int count = 0;

public MyStoredProcedure(DataSource ds) {
super(ds,SQL);
setSql(SQL);
declareParameter(new SqlOutParameter("dname",Types.VARCHAR));
declareParameter(new SqlParameter("deptno",Types.INTEGER));
compile();
}

public int getCount() {
return count;
}

public Map execute() {
Map inParameters = new HashMap(1);
inParameters.put( "deptno",new Integer(21) );

Map out = execute(inParameters);
System.out.println(out);
return out;
}
}

private static void printMap(Map r) {
Iterator i = r.entrySet().iterator();
while (i.hasNext()) {
System.out.println((String) i.next().toString());
}
}
}


When I run this...I am getting the following error:


Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call getDeptEntries(?, ?)}]; SQL state [72000]; error code [1008]; ORA-01008: not all variables bound
ORA-06512: at "SEQUENOM.GETDEPTENTRIES", line 7
ORA-06512: at line 1
; nested exception is java.sql.SQLException: ORA-01008: not all variables bound
ORA-06512: at "SEQUENOM.GETDEPTENTRIES", line 7
ORA-06512: at line 1

java.sql.SQLException: ORA-01008: not all variables bound
ORA-06512: at "SEQUENOM.GETDEPTENTRIES", line 7
ORA-06512: at line 1



Thnx in advance..

_________________
Sujatha K


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.