Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > ruby9i bind_param errors

Reply
Thread Tools

ruby9i bind_param errors

 
 
Carlos Diaz
Guest
Posts: n/a
 
      10-09-2005
Hi,

I've been looking around and I just can't seem to find too much
documentation on ruby9i. The only thing that I found gives a very
high-level explanation of how to use bind variables when talking to an
oracle 9i database. Here is how they explain the bind_param method:

-----------------BEGIN QUOTE-------
Synopsis

statementObj.bind_param(label, bindvar)
Description

#bind_param binds bindvar to the parameter named label.

Bind variables are used for input of parameters in a DML statement or
for either input and output of parameters in a call to a stored
procedure or function.

---------------------END QUOTE--------------

Ok, so that seems pretty straight forward right? Well here is my code:

---------------------BEGIN MY CODE--------------

stmt =3D dbh.prepare("select value from v$segment_statistics
where statistic_name =3D :stat_name
and object_name =3D :t_name
and tablspace_name =3D :ts_name;")

table_name =3D "SOME_TABLE"
tablespace_name =3D "SOME_TABLESPACE"
stmt.bind_param("stat_name", "db block changes")
stmt.bind_pram("t_name", "#{table_name}")
stmt.bind_param("ts_name", "#{tablespace_name}")
stmt.execute
-------------------------END MY CODE-----------------

However, when I run this code snippet, I get an error saying that that
'bind_param' could not bind the varialbe in "stmt_bind_param". Here
is an a copy of the error:

----------------BEGIN ERROR-----------------
in `bind_param': Could not bind variable in "stmt_bind_param" in file
"statement.c" at line 108 (Ruby9i::Error)
ORA-01036: illegal variable name/number
----------------END ERROR------------------

Anyone run into anything like this that would be able to point me in
the right direction?

Thanks in advance.
-Carlos


 
Reply With Quote
 
 
 
 
Carlos Diaz
Guest
Posts: n/a
 
      10-09-2005
By the way, this is failing as soon as it tries to bind the first param.

On 10/8/05, Carlos Diaz <(E-Mail Removed)> wrote:
> Hi,
>
> I've been looking around and I just can't seem to find too much
> documentation on ruby9i. The only thing that I found gives a very
> high-level explanation of how to use bind variables when talking to an
> oracle 9i database. Here is how they explain the bind_param method:
>
> -----------------BEGIN QUOTE-------
> Synopsis
>
> statementObj.bind_param(label, bindvar)
> Description
>
> #bind_param binds bindvar to the parameter named label.
>
> Bind variables are used for input of parameters in a DML statement or
> for either input and output of parameters in a call to a stored
> procedure or function.
>
> ---------------------END QUOTE--------------
>
> Ok, so that seems pretty straight forward right? Well here is my code:
>
> ---------------------BEGIN MY CODE--------------
>
> stmt =3D dbh.prepare("select value from v$segment_statistics
> where statistic_name =3D :stat_name
> and object_name =3D :t_name
> and tablspace_name =3D :ts_name;")
>
> table_name =3D "SOME_TABLE"
> tablespace_name =3D "SOME_TABLESPACE"
> stmt.bind_param("stat_name", "db block changes")
> stmt.bind_pram("t_name", "#{table_name}")
> stmt.bind_param("ts_name", "#{tablespace_name}")
> stmt.execute
> -------------------------END MY CODE-----------------
>
> However, when I run this code snippet, I get an error saying that that
> 'bind_param' could not bind the varialbe in "stmt_bind_param". Here
> is an a copy of the error:
>
> ----------------BEGIN ERROR-----------------
> in `bind_param': Could not bind variable in "stmt_bind_param" in file
> "statement.c" at line 108 (Ruby9i::Error)
> ORA-01036: illegal variable name/number
> ----------------END ERROR------------------
>
> Anyone run into anything like this that would be able to point me in
> the right direction?
>
> Thanks in advance.
> -Carlos
>



 
Reply With Quote
 
 
 
 
Carlos Diaz
Guest
Posts: n/a
 
      10-09-2005
Ok, I feel like an idiot. I just found my error. There is no problem
with the bind_param method. The problem I was running into is that I
had a for loop where I was using another instance of the variable
stmt, which happens to be the same name as I was using in the for the
stmt I was trying to bind my variable to. So, to make a long story
short, I was trying to bind a parameter to the wrong statement.



On 10/8/05, Carlos Diaz <(E-Mail Removed)> wrote:
> By the way, this is failing as soon as it tries to bind the first param.
>
> On 10/8/05, Carlos Diaz <(E-Mail Removed)> wrote:
> > Hi,
> >
> > I've been looking around and I just can't seem to find too much
> > documentation on ruby9i. The only thing that I found gives a very
> > high-level explanation of how to use bind variables when talking to an
> > oracle 9i database. Here is how they explain the bind_param method:
> >
> > -----------------BEGIN QUOTE-------
> > Synopsis
> >
> > statementObj.bind_param(label, bindvar)
> > Description
> >
> > #bind_param binds bindvar to the parameter named label.
> >
> > Bind variables are used for input of parameters in a DML statement or
> > for either input and output of parameters in a call to a stored
> > procedure or function.
> >
> > ---------------------END QUOTE--------------
> >
> > Ok, so that seems pretty straight forward right? Well here is my code:
> >
> > ---------------------BEGIN MY CODE--------------
> >
> > stmt =3D dbh.prepare("select value from v$segment_statistics
> > where statistic_name =3D :stat_name
> > and object_name =3D :t_name
> > and tablspace_name =3D :ts_name;")
> >
> > table_name =3D "SOME_TABLE"
> > tablespace_name =3D "SOME_TABLESPACE"
> > stmt.bind_param("stat_name", "db block changes")
> > stmt.bind_pram("t_name", "#{table_name}")
> > stmt.bind_param("ts_name", "#{tablespace_name}")
> > stmt.execute
> > -------------------------END MY CODE-----------------
> >
> > However, when I run this code snippet, I get an error saying that that
> > 'bind_param' could not bind the varialbe in "stmt_bind_param". Here
> > is an a copy of the error:
> >
> > ----------------BEGIN ERROR-----------------
> > in `bind_param': Could not bind variable in "stmt_bind_param" in file
> > "statement.c" at line 108 (Ruby9i::Error)
> > ORA-01036: illegal variable name/number
> > ----------------END ERROR------------------
> >
> > Anyone run into anything like this that would be able to point me in
> > the right direction?
> >
> > Thanks in advance.
> > -Carlos
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OCI-8, Oracle : 'ORDER BY' doesn't work with 'bind_param' B. Randy Ruby 5 04-21-2009 02:21 PM
DBI stateHandler bind_param errors David Lee Ruby 0 10-10-2007 01:39 AM
Attribute Parameter Problem with bind_param( ) pnstarr@gmail.com Perl Misc 6 09-11-2006 09:00 PM
[WIN] Ruby9i compiled using MSVC++ 6.0 Shashank Date Ruby 2 07-07-2003 12:19 PM
Ruby9i now available Jim Cain Ruby 12 07-03-2003 05:34 PM



Advertisments