Click here to get back home

binding parameters (timestamp) with DBD::Sybase

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
binding parameters (timestamp) with DBD::Sybase Sharif Islam 04-02-2008
Posted by Sharif Islam on April 2, 2008, 4:22 pm
Please log in for more thread options
I need to run a stored procedure in the MSSQL 2005 server from my linux
machine. It takes a parameter which is timestamp datatype. However, when
I try to use bind_parameter, I get an error:

my $sp_qry = "EXEC MY_STORED_PROC ?" ;
my $sth = $dbh->prepare($sp_qry) ;
$sth->bind_param(1, $row[0], SQL_TIMESTAMP);

Error:

Bareword "SQL_TIMESTAMP" not allowed while "strict subs" in use at
track_changes.pl line 34.
Execution of track_changes.pl aborted due to compilation errors.

If I take out the strict:
DBI::st=HASH(0x9fe7388)->bind_param(...): attribute parameter
'SQL_TIMESTAMP' is not a hash ref at myscript.pl line 32.

line 32 is $sth->bind_param(1, $row[0], SQL_TIMESTAMP);

SQL_TIMESTAMP is not the right type? not supported?

--s

Posted by Ben Morrow on April 2, 2008, 4:38 pm
Please log in for more thread options

> I need to run a stored procedure in the MSSQL 2005 server from my linux
> machine. It takes a parameter which is timestamp datatype. However, when
> I try to use bind_parameter, I get an error:
>
> my $sp_qry = "EXEC MY_STORED_PROC ?" ;
> my $sth = $dbh->prepare($sp_qry) ;
> $sth->bind_param(1, $row[0], SQL_TIMESTAMP);
>
> Error:
>
> Bareword "SQL_TIMESTAMP" not allowed while "strict subs" in use at
> track_changes.pl line 34.
> Execution of track_changes.pl aborted due to compilation errors.

The DBI documentation suggests you need

use DBI qw/:sql_types/;

to import the type constants.

> If I take out the strict:

Don't do that. Unless you already understand what you're doing and why
it is the right thing to do, it never helps.

Ben


Posted by Sharif Islam on April 2, 2008, 5:29 pm
Please log in for more thread options
Ben Morrow wrote:
>> I need to run a stored procedure in the MSSQL 2005 server from my linux
>> machine. It takes a parameter which is timestamp datatype. However, when
>> I try to use bind_parameter, I get an error:
>>
>> my $sp_qry = "EXEC MY_STORED_PROC ?" ;
>> my $sth = $dbh->prepare($sp_qry) ;
>> $sth->bind_param(1, $row[0], SQL_TIMESTAMP);
>>
>> Error:
>>
>> Bareword "SQL_TIMESTAMP" not allowed while "strict subs" in use at
>> track_changes.pl line 34.
>> Execution of track_changes.pl aborted due to compilation errors.
>
> The DBI documentation suggests you need
>
> use DBI qw/:sql_types/;
>
> to import the type constants.

Thanks. But it seems now the datatype is getting set to VARCHAR:

DBD::Sybase::st execute failed: Server message number=257 severity=16
state=3 line=0 server=MSSQL procedure=MY_STORED_PROC text=Implicit
conversion from data type char to timestamp is not allowed. Use the
CONVERT function to run this query. at myscript.pl line 34.


I get the parameter from another query and I save the timestamp value in
a variable, $row[0]:

$qry = SELECT min_active_rowversion()
...
$sth->bind_param(1, $row[0], SQL_TIMESTAMP);


But bind_param suppose set the type to the correct datatype?

--s







Posted by parv on April 4, 2008, 6:27 am
Please log in for more thread options
wrote Sharif Islam ...

> Thanks. But it seems now the datatype is getting set to VARCHAR:
>
> DBD::Sybase::st execute failed: Server message number=257 severity=16
> state=3 line=0 server=MSSQL procedure=MY_STORED_PROC text=Implicit
> conversion from data type char to timestamp is not allowed. Use the
> CONVERT function to run this query. at myscript.pl line 34.

Seems like the problem is with the stored procedure (either in
accepting the parameter or in the query sent to db) as the error
message is coming from the database server.


- parv

--


Similar ThreadsPosted
Problems Binding Parameters for Stored Procedure April 10, 2007, 1:42 pm
dbd-sybase ppd October 22, 2004, 11:18 am
PAR and Sybase::CTlib on HP-UX February 1, 2007, 12:35 pm
how to install Sybase::DBlib??? August 22, 2004, 12:59 am
install_driver(Sybase) failed: February 15, 2006, 4:52 pm
Sybase connection error July 28, 2006, 9:07 am
how to connect to sybase in perl August 21, 2007, 9:02 am
Sybase DBI Returned data query September 9, 2004, 10:22 am
DBD::Sybase : How to get rid of the 255-char limit on varchar? May 15, 2006, 5:13 pm
perl dbi sybase number of columns? December 27, 2006, 5:27 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap