[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Syntax error

Alan Nicoll

9/30/2008 8:01:00 PM

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
--
Posted via http://www.ruby-....

4 Answers

Gregory Brown

9/30/2008 8:07:00 PM

0

On Tue, Sep 30, 2008 at 4:01 PM, Alan Nicoll <alan.nicoll@xerox.com> wrote:
> 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'')

Check your quotes.

-greg

--
Technical Blaag at: http://blog.majesticseacr... | Non-tech
stuff at: http://metametta.bl...

Stefano Crocco

9/30/2008 8:09:00 PM

0

Alle Tuesday 30 September 2008, Alan Nicoll ha scritto:
> 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

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

Alan Nicoll

9/30/2008 8:15:00 PM

0

Stefano Crocco wrote:
> Alle Tuesday 30 September 2008, Alan Nicoll 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
--
Posted via http://www.ruby-....

Luis Parravicini

9/30/2008 8:17:00 PM

0

On Tue, Sep 30, 2008 at 5:01 PM, Alan Nicoll <alan.nicoll@xerox.com> 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'".
> where entry_id > '007850''

--
Luis Parravicini
http://ktulu.co...