MS SQL server Insert Error [109]

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Murali Kanaga

    MS SQL server Insert Error [109]

    Greetings!

    When I run the following SQL statement in Perl, I get an error
    stating:
    any help/pointers how this can be resolved?

    Thanks,
    -Murali

    SQL note_insert error: [109] [2] [0] "[Microsoft][ODBC SQL Server
    Driver][SQL Server]There are more columns in the INSERT statement than
    values specified in the VALUES clause. The number of values in the
    VALUES clause must match the number of columns specified in the INSERT
    statement."

    The perl code:

    $sql_stmt1 = "select cast(newid () as varbinary(16)) as notes_id
    from cc_test";

    if($db_ends->Sql($sql_stmt1 ))
    {
    $db_ends->Error();
    exit(-1);
    }

    while($db_ends->FetchRow())
    {
    undef %Data;
    %Data = $db_ends->DataHash();
    $notes_id = $Data{"notes_id "};
    }

    # Prepare the columns for insert

    my $updated_detail = "$pn . $cc_ver\n";

    my $note_columns = "user_note_ id, bio_name, related_tbl_nam e,
    related_string_ id, related_int_id, note_type_lkp, notes,
    internal_flag, revision_number , obsolete_flag";

    my $note_values = "cast(" +$notes_Id + "as binary(16)), Null, Null,
    Null, $bfn, 0x74942E5A0A040 22800415DE63529 D4B7, $notes_detail, 0, 0,
    0";

    $sql_note_inser t = "insert into user_note ($note_columns) values
    ($note_values)" ;

    if($db_ends->Sql($sql_note_ insert))
  • Gert-Jan Strik

    #2
    Re: MS SQL server Insert Error [109]

    Make sure you delimit all strings with single quotes ('). If one of the
    current variables (such as $note_details) contains a comma, then you
    will have more "values" than "columns".

    If this doesn't work, then please post the actual query you are
    submitting to SQL-Server.

    Hope this helps,
    Gert-Jan


    Murali Kanaga wrote:[color=blue]
    >
    > Greetings!
    >
    > When I run the following SQL statement in Perl, I get an error
    > stating:
    > any help/pointers how this can be resolved?
    >
    > Thanks,
    > -Murali
    >
    > SQL note_insert error: [109] [2] [0] "[Microsoft][ODBC SQL Server
    > Driver][SQL Server]There are more columns in the INSERT statement than
    > values specified in the VALUES clause. The number of values in the
    > VALUES clause must match the number of columns specified in the INSERT
    > statement."
    >
    > The perl code:
    >
    > $sql_stmt1 = "select cast(newid () as varbinary(16)) as notes_id
    > from cc_test";
    >
    > if($db_ends->Sql($sql_stmt1 ))
    > {
    > $db_ends->Error();
    > exit(-1);
    > }
    >
    > while($db_ends->FetchRow())
    > {
    > undef %Data;
    > %Data = $db_ends->DataHash();
    > $notes_id = $Data{"notes_id "};
    > }
    >
    > # Prepare the columns for insert
    >
    > my $updated_detail = "$pn . $cc_ver\n";
    >
    > my $note_columns = "user_note_ id, bio_name, related_tbl_nam e,
    > related_string_ id, related_int_id, note_type_lkp, notes,
    > internal_flag, revision_number , obsolete_flag";
    >
    > my $note_values = "cast(" +$notes_Id + "as binary(16)), Null, Null,
    > Null, $bfn, 0x74942E5A0A040 22800415DE63529 D4B7, $notes_detail, 0, 0,
    > 0";
    >
    > $sql_note_inser t = "insert into user_note ($note_columns) values
    > ($note_values)" ;
    >
    > if($db_ends->Sql($sql_note_ insert))[/color]

    Comment

    Working...