SQL> CREATE TABLE v (
2 ip VARCHAR2(15)
3 , ipn INTEGER AS (
4 16777216
5 * TO_NUMBER(
6 SUBSTR(
7 ip
8 , 1
9 , INSTR(ip, '.', 1, 1)
10 - 1
11 )
12 )
13 + 65536
14 * TO_NUMBER(
15 SUBSTR(
16 ip
17 , INSTR(ip, '.', 1, 1)
18 + 1
19 , INSTR(ip, '.', 1, 2)
20 - INSTR(ip, '.', 1, 1)
21 - 1
22 )
23 )
24 + 256
25 * TO_NUMBER(
26 SUBSTR(
27 ip
28 , INSTR(ip, '.', 1, 2)
29 + 1
30 , INSTR(ip, '.', 1, 3)
31 - INSTR(ip, '.', 1, 2)
32 - 1
33 )
34 )
35 + TO_NUMBER(
36 SUBSTR(
37 ip
38 , INSTR(ip, '.', 1, 3)
39 + 1
40 )
41 )
42 )
43 )
44 /
Таблица создана.
SQL> INSERT INTO v(ip) VALUES ('192.168.11.1');
1 строка создана.
SQL> SELECT * FROM v;
IP IPN
--------------- ----------
192.168.11.1 3232238337
SQL> COLUMN data_default FORMAT a80 WORD_WRAP
SQL> SELECT data_default
2 FROM user_tab_columns
3 WHERE table_name = 'V'
4 AND column_name = 'IPN'
5 /
DATA_DEFAULT
--------------------------------------------------------------------------------
16777216*TO_NUMBER(SUBSTR("IP",1,INSTR("IP",'.',1,1)-1))+65536*TO_NUMBER(SUBSTR(
"IP",INSTR("IP",'.',1,1)+1,INSTR("IP",'.',1,2)-INSTR("IP",'.',1,1)-1))+256*TO_NU
MBER(SUBSTR("IP",INSTR("IP",'.',1,2)+1,INSTR("IP",'.',1,3)-INSTR("IP",'.',1,2)-1
))+TO_NUMBER(SUBSTR("IP",INSTR("IP",'.',1,3)+1))
Friday, December 08, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment