Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-341

[Perl]It cannot insert data by insert index of enum through prepare statement.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: Perl-Apricot
    • Fix Version/s: Perl-Aprium
    • Component/s: Perl Driver
    • Labels:
    • Environment:

      CUBRID9.0.0.0460
      RB9.0.0

      Description

      Repro Steps:

      $dbh=DBI->connect($dsn, $user, $pass,{RaiseError => 1,PrintError=>0,AutoCommit=>0}) or die "connect err: $dbh->errstr";
      
      $dbh -> do("drop table if EXISTS enumb01;") or die "drop error: $dbh->errstr";
      $dbh -> do("create class enumb01(i INT, working_days ENUM('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'),
                  answers ENUM('Yes', 'No', 'Cancel'));") or die "create error: $dbh->errstr";
      my $sth;
      ok($sth=$dbh->prepare("insert into enumb01 values (?,?,?);"),"prepare ok");
      $dbh->{RaiseError}=0;
      $dbh->{PrintError}=1;
      ok($sth->execute(1,1,1),"insert execute ok");
      
      
      $dbh->commit or warn "commit error:$DBI::errstr";
      $sth->finish();
      

      Acutal result:

      [perl@NC-PL-QA030 cases]$ perl testnumber.pl demodb 30022 10.34.64.212              
      ok 1 - prepare ok
      Insert error: CUBRID DBMS Error : (-495) Execute: before ' ,?);'
      Cannot coerce host var to type enum.  at testnumber.pl line 27.
      1..1
      

      Expect result:
      It can insert successfully.

      Additional:
      In csql, it is ok

      csql> prepare t from 'insert into enumb01 values (?,?,?);';
      
      Current transaction has been committed.
      
      1 command(s) successfully processed
      
      csql> execute t using 1,1,1;
      
      1 row affected.
      
      Current transaction has been committed.
      
      1 command(s) successfully processed.
      csql> select * from enumb01;
      
      === <Result of SELECT Command in Line 1> ===
      
                  i  working_days          answers             
      =========================================================
                  1  'Monday'              'Yes'               
      
      
      1 row selected.
      
      Current transaction has been committed.
      
      1 command(s) successfully processed.
      
      1. APIS-341_FIX01.creview
        43 kB
        李金虎
      2. testnumber.pl
        0.9 kB
        高艳铭

        Activity

        Hide
        xiaoshan78 李成龙[이성룡] added a comment -

        It is CCI problem.

        Show
        xiaoshan78 李成龙[이성룡] added a comment - It is CCI problem.
        Hide
        jinhu 李金虎 added a comment -

        Fixed in trunk, Revision: 1401

        How to bind enum data in CUBRID Perl driver
        For example, create table using the below sql:
        CREATE TABLE my_table (answers enum('yes', 'no', 'cancel') );

        There are four ways which are listed in (1)~(4) to bind enum type data in Perl driver:

        {code}
        $sth = $dbh->prepare("INSERT INTO $table VALUES ");
        (1) $sth->bind_param(1, 'no', DBI::SQL_VARCHAR);
        (2) $sth->bind_param(1, 'no');
        (3) $sth->bind_param(1, 2, DBI::SQL_INTEGER);
        (4) $sth->bind_param(1, '2', DBI::SQL_INTEGER);
        $sth->execute();{code}

        So, when binding the enum data with a indexe number, the type (DBI::SQL_INTEGER) is needed.

        The below clauses(1)~(2) which are implicitly binded to character '2' will fail.

        {code}
        (1)$sth->execute(2);
        (2)$sth->execute('2');{code}
        Show
        jinhu 李金虎 added a comment - Fixed in trunk, Revision: 1401 How to bind enum data in CUBRID Perl driver For example, create table using the below sql: CREATE TABLE my_table (answers enum('yes', 'no', 'cancel') ); There are four ways which are listed in (1)~(4) to bind enum type data in Perl driver: {code} $sth = $dbh->prepare("INSERT INTO $table VALUES "); (1) $sth->bind_param(1, 'no', DBI::SQL_VARCHAR); (2) $sth->bind_param(1, 'no'); (3) $sth->bind_param(1, 2, DBI::SQL_INTEGER); (4) $sth->bind_param(1, '2', DBI::SQL_INTEGER); $sth->execute();{code} So, when binding the enum data with a indexe number, the type (DBI::SQL_INTEGER) is needed. The below clauses(1)~(2) which are implicitly binded to character '2' will fail. {code} (1)$sth->execute(2); (2)$sth->execute('2');{code}
        Hide
        jinhu 李金虎 added a comment -

        Resolved.

        Show
        jinhu 李金虎 added a comment - Resolved.
        Hide
        cn14130 欧明宝[Bom Owen] added a comment -

        This issue existed in 9.1.0

        Test case: http://svn.cubrid.org/cubridapis/perl/branches/RB-9.1.0/t2/Perl/_43_enum/cases/testnumber.pl

        Test Environment:

        cubrid_rel:  9.1.0.0201
        perl driver: http://svn.cubrid.org/cubridapis/perl/branches/RB-9.1.0 1499
        perl:  5.14.2
        
        Show
        cn14130 欧明宝[Bom Owen] added a comment - This issue existed in 9.1.0 Test case: http://svn.cubrid.org/cubridapis/perl/branches/RB-9.1.0/t2/Perl/_43_enum/cases/testnumber.pl Test Environment: cubrid_rel: 9.1.0.0201 perl driver: http://svn.cubrid.org/cubridapis/perl/branches/RB-9.1.0 1499 perl: 5.14.2
        Hide
        cn14130 欧明宝[Bom Owen] added a comment -

        modified test case

        Show
        cn14130 欧明宝[Bom Owen] added a comment - modified test case

          People

          • Assignee:
            jinhu 李金虎
            Reporter:
            gaoyanming 高艳铭 (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Due:
              Created:
              Updated:
              Resolved: