By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,558 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,558 IT Pros & Developers. It's quick & easy.

How to convert a string to integer?

P: n/a
How to convert a string like '2,3,4' to three integer 2,3,4 in SQL
procedure of DB2 UDB 8.2?


Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
That depends on a lot of factors. If there are no constraints on the
numbers, use a LOOP to check for ",", then use SUBSTR() to get the
characters, and INTEGER() to turn it into a number.

In other cases a dynamic query may help.

If you could be more specific it would help.


Nov 12 '05 #2

P: n/a
If number of integer is exact three.
For example:
------------------------- Commands Entered -------------------------
, INT(SUBSTR(s3,1,POSSTR(s3,',')-1)) AS First
, INT(DEC(TRANSLATE(SUBSTR(s3,POSSTR(s3,',')+1),'.', ','))) AS
, INT(SUBSTR(s3,LOCATE(',',s3,POSSTR(s3,',')+1)+1)) AS Third
FROM (VALUES '2,3,4', '123,45,6789') Q(s3);

----------- ----------- ----------- -----------
2,3,4 2 3 4
123,45,6789 123 45 6789

2 record(s) selected.

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.