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

Cannot bind SEQUENCE type value in Perl

    Details

      Description

      Originally reported by a user at http://www.cubrid.org/questions/677557.

      I was trying to insert a value into a table column within a Perl script and using the DBD::cubrid module (v9.1.0.0001, server v9.1.0) with type SEQUENCE and it failed with:

      "CUBRID DBMS Error : (-494) Semantic: Cannot coerce host var to type sequence. at ... line ..."

      This was my first attempt and the script was using parameters. My workaround for the moment is to NOT use parameters, like in the second attempt.

      {code}
      #!/bin/env perl
      #
      # CREATE TABLE test_seq (
      # tags SEQUENCE (VARCHAR(512))
      # );

      use strict;
      use warnings;
      use DBI;

      my $dbname = 'test_sequence';
      my $host = 'localhost';
      my $port = '33000';
      my $user = 'user';
      my $pass = 'pass',

      my $dsn = qq{dbi:cubrid:database=$dbname;host=$host;port=$port};
      my $dbh = DBI->connect(
      $dsn, $user, $pass,
      { AutoCommit => 1, RaiseError => 1, PrintError => 1, }
      ) or die $DBI::errstr;{code}

      my $tag = q(

      {'tag1','tag2'}

      ); # also tried "

      {'tag1'}

      " and '

      {"tag1"}

      ' ...

      $dbh->do( qq

      { INSERT INTO test_seq ( tags ) VALUES (?) }

      , undef, $tag )
      or die $DBI::errstr; # CUBRID DBMS Error : (-494)

      $dbh->do( qq

      { INSERT INTO test_seq ( tags ) VALUES ($tag) }

      )
      or die $DBI::errstr; # This is OK

      My question is: have I done something wrong or this feature is not yet implemented for type SEQUENCE?

        Activity

        Hide
        cn15800 谢韦华[Bert] added a comment - - edited

        test case

        {code}
        #!/bin/env perl
        #
        # CREATE TABLE test_seq (
        # tags SEQUENCE (VARCHAR(512))
        # );

        use strict;
        use warnings;
        use DBI qw(:sql_types);

        my $dbname = 'demodb';
        my $host = '10.34.64.218';
        my $port = '33000';
        my $user = 'dba';
        my $pass = '',

        my $dsn = qq{dbi:cubrid:database=$dbname;host=$host;port=$port};
        my $dbh = DBI->connect(
        $dsn, $user, $pass,
        { AutoCommit => 1, RaiseError => 1, PrintError => 0, }
        ) or die $DBI::errstr;

        my $sth = $dbh->prepare("DROP TABLE if exists test_seq");
        $sth->execute;
        $sth = $dbh->prepare("CREATE TABLE test_seq (tags SEQUENCE (VARCHAR(512)))");
        $sth->execute;

        my @av_data=[ 'John1', 'Mary2', 'Tim3' ,'ttt4','hah5'];

        $sth = $dbh->prepare("INSERT INTO test_seq ( tags ) VALUES ");

        $sth->bind_param(1,@av_data) or die "bind_param error: $dbh->errstr";
        $sth->execute();{code}
        Show
        cn15800 谢韦华[Bert] added a comment - - edited test case {code} #!/bin/env perl # # CREATE TABLE test_seq ( # tags SEQUENCE (VARCHAR(512)) # ); use strict; use warnings; use DBI qw(:sql_types); my $dbname = 'demodb'; my $host = '10.34.64.218'; my $port = '33000'; my $user = 'dba'; my $pass = '', my $dsn = qq{dbi:cubrid:database=$dbname;host=$host;port=$port}; my $dbh = DBI->connect( $dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0, } ) or die $DBI::errstr; my $sth = $dbh->prepare("DROP TABLE if exists test_seq"); $sth->execute; $sth = $dbh->prepare("CREATE TABLE test_seq (tags SEQUENCE (VARCHAR(512)))"); $sth->execute; my @av_data=[ 'John1', 'Mary2', 'Tim3' ,'ttt4','hah5']; $sth = $dbh->prepare("INSERT INTO test_seq ( tags ) VALUES "); $sth->bind_param(1,@av_data) or die "bind_param error: $dbh->errstr"; $sth->execute();{code}
        Hide
        cn15800 谢韦华[Bert] added a comment - - edited

        $sth->bind_param(index,data,data_type):

        If data is array, driver will process it as sequence, for example:

        index = 1;
        data = [ 'John1', 'Mary2', 'Tim3' ,'ttt4','hah5']

        Show
        cn15800 谢韦华[Bert] added a comment - - edited $sth->bind_param(index,data,data_type): If data is array, driver will process it as sequence, for example: index = 1; data = [ 'John1', 'Mary2', 'Tim3' ,'ttt4','hah5']
        Hide
        cn15800 谢韦华[Bert] added a comment -

        Now driver didn't support set(bit), because ther is anther problem: http://www.jira.cubrid.org/browse/APIS-586

        Show
        cn15800 谢韦华[Bert] added a comment - Now driver didn't support set(bit), because ther is anther problem: http://www.jira.cubrid.org/browse/APIS-586
        Hide
        ryin005 Ray Yin added a comment -

        Add a test case for this issue

        RB-8.4.4

        [perl@NC-PL-QA011 Perl]$ svn ci --username cn14323 -m "[NOISSUE] add _48_issues folder to stores all the apis issue test cases"
        Adding         Perl/_48_issues
        Adding         Perl/_48_issues/_13_2H
        Adding         Perl/_48_issues/_13_2H/apis_516
        Adding         Perl/_48_issues/_13_2H/apis_516/cases
        Adding         Perl/_48_issues/_13_2H/apis_516/cases/answer
        Adding         Perl/_48_issues/_13_2H/apis_516/cases/answer/bind_sequence.answer
        Adding         Perl/_48_issues/_13_2H/apis_516/cases/apis_516.sh
        Adding         Perl/_48_issues/_13_2H/apis_516/cases/bind_sequence.pl
        Transmitting file data .....
        Committed revision 37307.
        

        Link: http://svn.bds.nhncorp.com/xdbms/cubridqa/branches/RB-8.4.4/interface/Perl/scenario/Perl/_48_issues/_13_2H/apis_516/cases/

        Show
        ryin005 Ray Yin added a comment - Add a test case for this issue RB-8.4.4 [perl@NC-PL-QA011 Perl]$ svn ci --username cn14323 -m "[NOISSUE] add _48_issues folder to stores all the apis issue test cases" Adding Perl/_48_issues Adding Perl/_48_issues/_13_2H Adding Perl/_48_issues/_13_2H/apis_516 Adding Perl/_48_issues/_13_2H/apis_516/cases Adding Perl/_48_issues/_13_2H/apis_516/cases/answer Adding Perl/_48_issues/_13_2H/apis_516/cases/answer/bind_sequence.answer Adding Perl/_48_issues/_13_2H/apis_516/cases/apis_516.sh Adding Perl/_48_issues/_13_2H/apis_516/cases/bind_sequence.pl Transmitting file data ..... Committed revision 37307. Link: http://svn.bds.nhncorp.com/xdbms/cubridqa/branches/RB-8.4.4/interface/Perl/scenario/Perl/_48_issues/_13_2H/apis_516/cases/
        Hide
        ryin005 Ray Yin added a comment -

        Test OS: Linux64bit, Windows32bit
        CUBRID: 8.4.4.0227
        Perl: 5.18.0, 5.16.3
        Driver: cubrid-perl 8.4.4.0002

        Test Result: PASS

        Show
        ryin005 Ray Yin added a comment - Test OS: Linux64bit, Windows32bit CUBRID: 8.4.4.0227 Perl: 5.18.0, 5.16.3 Driver: cubrid-perl 8.4.4.0002 Test Result: PASS

          People

          • Assignee:
            cn15800 谢韦华[Bert]
            Reporter:
            kadishmal Esen Sagynov
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: