casting to counters

Post Reply
bart
Posts: 251
Joined: Wed Apr 26, 2000 12:42 am

casting to counters

Post by bart »

This problem that took a while to figure out. It seems that neither vortex $variables or normal integers get promoted when comparing them to a counter data type.

eg:www% tsql "select message_id from chatmsgs"
Texis Version 05.01.1109947850(20050304) Copyright (c) 1988-2005 Thunderstone EPI

message_id
------------+
4510b39d33
www% tsql "select message_id from chatmsgs where message_id > 1"
Texis Version 05.01.1109947850(20050304) Copyright (c) 1988-2005 Thunderstone EPI

message_id
------------+
www% tsql "select message_id from chatmsgs where message_id > '1'"
Texis Version 05.01.1109947850(20050304) Copyright (c) 1988-2005 Thunderstone EPI

message_id
------------+
4510b39d33
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

casting to counters

Post by mark »

bart
Posts: 251
Joined: Wed Apr 26, 2000 12:42 am

casting to counters

Post by bart »

I simplified my example. The problem was actually discovered in a vortex script where an incoming cgi form variable containing a counter string was used as part of a sql magnitude compare.

ie:

<sql "select mycounters from mystable where mycounters > $form_counter_var">

does not work, but this does:

<$form_counter_var=(convert( $form_counter_var , 'counter' ))>
<sql "select mycounters from mystable where mycounters > $form_counter_var">
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

casting to counters

Post by mark »

Maybe that particular value was all digits and became a long automatically instead of a varchar. If that's the case <sum>ing it with empty string should force it to varchar. <sum "%s" "" $form_counter_var><$form_counter_var=$ret>
Post Reply