# Syntax errors on "insert into"

**URL:** <https://www.ruby-forum.com/t/syntax-errors-on-insert-into/63128>\
**Category:** Rails\
**Created:** [June 12, 2006, 2:32pm UTC](https://www.ruby-forum.com/t/syntax-errors-on-insert-into/63128 "2006-06-12T14:32:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 12, 2006, 2:32pm UTC](https://www.ruby-forum.com/t/syntax-errors-on-insert-into/63128/1 "2006-06-12T14:32:10Z")

</div>

I’m digging around and googling but can’t seem to find what I think is a  
simple thing. All I’m trying to do is insert data in a migration into a  
table, using regular SQL statements.

LIke this:

class AddStateData \< ActiveRecord::Migration  
def self.up

INSERT INTO states values (’’,‘Alaska’);  
INSERT INTO states values (’’, ‘Arkansas’);  
INSERT INTO states VALUES (’’, ‘Arizona’);  
INSERT INTO states VALUES (’’, ‘California’);  
INSERT INTO states VALUES (’’, ‘Colorado’);  
INSERT INTO states VALUES (’’, ‘Connecticut’);  
INSERT INTO states VALUES (’’, ‘District of Columbia’);  
INSERT INTO states VALUES (’’, ‘Delware’);  
INSERT INTO states VALUES (’’, ‘Florida’);  
INSERT INTO states VALUES (’’, ‘Georgia’);  
INSERT INTO states VALUES (’’, ‘Hawaii’);

Pretty simple i think, but in RadRails it shows multiple syntax errors.

Anyone mind telling me what’s wrong ?

TIA  
Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 12, 2006, 2:38pm UTC](https://www.ruby-forum.com/t/syntax-errors-on-insert-into/63128/2 "2006-06-12T14:38:38Z")

</div>

> > > > > “Dark” == Dark A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Anyone mind telling me what’s wrong ?

## You’re putting wodges of one programming language into code written in another one. What on Earth made you think you could just start putting SQL into your Ruby program?

```
	     Calle D. <removed_email_address@domain.invalid>
	 http://www.livejournal.com/users/cdybedahl/
	"Let me answer that question with a headbutt."
	      -- Buffy, Buffy the Vampire Slayer

```

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 12, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/syntax-errors-on-insert-into/63128/3 "2006-06-12T14:44:53Z")

</div>

Good question, with the only answer right now being “I just assume” 😉  
So, I’ll try doing something like this:

State.create(:state =\> ‘New York’,

Stuart

---

<div class="post-metadata">

**Author:** ![Dark\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/48db29/32.png) [@Dark\_A](https://www.ruby-forum.com/u/Dark_A)\
**Post date:** [June 12, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/syntax-errors-on-insert-into/63128/4 "2006-06-12T15:13:23Z")

</div>

Interestingly enough once I got the migration code correct I found out  
that  
there needs to be a model in place . I had made the error of creating  
the  
create table migration code first, then the add data for the table. Once  
I  
created the model though I see it wanted to make the migration for  
creating  
the table but didn’t override the existing file. Once the model was in  
place I could add the data to the table.

Sorry, I’m rambling.  
Stuart
