Re: Syntax error



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

.



Relevant Pages

  • Re: VB INSERT INTO
    ... Numeric value shouldn't have quotes around them, so if, for example, ... -2147217900 Syntax error in INSERT INTO statement. ... strSQL" without the quotes. ... Set conDatabase = CurrentProject.Connection ...
    (microsoft.public.access.modulesdaovba)
  • Re: running vbscript syntax error
    ... A string must be passed to the Run method. ... The double quotes in the string are resolved to single quotes. ... To troubleshoot, run a script where you define the value of strCmd as above, ... is a syntax error, perhaps due to unbalanced quotes, you can fix it. ...
    (microsoft.public.scripting.vbscript)
  • Re: Multi Field SQL Where Clause
    ... Yes, it should have been a single quote, not three quotes. ... And the MsgBox should have been "MsgBox strWhere". ... sysNtDvNo = sysPUOHDvNo ... When I remove the two additional quotes the syntax error goes away but the functionality is still absent. ...
    (microsoft.public.access.forms)
  • Re: gawk for windows: system() does not yield exit status
    ... Your syntax throws sytax errors under XP because of the single quotes ... it would throw syntax error on *any* platform (even non- ... Now you might suspect that seterlev does not set the exit code in the ...
    (comp.lang.awk)
  • Re: Need correct conditional statement language
    ... there is a syntax error (comma) in the formula. ... double quotes). ...
    (microsoft.public.access.queries)