ascii


함수 이름 : ascii
의미 :

ASCII returns the decimal representation in the database character set of the first character of char.

char can be of datatype CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The value returned is of datatype NUMBER.
If your database character set is 7-bit ASCII, then this function returns an ASCII value.
If your database character set is EBCDIC Code, then this function returns an EBCDIC value.
There is no corresponding EBCDIC character function.


아스키는 DB에 있는 케릭터 셋에 맞춰 입력된 문자 중에 첫번 째 문자를 10진수 표기법으로 리턴한다.
이때 입력되는 문자의 형태는 CHAR, VARCHAR2, NCHAR, or NVARCHAR2가 될 수 있으며
리턴되는 값은 숫자의 형태로 리턴된다.
데이타 베이스의 캐릭터 셋의 설정에 따라 맞는 값이 출력된다 (ex : 7-bit ascii, EBCDIC 등)








생각한 예제

select ascii('&ascinput') from dual;

결과 : ascinput 이라는 변수에 입력을 하면 아스키 코드가 나온다.
팁 : isql plus 에서는 실행되지 않는다.
문자열 ABCDE 와 같이 입력한 경우 맨 앞 문자인 A 의 아스키 코드인 65가 리턴된다



이런 식으로 문자의 아스키 코드를 알아 낸 후 나중에
아스키 코드로 다음과 같은 예제와 함께 쓸 수 있을 듯 하다.









10g 메뉴얼에 소개된 예제






SELECT last_name FROM employees WHERE ASCII(SUBSTR(last_name, 1, 1,)) = 76; LAST_NAME-------------------------LadwigLandryLeeLivingston
쿼리의미 : emp 테이블에서 라스트 네임의 첫글짜의 아스키 코드가 76인 사람의 last name 을 보여줘라
p.s. : 아스키 코드의 활용 빈도..에 대한 의문?




오라클 메뉴얼의 설명과 캐릭터 셋 코드 표



Oracle9i SQL Reference
Release 2 (9.2)



ASCII

Syntax

ascii::=

Text description of functions15.gif follows
Text description of ascii


Purpose

ASCII returns the decimal representation in the database character set of the first character of char.

char can be of datatype CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The value returned is of datatype NUMBER. If your database character set is 7-bit ASCII, then this function returns an ASCII value. If your database character set is EBCDIC Code, then this function returns an EBCDIC value. There is no corresponding EBCDIC character function.


Note:

This function does not support CLOB data directly. However, CLOBs can be passed in as arguments through implicit data conversion. Please refer to "Datatype Comparison Rules" for more information.



Examples

The following example returns the ASCII decimal equivalent of the letter Q:

SELECT ASCII('Q') FROM DUAL; ASCII('Q')----------        81



Table 2-8   ASCII Character Set

Symbol

Decimal value

Symbol

Decimal value

blank

32

;

59

!

33

<

60

"

34

=

61

#

35

>

62

$

36

?

63

%

37

@

64

&

38

A-Z

65-90

'

39

[

91

(

40

\

92

)

41

]

93

*

42

^

94

+

43

_

95

,

44

`

96

-

45

a-z

97-122

.

46

{

123

/

47

|

124

0-9

48-57

}

125

:

58

~

126

Table 2-9 EBCDIC Character Set

Symbol

Decimal value

Symbol

Decimal value

blank

64

%

108

¢

74

_

109

.

75

>

110

<

76

?

111

(

77

:

122

+

78

#

123

|

79

@

124

&

80

'

125

!

90

=

126

$

91

"

127

*

92

a-i

129-137

)

93

j-r

145-153

;

94

s-z

162-169

ÿ

95

A-I

193-201

-

96

J-R

209-217

/

97

S-Z

226-233












by 이유없음 | 2009/03/09 08:28 | Oracle | 트랙백

◀ 이전 페이지 다음 페이지 ▶