Re: ruby driver postgresql

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Junkone <junkone1(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ruby driver postgresql
Date: 2006-08-25 13:51:36
Message-ID: 20060825135136.GA49264@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Aug 24, 2006 at 12:11:28PM -0700, Junkone wrote:
> I am using the C driver and am trying to run this statement
> irb(main):020:0> a=conn.exec("select * from exchanges where id=$1",4)
> ArgumentError: wrong number of arguments (2 for 1)
> from (irb):20:in `exec'
> from (irb):20
> from :0
> irb(main):021:0>
>
> I get the error. But the ruby doc stats that i can use this parameteric
> query. any pointers will be useful.

Are you using the ruby-postgres module and looking at the following
documentation or a copy of it?

http://ruby.scripting.ca/postgres/rdoc/

Specifically, is this what you're seeing?

conn.exec(sql, *bind_values)

Sends SQL query request specified by sql to the PostgreSQL.
Returns a PGresult instance on success. On failure, it raises
a PGError exception.

bind_values represents values for the PostgreSQL bind parameters
found in the sql. PostgreSQL bind parameters are presented as $1,
$1, $2, etc.

I just looked through the source code for a few versions of that
module and only the latest snapshot supports multiple arguments for
PGconn#exec. Version 0.7.1 doesn't (that "Release version" is over
3.5 years old!).

--
Michael Fuhr

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Gregory Stark 2006-08-25 14:02:31 Re: SQL:2003 Window Functions for postgresql 8.3?
Previous Message Tom Lane 2006-08-25 13:37:25 Re: Help needed defining timestamp format for input?