# Array

**URL:** <https://www.ruby-forum.com/t/array/160891>\
**Category:** Ruby\
**Created:** [February 20, 2009, 5:33pm UTC](https://www.ruby-forum.com/t/array/160891 "2009-02-20T17:33:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vetrivel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vetrivel](https://www.ruby-forum.com/u/vetrivel)\
**Post date:** [February 20, 2009, 5:33pm UTC](https://www.ruby-forum.com/t/array/160891/1 "2009-02-20T17:33:54Z")

</div>

In array I have content like this

```
     a = ["c" , "d", "e" , "f"]

```

But I need like this

```
      'c','d','e','f'

```

I want this for my following purpose  
insert into tablename values a .

a has to subtitude in below statement,.

---

<div class="post-metadata">

**Author:** ![vetrivel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/dc4da7/32.png) [@vetrivel](https://www.ruby-forum.com/u/vetrivel)\
**Post date:** [February 20, 2009, 7:20pm UTC](https://www.ruby-forum.com/t/array/160891/2 "2009-02-20T19:20:10Z")

</div>

On Fri, Feb 20, 2009 at 10:03 PM, Vetrivel V.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In array I have content like this
> 
> ```
> a = ["c" , "d", "e" , "f"]
> 
> ```
> 
> But I need like this
> 
> ```
> 'c','d','e','f'
> 
> ```
> 
> I want this for my following purpose  
> insert into tablename values a .

While the ruby to do that is trivial, i feel its more important that i  
point out you should _never_ construct a SQL statement like this -  
it’s a classic security hole.

[SQL injection - Wikipedia](http://en.wikipedia.org/wiki/SQL_injection) or just google sql  
injection.

Whatever tool you’re using to interface with your database, it will  
certainly have a safe way to pass parameters into a sql statement.  
Please look that up - it will make the world safer and bypass your  
original problem to boot 🙂

Cheers,  
lasitha
