ASCII_VAL and ASCII_CHAR with negative values

22 views
Skip to first unread message

Karol Bieniaszewski

unread,
Nov 5, 2021, 11:36:27 AM11/5/21
to firebird...@googlegroups.com

Hi

 

Connection characterset WIN1250.

 

SELECT ASCII_VAL('–') FROM RDB$DATABASE

 

Return me value „-106”, yes minus 106.

And i am worried what does it mean?

 

Same when i do

 

SELECT ASCII_CHAR(–106) FROM RDB$DATABASE

I got char „'–'.

 

What is the rule here? I ask because i read this char from database with WIN1250 charset.

 

In description of README.builtin_functions.txt i see that „Argument to ASCII_CHAR must be in the range 0 to 255 and returns a value

    with NONE character set.”

 

regards,

Karol Bieniaszewski

 

Ertan Küçükoglu

unread,
Nov 5, 2021, 11:44:10 AM11/5/21
to firebird...@googlegroups.com
When I try both functions I get different results on FirebirdSQL 2.5.9 Win64

SELECT ASCII_VAL('–') FROM RDB$DATABASE
 ASCII_VAL
  SMALLINT
-----------
       150

Second statement gives error:
SELECT ASCII_CHAR(–106) FROM RDB$DATABASE
Dynamic SQL Error
SQL error code = -104
Token unknown - line 1, column 19


Karol Bieniaszewski <livius...@poczta.onet.pl>, 5 Kas 2021 Cum, 18:36 tarihinde şunu yazdı:
--
You received this message because you are subscribed to the Google Groups "firebird-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/firebird-support/4Hm4Nh2Z9ZzlWD%40smtp.poczta.onet.pl.

Mark Rotteveel

unread,
Nov 5, 2021, 11:56:33 AM11/5/21
to firebird...@googlegroups.com
Which Firebird version are you using, and how are you querying and
obtaining this value? When I do this against Firebird 4.0 (using
DBeaver), I get 150. And 150 is 0b1001 0110, which is also -106 when the
value is represented as a signed byte (e.g. in Java, if you had used
ResultSet.getByte to get the value).

Mark
--
Mark Rotteveel

Karol Bieniaszewski

unread,
Nov 5, 2021, 12:27:52 PM11/5/21
to firebird...@googlegroups.com

WI-V3.0.5.33187 Firebird 3.0 db charset WIN1250

 

With 2 tools flamerobin and my custom too which use Firedac.

 

regards,

Karol Bieniaszewski

--

You received this message because you are subscribed to the Google Groups "firebird-support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.

Mark Rotteveel

unread,
Nov 6, 2021, 3:18:39 AM11/6/21
to firebird...@googlegroups.com
On 05-11-2021 17:27, Karol Bieniaszewski wrote:
> WI-V3.0.5.33187 Firebird 3.0 db charset WIN1250
>
> With 2 tools flamerobin and my custom too which use Firedac.

I am unable to reproduce (with Firebird 3.0.7 on Windows 10), using
DBeaver and using FlameRobin. Maybe this is a bug in Firebird 3.0.5
(though I couldn't find anything in the release notes), or maybe there
is some environmental difference.

Mark
--
Mark Rotteveel

Karol Bieniaszewski

unread,
Nov 6, 2021, 5:17:27 AM11/6/21
to firebird...@googlegroups.com

I found where the problem is 😊

 

This was udf not builtin function.

 

DECLARE EXTERNAL FUNCTION ASCII_CHAR

integer

RETURNS cstring(1) free_it

ENTRY_POINT 'IB_UDF_ascii_char'

MODULE_NAME 'ib_udf';

 

DECLARE EXTERNAL FUNCTION ASCII_VAL

char(1)

RETURNS integer BY VALUE

ENTRY_POINT 'IB_UDF_ascii_val'

MODULE_NAME 'ib_udf';

 

 

regards,

Karol Bieniaszewski

--

You received this message because you are subscribed to the Google Groups "firebird-support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to firebird-suppo...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages