Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Do placeholders work in SET clause of UPDATE query for column datatype of UNSIGNED INT in ASE 15.7+?

After much time wasting I found -- with DBI 1.625, DBD::Sybase 1.14, & ASE 15.7 -- that ...

  • VARCHAR datatype is being used for column of UNSIGNED INT datatype in SET clause of UPDATE query when placeholder is used. The error message is similar to ...
    DBD::Sybase::st execute failed: Server message number=257 severity=16 +state=1 line=0 server=DB_SERVER procedure=DBD2 text=Implicit conversi +on from datatype 'VARCHAR' to 'UNSIGNED INT' is not allowed. Use the + CONVERT function to run this query. Statement= UPDATE db..table SET col = :p1 -- %d WHERE search_col = :p2
  • neither does explicitly setting the datatype help: $sth->bind_param( $place , $var , SQL_INTEGER ) as it produces same error as above;
  • neither does CONVERT function works per above error message (besides the point that I question the value of using a placeholder at all in this case); the following error message is noted in DBD::Sybase ...
    DBD::Sybase::db prepare failed: Server message number=12828 severity=1 +6 state=1 line=1 server=DB_SERVER procedure=DBD2 text=The datatype of + a parameter marker used in the dynamic prepare statement could not b +e resolved. Statement= UPDATE db..table SET col = --? CONVERT( UNSIGNED INT , :p1 ) -- %d WHERE search_col = :p2
  • there is no problem with datatype of numeric(9,0), or after embedding the value right in SQL string sans placeholder;

By way of crude, untested but representative code ...

# SQL. create table pqr ( x numeric(9,0) not null , y unsigned int not null ) insert into pqr values( 0 , 0 ) # Perl $n = 1; # Works. $dbh->do( q/UPDATE pqr SET x = ?/ , undef , $n ); $n = 2; # Fails; $dbh->do( q/UPDATE pqr SET y = ?/ , undef , $n ); $n = 3; # works (same as %s, this is all string in the end). $dbh->do( sprintf q/UPDATE pqr SET y = %d/ , $n );

In reply to DBI 1.625, DBD::Sybase 1.14, ASE 15.7: no placeholder support for UNSIGNED INT datatype in SET clause by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (5)
    As of 2020-11-29 05:31 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found