Home > Archive > dBASE Web Applications > March 2006 > Data type conversion









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Data type conversion
Claus Mygind

2006-03-13, 7:23 am

Can the following be done with the SQL Update statement?

take two fields and combine them, one numeric and the other character.

I know the update statement is as follows:

UPDATE tbl_name SET col_name1=col_name2+
col_name3

say
value of col_name2 = 12345
value of col_name3 = "ABC"

Is there in SQL something equivelant to str(col_name2)+col_n
ame3?


Claus Mygind

2006-03-13, 7:23 am

Ok I think I got the first part

UPDATE tbl_name SET col_name1=CONCAT(col
_name2, col_name3)

But what can I do to make sure the converted length of the number in
col_name2 is constant such as the dbase equivelant of variableA =
str(col_name2, 6). So it does not matter if the value of col_name2 is 1 or
100,000 variableA will always be a lenght of 6?


Eric Logan

2006-03-13, 8:23 pm

Claus;
With dBase and other standard SQL systems you use cast() for data type
conversion and '||' for concatenation.
"UPDATE tbl_name SET col_name1 = CAST(col_name2 as char(5))||col_name3"
Cast as char() takes a length parameter. If your SQL system has a 'CONCAT"
function, then it may also have different functions for data type
conversion.
Eric Logan

> "Claus Mygind" wrote ...
> Can the following be done with the SQL Update statement?
> take two fields and combine them, one numeric and the other character.
> I know the update statement is as follows:
> UPDATE tbl_name SET col_name1=col_name2+
col_name3
> say
> value of col_name2 = 12345
> value of col_name3 = "ABC"
> Is there in SQL something equivelant to str(col_name2)+col_n
ame3?


> UPDATE tbl_name SET col_name1=CONCAT(col
_name2, col_name3)






Claus Mygind

2006-03-14, 8:23 pm

Eric,
Thanks for the help. I will check it out.
Claus

"Eric Logan" <jelogan@pcweb.net> wrote in message
news:24oEE8uRGHA.560@news-server...
> Claus;
> With dBase and other standard SQL systems you use cast() for data type
> conversion and '||' for concatenation.
> "UPDATE tbl_name SET col_name1 = CAST(col_name2 as char(5))||col_name3"
> Cast as char() takes a length parameter. If your SQL system has a 'CONCAT"
> function, then it may also have different functions for data type
> conversion.
> Eric Logan
>
>
>
>
>
>
>



Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com