Forum: Building VoltDB Applications

Post: Stored Procedure Arguments

Stored Procedure Arguments
skashikar
Jun 8, 2010
Hi,

Is it possible to pass VoltTable[] as a IN stored procedure parameter (to run())?
Is it possible to return VoltTable[] as a OUT parameter?

Thanks,
Swapnil
RE: Stored Procedure Arguments
aweisberg
Jun 8, 2010
Hi Swapnil,

Yes and yes. A scalar value returned by a procedure will always be wrapped in an array of volt tables. You can also create an array of volt tables and return that.

See 3.2.1.5 in "Using VoltDB" from http://community.voltdb.com/sites/default/files/1.0.01-docs_pdf.zip

Ariel Weisberg
VoltDB Engineer
RE: Stored Procedure Arguments
skashikar
Jun 9, 2010
Hi Swapnil,

Yes and yes. A scalar value returned by a procedure will always be wrapped in an array of volt tables. You can also create an array of volt tables and return that...
Ariel Weisberg
VoltDB Engineer


Hi Ariel,

Hmmm... Section 3.2.1.5 describes how to get VoltTable[] as return value of run() but I couldn't find any mention of passing or returning VoltTable[] as parameters to run().

Just to confirm, let me give an example of what I am thinking about.
Lets say, given a personId as input, we need to get three outputs: 1) count of his friends 2) list of friends and 3) all past addresses. To do so we write a SP where the count is returned through the return value of run(). The rest through the parameter list:

public long run(long personId, VoltTable[] friendsList, VoltTable[] pastAddresses)

Is this a valid run() signature?
If yes, I will then have a follow-up question.

Thanks,
Swapnil
==========
PS: why is message subject field not auto-populated everytime I reply to the same thread?
It doesn't work like that.
jhugg
Jun 9, 2010
Hi Ariel,

Hmmm... Section 3.2.1.5 describes how to get VoltTable[] as return value of run() but I couldn't find any mention of passing or returning VoltTable[] as parameters to run()...

Thanks,
Swapnil
==========
PS: why is message subject field not auto-populated everytime I reply to the same thread?


Hi Swapnil,

From memory, we accept numbers, strings, dates and tables as input to procedures, and we also support arrays of any of those things.

So yes, that's a valid signature. HOWEVER, our parameters are input only and don't support IN/OUT/INOUT modes. The way you would probably do this kind of thing in VoltDB is to return an array of 3 tables. The first table would simply contain a single column and single row with a long value representing the count.

-John
understood
skashikar
Jun 9, 2010
Hi Swapnil,

From memory, we accept numbers, strings, dates and tables as input to procedures, and we also support arrays of any of those things.

So yes, that's a valid signature. HOWEVER, our parameters are input only and don't support IN/OUT/INOUT modes. The way you would probably do this kind of thing in VoltDB is to return an array of 3 tables. The first table would simply contain a single column and single row with a long value representing the count.

-John


Hi John,

Thanks. that clarifies what I was suspecting. thanks a lot.

Swapnil