# Syntax error

**URL:** <https://www.ruby-forum.com/t/syntax-error/149892>\
**Category:** Ruby\
**Created:** [September 30, 2008, 10:02pm UTC](https://www.ruby-forum.com/t/syntax-error/149892 "2008-09-30T22:02:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anicoll](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@anicoll](https://www.ruby-forum.com/u/anicoll)\
**Post date:** [September 30, 2008, 10:02pm UTC](https://www.ruby-forum.com/t/syntax-error/149892/1 "2008-09-30T22:02:10Z")

</div>

I’m a perlish person trying to get Ruby to talk to our Oracle 10g  
database. The following program gives me a syntax error I can’t  
resolve. I’ve looked at a lot of the website messages concerning the  
same error an not found anything that points me to a solution. The sql  
runs in TOAD. The caret points to the underbar between aradmin and et.

require ‘oci8’  
conn = OCI8.new(‘sql\_user’, ‘sql\_user05’, ‘AR’)  
cursor = conn.exec(‘SELECT entry\_id, status FROM aradmin.et\_requests  
where entry\_id \> ‘007850’’)  
while r = cursor.fetch()  
puts r.join(’,’)  
end  
cursor.close  
conn.logoff

ruby data2.rb  
data2.rb:3: syntax error, unexpected tINTEGER, expecting ‘)’  
cursor = conn.exec(‘SELECT entry\_id, status FROM aradmin.et\_requests  
where entry\_id \> ‘007850’’)  
^

> Exit code: 1

---

<div class="post-metadata">

**Author:** ![anicoll](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@anicoll](https://www.ruby-forum.com/u/anicoll)\
**Post date:** [September 30, 2008, 10:12pm UTC](https://www.ruby-forum.com/t/syntax-error/149892/2 "2008-09-30T22:12:30Z")

</div>

On Tue, Sep 30, 2008 at 4:01 PM, Alan N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> while r = cursor.fetch()  
> puts r.join(‘,’)  
> end  
> cursor.close  
> conn.logoff
> 
> ruby data2.rb  
> data2.rb:3: syntax error, unexpected tINTEGER, expecting ‘)’  
> cursor = conn.exec(‘SELECT entry\_id, status FROM aradmin.et\_requests  
> where entry\_id \> ‘007850’’)

Check your quotes.

-greg

---

<div class="post-metadata">

**Author:** ![anicoll](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@anicoll](https://www.ruby-forum.com/u/anicoll)\
**Post date:** [September 30, 2008, 10:13pm UTC](https://www.ruby-forum.com/t/syntax-error/149892/3 "2008-09-30T22:13:40Z")

</div>

Alle Tuesday 30 September 2008, Alan N. ha scritto:

> while r = cursor.fetch()
> 
> ```
> ^
> 
> ```
> 
> > Exit code: 1

The single quote before the number closes the string opening at SELECT,  
so  
that ruby sees a string followed by a number, just like:

'abc’123

which isn’t valid ruby syntax. To solve the issue, simply replace the  
single  
quotes around the argument to conn.exec with double quotes:

cursor = conn.exec(“SELECT entry\_id, status FROM aradmin.et\_requests  
where entry\_id \> ‘007850’”).

I hope this helps

Stefano

---

<div class="post-metadata">

**Author:** ![anicoll](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@anicoll](https://www.ruby-forum.com/u/anicoll)\
**Post date:** [September 30, 2008, 10:18pm UTC](https://www.ruby-forum.com/t/syntax-error/149892/4 "2008-09-30T22:18:22Z")

</div>

On Tue, Sep 30, 2008 at 5:01 PM, Alan N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ruby data2.rb  
> data2.rb:3: syntax error, unexpected tINTEGER, expecting ‘)’  
> cursor = conn.exec(‘SELECT entry\_id, status FROM aradmin.et\_requests  
> where entry\_id \> ‘007850’’)

Check the quotes used in the string passed as argument to exec. The  
single quotes used for the ruby string are clashing with the single  
quotes around 007850. Try using “SELECT entry\_id, status FROM  
aradmin.et\_requests where entry\_id \> ‘007850’”.

---

<div class="post-metadata">

**Author:** ![anicoll](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea666f/32.png) [@anicoll](https://www.ruby-forum.com/u/anicoll)\
**Post date:** [September 30, 2008, 10:16pm UTC](https://www.ruby-forum.com/t/syntax-error/149892/5 "2008-09-30T22:16:26Z")

</div>

Stefano C. wrote:

> Alle Tuesday 30 September 2008, Alan N. ha scritto:
> 
> > while r = cursor.fetch()

> which isn’t valid ruby syntax. To solve the issue, simply replace the  
> single  
> quotes around the argument to conn.exec with double quotes:

> I hope this helps
> 
> Stefano

That worked like a charm; debugging is so easy in hindsight.

Thanks  
Nick
