cast
Posted in 2003
Topics: General Discussion
Hi,
I have to convert from char to numeric. The thing is that the =
built-in cast does not seem to work because in the following statement =
doesn't return any row,=20
when actually there is one row in the table. What can I do?
Sample - Returning 1 row
select * from clients where code =3D 1234 =20
Sample - Returning 0 row
DEFINE v_Code char(5);
LET v_Code =3D (Select codetxt From TmpCodes);
select * from clients where code =3D v_Code; =20
Note: The Code field in the clients table is numeric.
David
Isn't it difficult to read the =20 =3D nonsense. :-(
I can run "SELECT * FROM Feature_Requests WHERE FR_Num = '152149'" where
FR_Num is an INTEGER column with no problem.
I'm not clear what you expect your line of code LET v_Code = (SELECT
codetxt FROM TmpCodes) to do. It isn't even particularly clear which
language you are using. However, if you want to establish that there's a
problem, you'd have to show code like this I4GL code:
DATABASE whatever
MAIN
DEFINE v_code CHAR(5);
DEFINE r LIKE clients.*
LET v_code = '1234';
SELECT * INTO r.* FROM Clients WHERE code = v_code;IF STATUS = NOTFOUND THEN
DISPLAY "Nothing found!"
ELSE
DISPLAY "Found code = ", r.code
END IF
END MAIN
Without proof positive that v_code contains 1234 before the SELECT is
executed, I'm dubious about your claim.
If you can demonstrate the problem, then you need to provide platform and
version information for both the database server and the client software.
--
Jonathan Leffler (jleffler@us.ibm.com)
STSM, Informix Database Engineering, IBM Data Management Solutions
4100 Bohannon Drive, Menlo Park, CA 94025
Tel: +1 650-926-6921 Tie-Line: 630-6921
"I don't suffer from insanity; I enjoy every minute of it!"
|---------+---------------------------->
| | "Mesa Ayuda" |
| | <mayuda@sunrise-i|
| | t.com.ar> |
| | Sent by: |
| | forum.subscriber@|
| | iiug.org |
| | |
| | |
| | 02/26/2003 06:55 |
| | AM |
| | |
|---------+---------------------------->
>-------------------------------------------------------------------------------
--------------------------------------------------------------|
| |
| To: ids@iiug.org |
| cc: |
| Subject: cast [510] |
| |
| |
>-------------------------------------------------------------------------------
--------------------------------------------------------------|
Hi,
I have to convert from char to numeric. The thing is that the =
built-in cast does not seem to work because in the following statement =
doesn't return any row,=20
when actually there is one row in the table. What can I do?
Sample - Returning 1 row
select * from clients where code =3D 1234 =20
Sample - Returning 0 row
DEFINE v_Code char(5);
LET v_Code =3D (Select codetxt From TmpCodes);
select * from clients where code =3D v_Code; =20
Note: The Code field in the clients table is numeric.
David