dbd informix / INTERVAL problems
Posted in 2000
Topics: Stored Procedures & SPL, Data Types & Schema Design
Hello, I'm trying to return an INTERVAL to a perl DBD::Informix client program. I can't do this (DBD::Informix::st fetchrow_array failed: SQL: -1260: It is not possible to convert between the specified types.), and I can't seem to work out how to convert this interval (calculation) into any useful data type. Any suggestions (short of implementing this query as a stored procedure ... writing things through to a temp table?) -- ben
Ben Gould <ben.gould@none.net> wrote: > I'm trying to return an INTERVAL to a perl DBD::Informix client program. > > I can't do this (DBD::Informix::st fetchrow_array failed: SQL: -1260: > It is not possible to convert between the specified types.), and I > can't seem to work out how to convert this interval (calculation) into > any useful data type. > > Any suggestions (short of implementing this query as a stored procedure > ... writing things through to a temp table?) Please produce a minimal, self-contained test case that shows the problem. Please also report the details requested in the documentation! Counter example: #!/usr/bin/perl -w # Minimal test case that intervals work! use DBD::Informix::TestHarness; $dbh = connect_to_test_database({RaiseError=>1}); $dbh->do(q%create temp table x(y datetime year to second, z datetime year to month)%); $dbh->do(q%insert into x values('2000-01-01 00:00:00', '2000-01')%); $sth = $dbh->prepare(q%select current year to second - y, current year to month - z from x%); $sth->execute; $ref = $sth->fetchrow_arrayref(); print "Row: interval 1 = $$ref[0]; interval 2 = $$ref[1]\\n"; $sth->finish; $dbh->disconnect; For me, this produced the output: # DBI->connect('dbi:Informix:stores', '', ''); # Connect Attribute: RaiseError => 1 Row: interval 1 = 248 10:27:04; interval 2 = 0-08 I also checked a variant using: @row = $sth->fetchrow_array(); print "Row: interval 1 = $row[0]; interval 2 = $row[1]\\n"; This also produced a similar answer. I'm using a Sun Ultra Sparc 10 running Solaris 7, GCC 2.95.2, ESQL/C 9.30.UC1 (CSDK 2.40.UC1), IDS.2000 9.20.UC1, Perl 5.6.0, DBI 1.14, DBD::Informix 1.00.PC1. -- Yours, Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h> Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN "I don't suffer from insanity; I enjoy every minute of it!"