Home » SQL & PL/SQL » Client Tools » Convert ASCII number 177 to character +/-
Convert ASCII number 177 to character +/- [message #671017] Thu, 09 August 2018 13:18 Go to next message
richard_oak
Messages: 8
Registered: May 2016
Junior Member
Hello,

I'm trying to use the CHR function to convert ASCII extended number 177 to +/- symbol. These are my current results:

SELECT ASCII('±') FROM DUAL; -- Result = 177
SELECT CHR(177) FROM DUAL; -- Result = error


Does anyone know how to get the symbol '±'?


Richard
Re: Convert ASCII number 177 to character +/- [message #671018 is a reply to message #671017] Thu, 09 August 2018 13:40 Go to previous messageGo to next message
BlackSwan
Messages: 26081
Registered: January 2009
Location: SoCal
Senior Member
richard_oak wrote on Thu, 09 August 2018 11:18
Hello,

I'm trying to use the CHR function to convert ASCII extended number 177 to +/- symbol. These are my current results:

SELECT ASCII('±') FROM DUAL; -- Result = 177
SELECT CHR(177) FROM DUAL; -- Result = error


Does anyone know how to get the symbol '±'?


Richard
Pure ASCII, IMO, is values 0, 127 inclusive.
Values greater than 127 are characterset dependent.
Re: Convert ASCII number 177 to character +/- [message #671019 is a reply to message #671017] Thu, 09 August 2018 13:42 Go to previous messageGo to next message
Michel Cadot
Messages: 65661
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Error? What error?

From your previous topic:

Michel Cadot wrote on Thu, 26 May 2016 19:13

Use SQL*Plus and copy and paste your session.
And don't forget to format as specified above.

With "above":
Michel Cadot wrote on Thu, 26 May 2016 18:56

Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals, as solution depends on it.

SQL> SELECT ASCII('±') FROM DUAL;
ASCII('Ð')
----------
       241

1 row selected.

SQL> SELECT CHR(177) FROM DUAL;
C
-
▒

1 row selected.

SQL> SELECT CHR(241) FROM DUAL;
C
-
±

1 row selected.
Re: Convert ASCII number 177 to character +/- [message #671020 is a reply to message #671019] Thu, 09 August 2018 13:52 Go to previous messageGo to next message
richard_oak
Messages: 8
Registered: May 2016
Junior Member
Thanks Michel,

It is not an actual error, it is the "?" symbol:
SELECT CHR(177) FROM DUAL;
C
-
?

I can see that on your side query below returns 241 number, and on my side it returns 177. Do you know why?
SELECT ASCII('±') FROM DUAL;

ASCII('±')
----------
177


Re: Convert ASCII number 177 to character +/- [message #671021 is a reply to message #671020] Thu, 09 August 2018 14:06 Go to previous messageGo to next message
Michel Cadot
Messages: 65661
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Yes I know why but as you repeatedly refuse to post accordingly to the forum rules and what we asked I won't answer you.

Re: Convert ASCII number 177 to character +/- [message #671022 is a reply to message #671021] Thu, 09 August 2018 14:34 Go to previous messageGo to next message
richard_oak
Messages: 8
Registered: May 2016
Junior Member
Honestly, I missed that. I've read the rules now, hope I'm following them now:

Here it is:

Database:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production


SQL> SELECT CHR(241) FROM DUAL;

C
-
±


In SQL*Plus it works, but it does not in SQL Developer.

Re: Convert ASCII number 177 to character +/- [message #671026 is a reply to message #671022] Fri, 10 August 2018 03:10 Go to previous messageGo to next message
gazzag
Messages: 950
Registered: November 2010
Location: Bristol, UK
Senior Member
Use [ CODE ] tags around your code, please. Open with [ CODE ] and close with [ /CODE ] Except without the spaces.

E.g.
SQL> select sysdate from dual;

SYSDATE
---------
10-AUG-18
Re: Convert ASCII number 177 to character +/- [message #671027 is a reply to message #671022] Fri, 10 August 2018 03:12 Go to previous messageGo to next message
gazzag
Messages: 950
Registered: November 2010
Location: Bristol, UK
Senior Member
richard_oak wrote on Thu, 09 August 2018 20:34

In SQL*Plus it works, but it does not in SQL Developer.
Show us, don't tell us!
Re: Convert ASCII number 177 to character +/- [message #671035 is a reply to message #671027] Fri, 10 August 2018 10:25 Go to previous message
richard_oak
Messages: 8
Registered: May 2016
Junior Member
Yesterday I found the fix for this, I searched for the hexadecimal value of sign ± and the UNISTR function made the trick in SQL Developer:

SELECT UNISTR('\00B1') PLUSMINUS FROM DUAL;

P
-
±

Previous Topic: Substitute for PL SQL Developer?
Next Topic: PL/SQL Developer settings FAQ
Goto Forum:
  


Current Time: Wed Aug 15 23:10:11 CDT 2018