problem passing parameters to execute sql-query

Discussion in 'Ruby' started by davidbe, Jan 13, 2006.

  1. davidbe

    davidbe Guest

    Hi,

    I'm using Ruby to manipulate data and store it in a (oracle) database
    (using dbi). One column of the table is a NUMBER(6,2) type -- so it
    accepts floating point values.

    The SQL-code I want to execute is:
    @sql_schrijf_bez = "INSERT INTO TESTUSER.BG_BEZETTINGSGEGEVENS
    (JAAR, MAAND, IDLOCATIE, WAARDE, OPLAADDATUM)
    VALUES (?, ?, ?, ?, SYSDATE)"

    "WAARDE" is the NUMBER(6,2)

    When I execute (for example) the next line, I get an ORA-01722-error:
    Invalid number.
    sth_bez.execute(2005, 2, 1000, 5.9)

    When I adjust @sql_schrijf_bez to:
    @sql_schrijf_bez = "INSERT INTO TESTUSER.BG_BEZETTINGSGEGEVENS
    (JAAR, MAAND, IDLOCATIE, WAARDE, OPLAADDATUM)
    VALUES (?, ?, ?, 5.9, SYSDATE)"
    ^^^^^^^

    and

    sth_bez.execute(2005, 2, 1000).

    then there's no problem and the floating point value is stored in the
    database.

    Am I missing something? I don't know what the problem could be... Any
    help is more than welcome!

    Thanks in advance,
    David
     
    davidbe, Jan 13, 2006
    #1
    1. Advertising

  2. davidbe

    davidbe Guest

    Has not anyone any clue how I can find a solution for this problem?

    Kind regards,
    David

    > Hi,
    >
    > I'm using Ruby to manipulate data and store it in a (oracle) database
    > (using dbi). One column of the table is a NUMBER(6,2) type -- so it
    > accepts floating point values.
    >
    > The SQL-code I want to execute is:
    > @sql_schrijf_bez = "INSERT INTO TESTUSER.BG_BEZETTINGSGEGEVENS
    > (JAAR, MAAND, IDLOCATIE, WAARDE, OPLAADDATUM)
    > VALUES (?, ?, ?, ?, SYSDATE)"
    >
    > "WAARDE" is the NUMBER(6,2)
    >
    > When I execute (for example) the next line, I get an ORA-01722-error:
    > Invalid number.
    > sth_bez.execute(2005, 2, 1000, 5.9)
    >
    > When I adjust @sql_schrijf_bez to:
    > @sql_schrijf_bez = "INSERT INTO TESTUSER.BG_BEZETTINGSGEGEVENS
    > (JAAR, MAAND, IDLOCATIE, WAARDE, OPLAADDATUM)
    > VALUES (?, ?, ?, 5.9, SYSDATE)"
    > ^^^^^^^
    >
    > and
    >
    > sth_bez.execute(2005, 2, 1000).
    >
    > then there's no problem and the floating point value is stored in the
    > database.
    >
    > Am I missing something? I don't know what the problem could be... Any
    > help is more than welcome!
    >
    > Thanks in advance,
    > David
     
    davidbe, Jan 16, 2006
    #2
    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. Anonymous
    Replies:
    0
    Views:
    1,550
    Anonymous
    Oct 13, 2005
  2. Daniele Forghieri
    Replies:
    0
    Views:
    76
    Daniele Forghieri
    Mar 28, 2014
  3. Peter Otten
    Replies:
    0
    Views:
    79
    Peter Otten
    Mar 28, 2014
  4. Daniele Forghieri
    Replies:
    0
    Views:
    74
    Daniele Forghieri
    Mar 28, 2014
  5. Peter Otten
    Replies:
    0
    Views:
    83
    Peter Otten
    Mar 28, 2014
Loading...

Share This Page