Inserting number into CHAR field

Post Reply
User avatar
Thunderstone
Site Admin
Posts: 2504
Joined: Wed Jun 07, 2000 6:20 pm

Inserting number into CHAR field

Post by Thunderstone »



Hello,

A table field that is defined as char(8) and a variable that has always
held a number. Upon doing an insert the table field is empty. How can I
convert the int var to a string so I can insert it into the field?

-rob out



User avatar
Thunderstone
Site Admin
Posts: 2504
Joined: Wed Jun 07, 2000 6:20 pm

Inserting number into CHAR field

Post by Thunderstone »




I'm not sure where you are finding a field with a definition of char(8)
in Webinator, however variables can be converted with a convert call, for
example:

<$x=(convert($y, 'varchar' ))>

The reason it does not work is that char(8) is not large enough to hold
the largest number that a variable could hold, so the direct assignment
will not work.


User avatar
Thunderstone
Site Admin
Posts: 2504
Joined: Wed Jun 07, 2000 6:20 pm

Inserting number into CHAR field

Post by Thunderstone »




If the context you are asking this question in is within
Texis web script (vortex) and the variable is a CGI var:

<sum "%s" $IntVar>
<$StringVar=$ret>
<sql "insert into mytable values ($NowAString)">


tsql "insert into mytable values ('1')"




Post Reply