DBI and placeholders

Hi,
Is there a way to execute a statement, passing in an array for the bind variables? If I use

sth.execute(array[0],array[1],array[2])

Everything works fine, but if I just use

sth.execute(array)

I get a ‘not all variables bound’ error. Am I missing something?

Marty

An asterisk :slight_smile:

try

sth.execute(*array)

Cheers

Dave

···

On Tuesday, Feb 18, 2003, at 16:31 US/Central, Martin Bonner wrote:

Hi,
Is there a way to execute a statement, passing in an array for the
bind variables? If I use

sth.execute(array[0],array[1],array[2])

Everything works fine, but if I just use

sth.execute(array)

I get a ‘not all variables bound’ error. Am I missing something?

To make an array expand into across the parameter list for a method, use
the * operator.
sth.execute(*array)

···

On Wed, 19 Feb 2003 07:31:36 +0900, Martin Bonner wrote:

Hi,
Is there a way to execute a statement, passing in an array for the
bind variables? If I use

sth.execute(array[0],array[1],array[2])

Everything works fine, but if I just use

sth.execute(array)

I get a ‘not all variables bound’ error. Am I missing something?

Marty

Ahh, I see. Thank you.

Marty

···

----- Original Message -----
From: “Gabriel Emerson” gemerson@evalsoft.com
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Tuesday, February 18, 2003 4:49 PM
Subject: Re: DBI and placeholders

To make an array expand into across the parameter list for a method, use
the * operator.
sth.execute(*array)

On Wed, 19 Feb 2003 07:31:36 +0900, Martin Bonner wrote:

Hi,
Is there a way to execute a statement, passing in an array for the
bind variables? If I use

sth.execute(array[0],array[1],array[2])

Everything works fine, but if I just use

sth.execute(array)

I get a ‘not all variables bound’ error. Am I missing something?

Marty