Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread ASCII and CHR functions ?
Mon, Sep 26 2011 2:10 PMPermanent Link

mferan

Hi,

Does Elevate have the equivalent of the SQL functions ASCII and CHR found in other implementations?  I couldn't find anything in the docs.


Thanks
Mon, Oct 3 2011 9:10 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Does Elevate have the equivalent of the SQL functions ASCII and CHR found
in other implementations?  I couldn't find anything in the docs. >>

Are you looking to just insert a specific character as a constant ?  If so,
then you can just use this:

SELECT 'This is on one line'+#13+#10+'This is on a different line'
FROM MyTable

--
Tim Young
Elevate Software
www.elevatesoft.com
Wed, Oct 5 2011 8:46 PMPermanent Link

mferan

"Tim Young [Elevate Software]" wrote:

<< Does Elevate have the equivalent of the SQL functions ASCII and CHR found
in other implementations?  I couldn't find anything in the docs. >>

Are you looking to just insert a specific character as a constant ?  If so,
then you can just use this:

SELECT 'This is on one line'+#13+#10+'This is on a different line'
FROM MyTable

--
Tim Young
Elevate Software
www.elevatesoft.com


Hi Tim,

No, a table of mine has a character field defined as a space if the entry is current or A,B,C,D, etc.  if the entry represents an older "retired" entry.  I just wanted to be able to convert this A,B, etc to a number the same way I can with my-sql by saying I =  ASC(f_stat_field) - 65 to have I=0 when the field is 'A', 1 when the field is 'B', etc.    

Thanks
Thu, Oct 6 2011 3:11 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

mferan


For that you could use POSITION eg

POSITION(f_stat_field IN 'ABCDEFG.....')

You could also create your own function using Tim's SQL/PSM which you can then call so you can have exactly the same call as in mysql.

Roy Lambert [Team Elevate]
Thu, Oct 6 2011 3:38 AMPermanent Link

Adam Brett

Orixa Systems

Dear mferan,

There are a good number of internal functions in EDB such as:

SUBSTRING
LENGTH
OCCURS
POSITION

which can be used to determine whether particular CHARs or strings occur in a source field, or to copy out subsections of a field to do comparisons on.

You also have IF

i.e.

IF(SubString(somefield FROM 4 FOR 1) = 'A' THEN DoSomething ELSE DoSomethingElse)

--

I don't think there is an ASCI function to convert a CHAR to its ASCI representation, but I have never needed to use one myself, as I would usually just quote the CHAR direct (i.e 'A') .

If you need to identify non-printing CHAR (i.e. [RETURN]) you can use #10, #13 etc.
Image