I am writing an accounting system backed by an h2 database. The tree of accounts is stored in the ACCOUNTS table, with the PARENT_ID column storing the links in the tree.

To get the path to a given node in the tree, I have the following stored procedure:
  public static Object[] getAncestorPKs(long id)
whose job is to produce an array of integers, being the PARENT_ID values between the node in question and the root of the tree. I register the procedure in the database under the name ANCESTOR_PKS like this:
  CREATE ALIAS IF NOT EXISTS ANCESTOR_PKS FOR "xxx.yyy.zzz.getAncestorPKs"

My problem is I can't seem to find a way to use the thing without triggering a SQLException! I need to use it in the following way:
  SELECT ID FROM ACCOUNTS WHERE [...] AND ID IN ANCESTOR_PKS(x)
where x is the primary key of the node in question.  I get the following error:
  expected "("
with the asterix indicating the position of the error immediately after ANCESTOR_PKS.

I'm assuming this has something to do with the use of IN, since if I simply say
  "SELECT ANCESTOR_PKS(x)"
with x having some appropriate value, there is no problem.

Is there some way to use IN with the result of a stored procedure?

--
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to