Frans Verster <[email protected]> writes:
> Hi Guys and Girls,
>
> Sorry to bother.. I am making some Java DB / Apache Derby Table
> Functions, working very nice. I need to know the user querying the
> function to return only his/her items. How can I get the
> session/login/current user?
Hi Frans,
The SESSION_USER function returns the name of the user that invoked the
table function. Something like this should do the trick, I think:
public static ResultSet tablefunc() throws SQLException {
String user;
try (Connection c =
DriverManager.getConnection("jdbc:default:connection");
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("values session_user")) {
rs.next();
user = rs.getString(1);
}
return createResultSetForUser(user);
}
Hope this helps,
--
Knut Anders