Forum: Building VoltDB Applications

Post: union and union all statement parameters

union and union all statement parameters
itdevchief
Jul 2, 2014
Hello,

I need to union two tables and created following statement:

(select top ? * from ext_bid_user where pair_id = ? order by price desc, pair_id, id) union (select top ? * from ext_ask_user where pair_id = ? order by price asc, pair_id, id) order by price, pair_id, id;

which has 4 parameters. but when executing I get next error:

"Number of arguments provided was 4 where 0 was expected for statement"

what is wrong?

Thank you,
Victor.
pzhao
Jul 2, 2014
Victor,

Thanks for your question. I'm taking a look at it and let you know shortly.

-Peter
pzhao
Jul 2, 2014
Victor,

I was able to replicate a similar error using our voter example application:
../../bin/sqlcmd --query="select top ? * from votes"
VOLTDB ERROR: HSQL-BACKEND ERROR
Number of arguments provided was 0 where 1 was expected for statement select top ? * from votes
at org.voltdb.sysprocs.AdHoc_RO_MP.run(AdHoc_RO_MP.java:51)

What version of voltdb you are running and where are you running this command from?
Are you trying to execute a stored procedure statement in sqlcmd or in our web studio? These are good place to help develop your sql queries. As you plan out your application, you can move on to a stored procedure where you can get a varying results based on the inputs you pass onto the stored procedure. I've included documentation on stored procedures.

Simple stored procedure:
http://voltdb.com/docs/UsingVoltDB/DesignCodeFreeProcs.php
Java stored procedure:
https://community.voltdb.com/docs/UsingVoltDB/DesignProc

-Peter
itdevchief
Jul 2, 2014
Hello Peter,

I did use 4.4 and recently upgraded to 4.4.1. I am trying to execute stored procedure. What I found that any statement with UNION generates such error (nothing to do with TOP clause):

select * from ext_bid_user where pair_id = ? union all (select * from ext_ask_user where pair_id = ?)

generates the same error (2 params instead of 0).
pzhao
Jul 2, 2014
Victor,

If its possible, can you send us your catalog.jar file, we could take a closer look.
Please send to support@voltdb.com
Thanks.

-Peter