# Re: Passing an array to DBI statement execute

**URL:** <https://www.ruby-forum.com/t/re-passing-an-array-to-dbi-statement-execute/95385>\
**Category:** Ruby\
**Created:** [May 30, 2006, 10:34pm UTC](https://www.ruby-forum.com/t/re-passing-an-array-to-dbi-statement-execute/95385 "2006-05-30T22:34:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [May 30, 2006, 10:34pm UTC](https://www.ruby-forum.com/t/re-passing-an-array-to-dbi-statement-execute/95385/1 "2006-05-30T22:34:49Z")

</div>

> table. Here is my script:  
> values = [id]  
> values.concat line.chomp.split("\t")  
> (10…12).each {|x| values[x] = Time.parse(values[x])  
> unless values[x].nil? || values[x].strip == “”}  
> sth.execute(values)

sth.execute(\*values)

You need to flatten the list here. Otherwise, you’re just passing a  
single array.

Regards,

Dan

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [May 30, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/re-passing-an-array-to-dbi-statement-execute/95385/2 "2006-05-30T22:47:31Z")

</div>

that’s it, thanks

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [May 30, 2006, 11:09pm UTC](https://www.ruby-forum.com/t/re-passing-an-array-to-dbi-statement-execute/95385/3 "2006-05-30T23:09:15Z")

</div>

Ok, well, now it executes and seems like it is working, except nothing  
ends  
up in my database. Any ideas? Is there any way to print out what sql  
statement it is trying to execute? I can’t find any API docs for DBI.

Also, is DBI smart enough to figure out how to convert the Time objects  
into  
the correct format for the database?
