Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JDBC - Invalid column name error

Status
Not open for further replies.

DKL01

Programmer
Sep 14, 2000
233
0
0
US
Hi All -

Can anyone tell me what I'm doing wrong here. Appreciate any help. Thanks

In DB

CREATE OR REPLACE FUNCTION sf_Sales (
Date VARCHAR2,
Company_ID VARCHAR2
) RETURN NUMBER IS
:
:
:

In Java Code

sqlStr = "SELECT sf_Sales(" + sqlParam + ") SalesAmt from dual";
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection("jdbc:eek:racle:thin:mad:<IP>:<Port>:<sid>","Admin","Password");
Statement statement = connection.createStatement();
selcurs = statement.executeQuery(sqlStr);
selcurs.next()
System.out.println(selcurs.getFloat("SalesAmt")); <-- Getting invalid column name error.
 
What happens when you do :

Code:
System.out.println(selcurs.getFloat(1));

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Hi,

The PL/SQL function sf_Sales is expecting 2 args and how ever you are passing one param. Just make sure you execute the function in SQL Plus before trying to excute for the JDBC.

Code:
sqlStr = "SELECT sf_Sales('" + sqlParam + "','') SalesAmt from dual";

But I am not very good with PL/SQL I might be wrong as well.

-Venu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top