Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:41:31+00:00 2026-06-08T17:41:31+00:00

I am writing an accounting system backed by an h2 database. The tree of

  • 0

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 given node 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(5) [for example]

I get the following error:

Syntax error in SQL statement "SELECT ID FROM ACCOUNTS WHERE ID IN ANCESTOR_PKS[*](5) "; expected "("

But there is a bracket after ANCESTOR_PKS!!! What on earth is going on here? Is there some way to use IN with the result of a stored procedure? I have searched and searched, but all the examples of the use of IN that I see are with literal arrays, and no-one seems to think of showing how to use an array which is the return value of a stored procedure.

Help???

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:41:34+00:00Added an answer on June 8, 2026 at 5:41 pm

    I’m unfamiliar with h2, but this page says you must place () around the array.

    SELECT ID FROM ACCOUNTS WHERE ID IN (ANCESTOR_PKS(5))
    

    Maybe you even have to add a subselect

    SELECT ID FROM ACCOUNTS WHERE ID IN (SELECT ANCESTOR_PKS(5))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I am writing a MiddleWare application that synchronizes information between and accounting application
I'm writing a simple accounting program consists of several C# winform clients and a
I'm trying to get an older Bill of Materials system to export parts to
I'm writing a SQL script that we want our accounting team to be able
Hopefully I can do this without writing a book... I'm working on a system
I'm writing a script for Caseware, the accounting software my Company uses, and I
Writing code in php and jQueryMobile. I am trying to get a div to
Writing a server application and my code is starting to get a bit.. repetitive..
I am working on a program and need to implement a double-entry accounting system.
Writing Classic ASP code in JScript has a lot going for it: more humane

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.