ruby9i bind_param errors

C

Carlos Diaz

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
 
C

Carlos Diaz

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top