Re: FW: How Can I find the ascii value of a char in the stored proced ure?
Posted in 1999
On Mon, 17 May 1999, Girish Kagrana wrote:
>Could you please help in this issue.
There isn't a very clean solution. I guess the best you can do is
create a table of ASCII characters and codes:
CREATE TABLE ASCII
(
Code SMALLINT NOT NULL CHECK (Code BETWEEN 0 AND 255) UNIQUE,
Value CHAR(1) NOT NULL UNIQUE
)
INSERT INTO ASCII VALUES(65, 'A');
INSERT INTO ASCII VALUES(66, 'B'); ...boring...
You can then use this table to implement an ASCII or an ORD function:
CREATE PROCEDURE ASCII(i SMALLINT) RETURNING CHAR(1); DEFINE c CHAR(1);
FOREACH SELECT Value INTO c FROM ASCII WHERE Code = i
RETURN c;
END FOREACH;
LET c = NULL;
RETURN c;
END PROCEDURE;
CREATE PROCEDURE ORD(c CHAR(1)) RETURNING SMALLINT; DEFINE i SMALLINT;
FOREACH SELECT Code INTO i FROM ASCII WHERE Value = c
RETURN i;
END FOREACH;
LET i = NULL;
RETURN i;
END PROCEDURE;
I think that's as good as you can do unless you have IDS/UDO (aka IUS).
>> -----Original Message-----
>> From: Girish Kagrana [SMTP:Girish_Kagrana@Vantive.COM]
>> Sent: Friday, May 14, 1999 7:32 PM
>> To: informix-list@iiug.org
>> Subject: How Can I find the ascii value of a char in the stored procedure?
>>
>>
>> How Can I find the ascii value of a char in the stored procedure?
>>
>> My requirement:
>> To check the character is valid character or not,
>> The invalid character set for my requirement is, whose ascii value is
>> between 1 to 32
>>
>> Since ascii function is not available in Informix(7.3 UC3) stored
>> procedure ,
>> the only option I see is to hardcode those character and then
>> compare,
>>
>> How Can I hard code those characters in the stored procedure, Is it
>> possible with escape sequence ?
Yours,
Jonathan Leffler (jleffler@informix.com) #include <quotes/shakespeare.h>
Guardian of DBD::Informix v0.60 (v0.61_02) -- http://www.perl.com/CPAN
Informix IDN for D4GL & Linux -- http://www.informix.com/idn