Page 1 of 1

casting to counters

Posted: Wed Sep 20, 2006 8:42 am
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

casting to counters

Posted: Wed Sep 20, 2006 10:49 am
by mark
There's no conversion between integer and counter.
For varchar, the string should be 9-16 hex digits, '000000001'

See also http://thunderstone.master.com/texis/ma ... 3e19ffa611

casting to counters

Posted: Wed Sep 20, 2006 11:16 am
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">

casting to counters

Posted: Wed Sep 20, 2006 11:54 am
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>