db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trolll <m.roki...@ibe.edu.pl>
Subject Executing sql from function
Date Thu, 03 Mar 2011 14:42:15 GMT

Hi everyone

I have a problem with executing sql statements from inside of a sql function
written in java. This is what I did

1. This is how I execute the statemnt in java

q=con.prepareStatement("SELECT * FROM users");

2. I built a Jar that contains this class
3. I install the jar in a derby database

CALL SQLJ.install_jar ('file:///home/michal/foo.jar', 'foo', 1);

4. I create a function that uses my java method from the jar file

CRATE FUNCTION bar(varchar(50)) RETURNS varchar(50) LANGUAGE java EXTERNAL
NAME 'foo.Tools.bar' PARAMETER STYLE java no sql;

5. I use the method in a sql query

SELECT bar(user_id) FROM users

While query execution I get the following exception:
java.sql.SQLException: The external routine is not allowed to execute SQL

I use Java 6 and derby

Does anybody know what do I do wrong
View this message in context: http://old.nabble.com/Executing-sql-from-function-tp31059263p31059263.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.

View raw message