hsqldb - Calling hsql function from java -


i trying call oracle function java using hsqldb integration test.

function: (function.sql)

function balance (acct_id number) return number acct_bal number; begin   select bal acct_bal accts acct_no = acct_id;   return acct_bal; end; 

java code:

    int acctno = 0;     callablestatement cstmt = connection.preparecall("{? = call balance(?)}");     cstmt.registeroutparameter(1, types.float);     cstmt.setint(2, acctno);     cstmt.executeupdate();     float acctbal = cstmt.getfloat(1);     system.out.print("test print: " + acctno +  " " +acctbal); 

error:

java.sql.sqlsyntaxerrorexception: user lacks privilege or object not found: balance @ org.hsqldb.jdbc.util.sqlexception(unknown source) @ org.hsqldb.jdbc.util.sqlexception(unknown source) @ org.hsqldb.jdbc.jdbcpreparedstatement.<init>(unknown source) @ org.hsqldb.jdbc.jdbccallablestatement.<init>(unknown source) @ org.hsqldb.jdbc.jdbcconnection.preparecall(unknown source) 

please me in regard. note: creating table , inserting data working fine.

you must change function hsqldb syntax , create after tables. modified function this:

create function balance (acct_id integer) returns double begin atomic   declare acct_bal double;   select bal acct_bal accts acct_no = acct_id;   return acct_bal; end; 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -