binding parameters (timestamp) with DBD::Sybase

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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);


Bareword "SQL_TIMESTAMP" not allowed while "strict subs" in use at line 34.
Execution of 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 line 32.

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

SQL_TIMESTAMP is not the right type? not supported?


Re: binding parameters (timestamp) with DBD::Sybase

Quoted text here. Click to load it

The DBI documentation suggests you need

    use DBI qw/:sql_types/;

to import the type constants.

Quoted text here. Click to load it

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


Re: binding parameters (timestamp) with DBD::Sybase

Ben Morrow wrote:
Quoted text here. Click to load it

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 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?


Re: binding parameters (timestamp) with DBD::Sybase

wrote Sharif Islam ...

Quoted text here. Click to load it

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


Site Timeline