update add and cut
SQL> select * from IT_item_BRAND;
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
1 TENDA
2 POWER VOULT
3 TOSHIBA
4 3G TELETALK
5 ABLEREX
6 ACCER
7 APACER
8 APOLLO
9 ASUS
10 BANGLA LION
11 BLAZER
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
12 BRB
13 BRB/ PARADISE
14 CALLER ID
15 CANON
16 CARRIER
17 CISCO
18 CITYCEL E-ONE
19 CLONE PC
20 COLOR PRINTER
21 D-LINK
22 DELAX
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
23 DELL
24 DINTEK
25 EPSON
26 FLORA
27 GE GT6
28 GP
29 GRAMEEN PHONE
30 HITACHI
31 HP
32 INTEL
33 IT VISION
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
34 KASPERSKY
35 KEA PRINNTING
36 LEVELONE
37 LEVELONE ( GES-1650)
38 LEVELONE (GES-2450)
39 LG
40 LINKSYS
41 MICKROTIK
42 MICROLAB
43 NATIONAL
44 NEC
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
45 NOKIA
46 NOVA
47 OVO
48 PANASONIC
49 PANASONIC-500
50 PARADISE
51 PENDUIT
52 POWER PACK
53 PROLINK
54 QUBEE
55 SAMSUNG
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
56 SMART/NOVA
57 SPLITE
58 SYMENTIC
59 TISA
60 TRANSCAND
61 TRANSCEND
62 VARBATIM
63 VERBATIM
64 VOP TECT
65 VOPTECH
66 WESTERN DIGITAL (WD)
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
67 YDD
68 ZOOM ULTRA
69 BEST CHALLENGER
70 EURO
71 ZEBRA
72 POWER RITE
73 ASTA
74 KSTAR
75 SUMMIT
76 CLONE PC
77 SHARETECH
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
78 A4TECH
79 FUJITSU
80 H TECH
80 rows selected.
SQL> commit;
Commit complete.
SQL> update IT_item_BRAND set BRAND_CODE='00'||brand_code ;
80 rows updated.
SQL> select * from IT_item_BRAND;
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
001 TENDA
002 POWER VOULT
003 TOSHIBA
004 3G TELETALK
005 ABLEREX
006 ACCER
007 APACER
008 APOLLO
009 ASUS
0010 BANGLA LION
0011 BLAZER
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
0012 BRB
0013 BRB/ PARADISE
0014 CALLER ID
0015 CANON
0016 CARRIER
0017 CISCO
0018 CITYCEL E-ONE
0019 CLONE PC
0020 COLOR PRINTER
0021 D-LINK
0022 DELAX
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
0023 DELL
0024 DINTEK
0025 EPSON
0026 FLORA
0027 GE GT6
0028 GP
0029 GRAMEEN PHONE
0030 HITACHI
0031 HP
0032 INTEL
0033 IT VISION
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
0034 KASPERSKY
0035 KEA PRINNTING
0036 LEVELONE
0037 LEVELONE ( GES-1650)
0038 LEVELONE (GES-2450)
0039 LG
0040 LINKSYS
0041 MICKROTIK
0042 MICROLAB
0043 NATIONAL
0044 NEC
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
0045 NOKIA
0046 NOVA
0047 OVO
0048 PANASONIC
0049 PANASONIC-500
0050 PARADISE
0051 PENDUIT
0052 POWER PACK
0053 PROLINK
0054 QUBEE
0055 SAMSUNG
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
0056 SMART/NOVA
0057 SPLITE
0058 SYMENTIC
0059 TISA
0060 TRANSCAND
0061 TRANSCEND
0062 VARBATIM
0063 VERBATIM
0064 VOP TECT
0065 VOPTECH
0066 WESTERN DIGITAL (WD)
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
0067 YDD
0068 ZOOM ULTRA
0069 BEST CHALLENGER
0070 EURO
0071 ZEBRA
0072 POWER RITE
0073 ASTA
0074 KSTAR
0075 SUMMIT
0076 CLONE PC
0077 SHARETECH
BRAND_CODE BRAND_NM
---------- --------------------------------------------------
0078 A4TECH
0079 FUJITSU
0080 H TECH
80 rows selected.
SQL> commit;
Commit complete.
update IT_item_BRAND set BRAND_CODE=SUBSTR(brand_code,2,3) ;
SELECT SUBSTR('ABCDEFG',3,4) "Substring" FROM DUAL; Substring --------- CDEF SELECT SUBSTR('ABCDEFG',-5,4) "Substring" FROM DUAL; Substring --------- CDEF
Assume a double-byte database character set:
SELECT SUBSTRB('ABCDEFG',5,4.2) "Substring with bytes" FROM DUAL; Substring with bytes -------------------- CD
SQL> select lpad(nvl(to_number(max(BRAND_CODE)+1),1),4,('0')) from IT_ITEM_BRAND;
LPAD
----
0010
SQL> select max(brand_code) from IT_ITEM_BRAND;
MAX(BRAND_
----------
009
SQL> select max(to_number(brand_code)) from IT_ITEM_BRAND;
MAX(TO_NUMBER(BRAND_CODE))
--------------------------
80
SQL> select lpad(nvl(to_number(max(to_number(BRAND_CODE))+1),1),4,('0')) from IT_ITEM_BRAND;
LPAD
----
0081
SQL>
No comments:
Post a Comment