RE: Odd issue with DBI/DBD::Sybase

"Wechsler, Steven" <[email protected]> Mon, 11 Feb 2008 17:18:02 -0500
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase
Message-ID <9BFA664319211B4780C5F8A4FB060FF50121A2C1@LAZYTOWN.mtvn.ad.viacom.com>
But why would this have worked previously? And I also tried
$dbh->bind_col(1, $value, {TYPE => SQL_NUMERIC } ), but I still got the
error.


Steve Wechsler | [email protected] 
Sybase/SQL Server/MySQL Database Administrator 
212-846-5683 

MTV Networks 

 

________________________________

From: Jason L. Froebe [mailto:[email protected]] 
Sent: Monday, February 11, 2008 5:14 PM
To: Wechsler, Steven; [email protected]
Subject: Re: Odd issue with DBI/DBD::Sybase


The query after the placeholder value is transformed:

select  UserID, AttributeID, Rank from
nick_user_profile..up_UserAttribute  where UserID = "64152205"

try:

select  UserID, AttributeID, Rank from
nick_user_profile..up_UserAttribute  where UserID =
convert(numeric(8,0), ?)

 
Jason L. Froebe 
 
WebBlog http://jfroebe.livejournal.com
Tech log http://www.froebe.net/blog
Froebe Fibers http://www.froebe-fibers.com 


----- Original Message ----
From: "Wechsler, Steven" <[email protected]>
To: [email protected]
Sent: Monday, February 11, 2008 3:10:08 PM
Subject: Odd issue with DBI/DBD::Sybase



I'm getting this error: 

Unable to retrieve key from seclivesyb02 for 64152205: Implicit
conversion from datatype 'VARCHAR' to 'NUMERIC' is not allowed.  Use the
CONVERT function to run this query.

Here's the prepare statement: 

$data_sth{$server} = $handles{$server}->prepare($sql_template); 

Here's the SQL I'm preparing: 

select  UserID, AttributeID, Rank from
nick_user_profile..up_UserAttribute  where UserID = ? 

Here's the execute statement: 

    $data_sth{$server}->execute(@$row); 

@$row is a list with a single value: 64152205 

And here is the table schema: 

CREATE TABLE dbo.up_UserAttribute
(
    UserID      numeric(8,0) NOT NULL,
    AttributeID smallint     NOT NULL,
    Rank        smallint     NOT NULL,
    IntValue    numeric(8,0) NULL,
    TextCopy    varchar(255) NULL,
    StateID     tinyint      NOT NULL,
    TargetID    numeric(8,0) NULL,
    Title       varchar(255) NULL,
    Link        varchar(255) NULL,
    CONSTRAINT pk_UserAttribute
    PRIMARY KEY CLUSTERED (UserID,AttributeID,Rank)
) 

Now, the really odd thing is that this script worked fine until
recently, when apparently SOMETHING (I'm not sure what) changed, and now
I cannot do any input parameter binding on any table; it always results
in this error.  Any ideas?

Thanks. 



Steve Wechsler | [email protected] 
Sybase/SQL Server/MySQL Database Administrator 
212-846-5683 

MTV Networks