ruby9i bind_param errors

Discussion in 'Ruby' started by Carlos Diaz, Oct 9, 2005.

  1. Carlos Diaz

    Carlos Diaz Guest

    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
     
    Carlos Diaz, Oct 9, 2005
    #1
    1. Advertising

  2. Carlos Diaz

    Carlos Diaz Guest

    By the way, this is failing as soon as it tries to bind the first param.

    On 10/8/05, Carlos Diaz <> 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
    >
     
    Carlos Diaz, Oct 9, 2005
    #2
    1. Advertising

  3. Carlos Diaz

    Carlos Diaz Guest

    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 <> wrote:
    > By the way, this is failing as soon as it tries to bind the first param.
    >
    > On 10/8/05, Carlos Diaz <> 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
    > >

    >
    >
     
    Carlos Diaz, Oct 9, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Cain

    Ruby9i now available

    Jim Cain, Jul 2, 2003, in forum: Ruby
    Replies:
    12
    Views:
    244
    Daniel Berger
    Jul 3, 2003
  2. Shashank Date

    [WIN] Ruby9i compiled using MSVC++ 6.0

    Shashank Date, Jul 4, 2003, in forum: Ruby
    Replies:
    2
    Views:
    89
    Shashank Date
    Jul 7, 2003
  3. David Lee
    Replies:
    0
    Views:
    103
    David Lee
    Oct 10, 2007
  4. B. Randy
    Replies:
    5
    Views:
    212
    B. Randy
    Apr 21, 2009
  5. Replies:
    6
    Views:
    266
    Tad McClellan
    Sep 11, 2006
Loading...

Share This Page