Monday, August 16, 2010
Oracle 11g: Conversion Functions
===> SQL Queries: TO_CHAR with Dates
select last_name,
to_char(hire_date,'fmDD Month YYYY') as hiredate
from employees
Results:
LAST_NAME HIREDATE
------------------------- -----------------
King 17 June 1987
Kochhar 21 September 1989
De Haan 13 January 1993
Hunold 3 January 1990
Ernst 21 May 1991
Austin 25 June 1997
Pataballa 5 February 1998
Lorentz 7 February 1999
Greenberg 17 August 1994
Faviet 16 August 1994
Chen 28 September 1997
Sciarra 30 September 1997
Urman 7 March 1998
Popp 7 December 1999
Raphaely 7 December 1994
Khoo 18 May 1995
Baida 24 December 1997
Tobias 24 July 1997
Himuro 15 November 1998
Colmenares 10 August 1999
Weiss 18 July 1996
Fripp 10 April 1997
Kaufling 1 May 1995
Vollman 10 October 1997
Mourgos 16 November 1999
Nayer 16 July 1997
Mikkilineni 28 September 1998
Landry 14 January 1999
Markle 8 March 2000
Bissot 20 August 1997
Atkinson 30 October 1997
Marlow 16 February 1997
Olson 10 April 1999
Mallin 14 June 1996
Rogers 26 August 1998
Gee 12 December 1999
Philtanker 6 February 2000
Ladwig 14 July 1995
Stiles 26 October 1997
Seo 12 February 1998
Patel 6 April 1998
Rajs 17 October 1995
Davies 29 January 1997
Matos 15 March 1998
Vargas 9 July 1998
Russell 1 October 1996
Partners 5 January 1997
Errazuriz 10 March 1997
Cambrault 15 October 1999
Zlotkey 29 January 2000
Tucker 30 January 1997
Bernstein 24 March 1997
Hall 20 August 1997
Olsen 30 March 1998
Cambrault 9 December 1998
Tuvault 23 November 1999
King 30 January 1996
Sully 4 March 1996
McEwen 1 August 1996
Smith 10 March 1997
Doran 15 December 1997
Sewall 3 November 1998
Vishney 11 November 1997
Greene 19 March 1999
Marvins 24 January 2000
Lee 23 February 2000
Ande 24 March 2000
Banda 21 April 2000
Ozer 11 March 1997
Bloom 23 March 1998
Fox 24 January 1998
Smith 23 February 1999
Bates 24 March 1999
Kumar 21 April 2000
Abel 11 May 1996
Hutton 19 March 1997
Taylor 24 March 1998
Livingston 23 April 1998
Grant 24 May 1999
Johnson 4 January 2000
Taylor 24 January 1998
Fleaur 23 February 1998
Sullivan 21 June 1999
Geoni 3 February 2000
Sarchand 27 January 1996
Bull 20 February 1997
Dellinger 24 June 1998
Cabrio 7 February 1999
Chung 14 June 1997
Dilly 13 August 1997
Gates 11 July 1998
Perkins 19 December 1999
Bell 4 February 1996
Everett 3 March 1997
McCain 1 July 1998
Jones 17 March 1999
Walsh 24 April 1998
Feeney 23 May 1998
OConnell 21 June 1999
Grant 13 January 2000
Whalen 17 September 1987
Hartstein 17 February 1996
Fay 17 August 1997
Mavris 7 June 1994
Baer 7 June 1994
Higgins 7 June 1994
Gietz 7 June 1994
107 rows selected
===> SQL Queries: TO_CHAR with Numbers
select to_char(salary,'$99,999.00') salary
from employees
where last_name = 'Ernst'
Results:
SALARY
-----------
$6,000.00
1 rows selected
===> SQL Queries: TO_DATE using RR
select last_name,TO_CHAR(hire_date, 'DD-Mon-YYYY')
from employees
where hire_date < TO_DATE('01-Jan-90','DD-Mon-RR')
Results:
LAST_NAME TO_CHAR(HIRE_DATE,'DD-MON-YYYY')
------------------------- --------------------------------
King 17-Jun-1987
Kochhar 21-Sep-1989
Whalen 17-Sep-1987
3 rows selected
select last_name,
to_char(hire_date,'fmDD Month YYYY') as hiredate
from employees
Results:
LAST_NAME HIREDATE
------------------------- -----------------
King 17 June 1987
Kochhar 21 September 1989
De Haan 13 January 1993
Hunold 3 January 1990
Ernst 21 May 1991
Austin 25 June 1997
Pataballa 5 February 1998
Lorentz 7 February 1999
Greenberg 17 August 1994
Faviet 16 August 1994
Chen 28 September 1997
Sciarra 30 September 1997
Urman 7 March 1998
Popp 7 December 1999
Raphaely 7 December 1994
Khoo 18 May 1995
Baida 24 December 1997
Tobias 24 July 1997
Himuro 15 November 1998
Colmenares 10 August 1999
Weiss 18 July 1996
Fripp 10 April 1997
Kaufling 1 May 1995
Vollman 10 October 1997
Mourgos 16 November 1999
Nayer 16 July 1997
Mikkilineni 28 September 1998
Landry 14 January 1999
Markle 8 March 2000
Bissot 20 August 1997
Atkinson 30 October 1997
Marlow 16 February 1997
Olson 10 April 1999
Mallin 14 June 1996
Rogers 26 August 1998
Gee 12 December 1999
Philtanker 6 February 2000
Ladwig 14 July 1995
Stiles 26 October 1997
Seo 12 February 1998
Patel 6 April 1998
Rajs 17 October 1995
Davies 29 January 1997
Matos 15 March 1998
Vargas 9 July 1998
Russell 1 October 1996
Partners 5 January 1997
Errazuriz 10 March 1997
Cambrault 15 October 1999
Zlotkey 29 January 2000
Tucker 30 January 1997
Bernstein 24 March 1997
Hall 20 August 1997
Olsen 30 March 1998
Cambrault 9 December 1998
Tuvault 23 November 1999
King 30 January 1996
Sully 4 March 1996
McEwen 1 August 1996
Smith 10 March 1997
Doran 15 December 1997
Sewall 3 November 1998
Vishney 11 November 1997
Greene 19 March 1999
Marvins 24 January 2000
Lee 23 February 2000
Ande 24 March 2000
Banda 21 April 2000
Ozer 11 March 1997
Bloom 23 March 1998
Fox 24 January 1998
Smith 23 February 1999
Bates 24 March 1999
Kumar 21 April 2000
Abel 11 May 1996
Hutton 19 March 1997
Taylor 24 March 1998
Livingston 23 April 1998
Grant 24 May 1999
Johnson 4 January 2000
Taylor 24 January 1998
Fleaur 23 February 1998
Sullivan 21 June 1999
Geoni 3 February 2000
Sarchand 27 January 1996
Bull 20 February 1997
Dellinger 24 June 1998
Cabrio 7 February 1999
Chung 14 June 1997
Dilly 13 August 1997
Gates 11 July 1998
Perkins 19 December 1999
Bell 4 February 1996
Everett 3 March 1997
McCain 1 July 1998
Jones 17 March 1999
Walsh 24 April 1998
Feeney 23 May 1998
OConnell 21 June 1999
Grant 13 January 2000
Whalen 17 September 1987
Hartstein 17 February 1996
Fay 17 August 1997
Mavris 7 June 1994
Baer 7 June 1994
Higgins 7 June 1994
Gietz 7 June 1994
107 rows selected
===> SQL Queries: TO_CHAR with Numbers
select to_char(salary,'$99,999.00') salary
from employees
where last_name = 'Ernst'
Results:
SALARY
-----------
$6,000.00
1 rows selected
===> SQL Queries: TO_DATE using RR
select last_name,TO_CHAR(hire_date, 'DD-Mon-YYYY')
from employees
where hire_date < TO_DATE('01-Jan-90','DD-Mon-RR')
Results:
LAST_NAME TO_CHAR(HIRE_DATE,'DD-MON-YYYY')
------------------------- --------------------------------
King 17-Jun-1987
Kochhar 21-Sep-1989
Whalen 17-Sep-1987
3 rows selected
Oracle 11g: Using Date Functions
select last_name, (sysdate-hire_date)/7 as weeks
from employees
where department_id=90
Results:
LAST_NAME WEEKS
------------------------- ----------------------
King 1208.871435185185185185185185185185185185
Kochhar 1090.728578042328042328042328042328042328
De Haan 917.871435185185185185185185185185185185
===> Other queries
select months_between('10-SEP-1980','13-AUG-1980')
from dual
SELECT ADD_MONTHS('10-SEP-1980',6)
FROM DUAL
SELECT NEXT_DAY('10-SEP-1980','FRIDAY')
FROM DUAL
SELECT LAST_DAY('10-SEP-1980')
FROM DUAL
RESULTS:
MONTHS_BETWEEN('10-SEP-1980','13-AUG-1980')
-------------------------------------------
0.9032258064516129032258064516129032258065
1 rows selected
ADD_MONTHS('10-SEP-1980',6)
-------------------------
10-MAR-81
1 rows selected
NEXT_DAY('10-SEP-1980','FRIDAY')
-------------------------
12-SEP-80
1 rows selected
LAST_DAY('10-SEP-1980')
-------------------------
30-SEP-80
1 rows selected
===> SQL Queries ROUND and TRUNC
select round(sysdate,'MONTH')
from dual;
select round(sysdate,'year')
from dual;
select trunc(sysdate,'month')
from dual;
select trunc(sysdate,'year')
from dual;
Note: Assuming sysdate = '16-AUG-2010'
Results:
ROUND(SYSDATE,'MONTH')
-------------------------
01-SEP-10
1 rows selected
ROUND(SYSDATE,'YEAR')
-------------------------
01-JAN-11
1 rows selected
TRUNC(SYSDATE,'MONTH')
-------------------------
01-AUG-10
1 rows selected
TRUNC(SYSDATE,'YEAR')
-------------------------
01-JAN-10
1 rows selected
from employees
where department_id=90
Results:
LAST_NAME WEEKS
------------------------- ----------------------
King 1208.871435185185185185185185185185185185
Kochhar 1090.728578042328042328042328042328042328
De Haan 917.871435185185185185185185185185185185
===> Other queries
select months_between('10-SEP-1980','13-AUG-1980')
from dual
SELECT ADD_MONTHS('10-SEP-1980',6)
FROM DUAL
SELECT NEXT_DAY('10-SEP-1980','FRIDAY')
FROM DUAL
SELECT LAST_DAY('10-SEP-1980')
FROM DUAL
RESULTS:
MONTHS_BETWEEN('10-SEP-1980','13-AUG-1980')
-------------------------------------------
0.9032258064516129032258064516129032258065
1 rows selected
ADD_MONTHS('10-SEP-1980',6)
-------------------------
10-MAR-81
1 rows selected
NEXT_DAY('10-SEP-1980','FRIDAY')
-------------------------
12-SEP-80
1 rows selected
LAST_DAY('10-SEP-1980')
-------------------------
30-SEP-80
1 rows selected
===> SQL Queries ROUND and TRUNC
select round(sysdate,'MONTH')
from dual;
select round(sysdate,'year')
from dual;
select trunc(sysdate,'month')
from dual;
select trunc(sysdate,'year')
from dual;
Note: Assuming sysdate = '16-AUG-2010'
Results:
ROUND(SYSDATE,'MONTH')
-------------------------
01-SEP-10
1 rows selected
ROUND(SYSDATE,'YEAR')
-------------------------
01-JAN-11
1 rows selected
TRUNC(SYSDATE,'MONTH')
-------------------------
01-AUG-10
1 rows selected
TRUNC(SYSDATE,'YEAR')
-------------------------
01-JAN-10
1 rows selected
Sunday, August 15, 2010
Oracle 11g: Using Number Functions MOD
select last_name,
salary
from employees
where job_id='SA_REP';
Results:
LAST_NAME SALARY
------------------------- ----------------------
Tucker 10000
Bernstein 9500
Hall 9000
Olsen 8000
Cambrault 7500
Tuvault 7000
King 10000
Sully 9500
McEwen 9000
Smith 8000
Doran 7500
Sewall 7000
Vishney 10500
Greene 9500
Marvins 7200
Lee 6800
Ande 6400
Banda 6200
Ozer 11500
Bloom 10000
Fox 9600
Smith 7400
Bates 7300
Kumar 6100
Abel 11000
Hutton 8800
Taylor 8600
Livingston 8400
Grant 7000
Johnson 6200
30 rows selected
==> SQL Queries using MOD
select last_name,
salary,
MOD(salary, 5000)
from employees
where job_id='SA_REP';
Results :
LAST_NAME SALARY MOD(SALARY,5000)
------------------------- ---------------------- ----------------------
Tucker 10000 0
Bernstein 9500 4500
Hall 9000 4000
Olsen 8000 3000
Cambrault 7500 2500
Tuvault 7000 2000
King 10000 0
Sully 9500 4500
McEwen 9000 4000
Smith 8000 3000
Doran 7500 2500
Sewall 7000 2000
Vishney 10500 500
Greene 9500 4500
Marvins 7200 2200
Lee 6800 1800
Ande 6400 1400
Banda 6200 1200
Ozer 11500 1500
Bloom 10000 0
Fox 9600 4600
Smith 7400 2400
Bates 7300 2300
Kumar 6100 1100
Abel 11000 1000
Hutton 8800 3800
Taylor 8600 3600
Livingston 8400 3400
Grant 7000 2000
Johnson 6200 1200
30 rows selected
salary
from employees
where job_id='SA_REP';
Results:
LAST_NAME SALARY
------------------------- ----------------------
Tucker 10000
Bernstein 9500
Hall 9000
Olsen 8000
Cambrault 7500
Tuvault 7000
King 10000
Sully 9500
McEwen 9000
Smith 8000
Doran 7500
Sewall 7000
Vishney 10500
Greene 9500
Marvins 7200
Lee 6800
Ande 6400
Banda 6200
Ozer 11500
Bloom 10000
Fox 9600
Smith 7400
Bates 7300
Kumar 6100
Abel 11000
Hutton 8800
Taylor 8600
Livingston 8400
Grant 7000
Johnson 6200
30 rows selected
==> SQL Queries using MOD
select last_name,
salary,
MOD(salary, 5000)
from employees
where job_id='SA_REP';
Results :
LAST_NAME SALARY MOD(SALARY,5000)
------------------------- ---------------------- ----------------------
Tucker 10000 0
Bernstein 9500 4500
Hall 9000 4000
Olsen 8000 3000
Cambrault 7500 2500
Tuvault 7000 2000
King 10000 0
Sully 9500 4500
McEwen 9000 4000
Smith 8000 3000
Doran 7500 2500
Sewall 7000 2000
Vishney 10500 500
Greene 9500 4500
Marvins 7200 2200
Lee 6800 1800
Ande 6400 1400
Banda 6200 1200
Ozer 11500 1500
Bloom 10000 0
Fox 9600 4600
Smith 7400 2400
Bates 7300 2300
Kumar 6100 1100
Abel 11000 1000
Hutton 8800 3800
Taylor 8600 3600
Livingston 8400 3400
Grant 7000 2000
Johnson 6200 1200
30 rows selected
Oracle 11g: Using Number Functions ROUND and TRUNC
select 45.923 as ringgit
from dual;
Results:
RINGGIT
----------------------
45.923
===> SQL Queries:
select round(45.923,2),
round(45.923,0),
round(45.923,-1)
from dual;
select trunc(45.923,2),
trunc(45.923),
trunc(45.923,-1)
from dual;
Results:
ROUND(45.923,2) ROUND(45.923,0) ROUND(45.923,-1)
---------------------- ---------------------- ----------------------
45.92 46 50
TRUNC(45.923,2) TRUNC(45.923) TRUNC(45.923,-1)
---------------------- ---------------------- ----------------------
45.92 45 40
from dual;
Results:
RINGGIT
----------------------
45.923
===> SQL Queries:
select round(45.923,2),
round(45.923,0),
round(45.923,-1)
from dual;
select trunc(45.923,2),
trunc(45.923),
trunc(45.923,-1)
from dual;
Results:
ROUND(45.923,2) ROUND(45.923,0) ROUND(45.923,-1)
---------------------- ---------------------- ----------------------
45.92 46 50
TRUNC(45.923,2) TRUNC(45.923) TRUNC(45.923,-1)
---------------------- ---------------------- ----------------------
45.92 45 40
Oracle 11g: Using Character-Manipulation Functions
select employee_id,
first_name,
last_name
job_id
from employees
Results
EMPLOYEE_ID FIRST_NAME JOB_ID
---------------------- -------------------- -------------------------
100 Steven King
101 Neena Kochhar
102 Lex De Haan
103 Alexander Hunold
104 Bruce Ernst
105 David Austin
106 Valli Pataballa
107 Diana Lorentz
108 Nancy Greenberg
109 Daniel Faviet
110 John Chen
111 Ismael Sciarra
112 Jose Manuel Urman
113 Luis Popp
114 Den Raphaely
115 Alexander Khoo
116 Shelli Baida
117 Sigal Tobias
118 Guy Himuro
119 Karen Colmenares
120 Matthew Weiss
121 Adam Fripp
122 Payam Kaufling
123 Shanta Vollman
124 Kevin Mourgos
125 Julia Nayer
126 Irene Mikkilineni
127 James Landry
128 Steven Markle
129 Laura Bissot
130 Mozhe Atkinson
131 James Marlow
132 TJ Olson
133 Jason Mallin
134 Michael Rogers
135 Ki Gee
136 Hazel Philtanker
137 Renske Ladwig
138 Stephen Stiles
139 John Seo
140 Joshua Patel
141 Trenna Rajs
142 Curtis Davies
143 Randall Matos
144 Peter Vargas
145 John Russell
146 Karen Partners
147 Alberto Errazuriz
148 Gerald Cambrault
149 Eleni Zlotkey
150 Peter Tucker
151 David Bernstein
152 Peter Hall
153 Christopher Olsen
154 Nanette Cambrault
155 Oliver Tuvault
156 Janette King
157 Patrick Sully
158 Allan McEwen
159 Lindsey Smith
160 Louise Doran
161 Sarath Sewall
162 Clara Vishney
163 Danielle Greene
164 Mattea Marvins
165 David Lee
166 Sundar Ande
167 Amit Banda
168 Lisa Ozer
169 Harrison Bloom
170 Tayler Fox
171 William Smith
172 Elizabeth Bates
173 Sundita Kumar
174 Ellen Abel
175 Alyssa Hutton
176 Jonathon Taylor
177 Jack Livingston
178 Kimberely Grant
179 Charles Johnson
180 Winston Taylor
181 Jean Fleaur
182 Martha Sullivan
183 Girard Geoni
184 Nandita Sarchand
185 Alexis Bull
186 Julia Dellinger
187 Anthony Cabrio
188 Kelly Chung
189 Jennifer Dilly
190 Timothy Gates
191 Randall Perkins
192 Sarah Bell
193 Britney Everett
194 Samuel McCain
195 Vance Jones
196 Alana Walsh
197 Kevin Feeney
198 Donald OConnell
199 Douglas Grant
200 Jennifer Whalen
201 Michael Hartstein
202 Pat Fay
203 Susan Mavris
204 Hermann Baer
205 Shelley Higgins
206 William Gietz
107 rows selected
===> SQL Query using characters-manipulation functions
select employee_id,
CONCAT(first_name, last_name) EMPLOYEENAME,
job_id,
LENGTH(last_name),
INSTR(last_name,'a') "Contains 'a'?"
from employees
where SUBSTR(job_id, 4)='REP'
Results
EMPLOYEE_ID EMPLOYEENAME JOB_ID LENGTH(LAST_NAME) Contains 'a'?
---------------------- --------------------------------------------- ---------- --------
150 PeterTucker SA_REP 6 0
151 DavidBernstein SA_REP 9 0
152 PeterHall SA_REP 4 2
153 ChristopherOlsen SA_REP 5 0
154 NanetteCambrault SA_REP 9 2
155 OliverTuvault SA_REP 7 4
156 JanetteKing SA_REP 4 0
157 PatrickSully SA_REP 5 0
158 AllanMcEwen SA_REP 6 0
159 LindseySmith SA_REP 5 0
160 LouiseDoran SA_REP 5 4
161 SarathSewall SA_REP 6 4
162 ClaraVishney SA_REP 7 0
163 DanielleGreene SA_REP 6 0
164 MatteaMarvins SA_REP 7 2
165 DavidLee SA_REP 3 0
166 SundarAnde SA_REP 4 0
167 AmitBanda SA_REP 5 2
168 LisaOzer SA_REP 4 0
169 HarrisonBloom SA_REP 5 0
170 TaylerFox SA_REP 3 0
171 WilliamSmith SA_REP 5 0
172 ElizabethBates SA_REP 5 2
173 SunditaKumar SA_REP 5 4
174 EllenAbel SA_REP 4 0
175 AlyssaHutton SA_REP 6 0
176 JonathonTaylor SA_REP 6 2
177 JackLivingston SA_REP 10 0
178 KimberelyGrant SA_REP 5 3
179 CharlesJohnson SA_REP 7 0
202 PatFay MK_REP 3 2
203 SusanMavris HR_REP 6 2
204 HermannBaer PR_REP 4 2
33 rows selected
first_name,
last_name
job_id
from employees
Results
EMPLOYEE_ID FIRST_NAME JOB_ID
---------------------- -------------------- -------------------------
100 Steven King
101 Neena Kochhar
102 Lex De Haan
103 Alexander Hunold
104 Bruce Ernst
105 David Austin
106 Valli Pataballa
107 Diana Lorentz
108 Nancy Greenberg
109 Daniel Faviet
110 John Chen
111 Ismael Sciarra
112 Jose Manuel Urman
113 Luis Popp
114 Den Raphaely
115 Alexander Khoo
116 Shelli Baida
117 Sigal Tobias
118 Guy Himuro
119 Karen Colmenares
120 Matthew Weiss
121 Adam Fripp
122 Payam Kaufling
123 Shanta Vollman
124 Kevin Mourgos
125 Julia Nayer
126 Irene Mikkilineni
127 James Landry
128 Steven Markle
129 Laura Bissot
130 Mozhe Atkinson
131 James Marlow
132 TJ Olson
133 Jason Mallin
134 Michael Rogers
135 Ki Gee
136 Hazel Philtanker
137 Renske Ladwig
138 Stephen Stiles
139 John Seo
140 Joshua Patel
141 Trenna Rajs
142 Curtis Davies
143 Randall Matos
144 Peter Vargas
145 John Russell
146 Karen Partners
147 Alberto Errazuriz
148 Gerald Cambrault
149 Eleni Zlotkey
150 Peter Tucker
151 David Bernstein
152 Peter Hall
153 Christopher Olsen
154 Nanette Cambrault
155 Oliver Tuvault
156 Janette King
157 Patrick Sully
158 Allan McEwen
159 Lindsey Smith
160 Louise Doran
161 Sarath Sewall
162 Clara Vishney
163 Danielle Greene
164 Mattea Marvins
165 David Lee
166 Sundar Ande
167 Amit Banda
168 Lisa Ozer
169 Harrison Bloom
170 Tayler Fox
171 William Smith
172 Elizabeth Bates
173 Sundita Kumar
174 Ellen Abel
175 Alyssa Hutton
176 Jonathon Taylor
177 Jack Livingston
178 Kimberely Grant
179 Charles Johnson
180 Winston Taylor
181 Jean Fleaur
182 Martha Sullivan
183 Girard Geoni
184 Nandita Sarchand
185 Alexis Bull
186 Julia Dellinger
187 Anthony Cabrio
188 Kelly Chung
189 Jennifer Dilly
190 Timothy Gates
191 Randall Perkins
192 Sarah Bell
193 Britney Everett
194 Samuel McCain
195 Vance Jones
196 Alana Walsh
197 Kevin Feeney
198 Donald OConnell
199 Douglas Grant
200 Jennifer Whalen
201 Michael Hartstein
202 Pat Fay
203 Susan Mavris
204 Hermann Baer
205 Shelley Higgins
206 William Gietz
107 rows selected
===> SQL Query using characters-manipulation functions
select employee_id,
CONCAT(first_name, last_name) EMPLOYEENAME,
job_id,
LENGTH(last_name),
INSTR(last_name,'a') "Contains 'a'?"
from employees
where SUBSTR(job_id, 4)='REP'
Results
EMPLOYEE_ID EMPLOYEENAME JOB_ID LENGTH(LAST_NAME) Contains 'a'?
---------------------- --------------------------------------------- ---------- --------
150 PeterTucker SA_REP 6 0
151 DavidBernstein SA_REP 9 0
152 PeterHall SA_REP 4 2
153 ChristopherOlsen SA_REP 5 0
154 NanetteCambrault SA_REP 9 2
155 OliverTuvault SA_REP 7 4
156 JanetteKing SA_REP 4 0
157 PatrickSully SA_REP 5 0
158 AllanMcEwen SA_REP 6 0
159 LindseySmith SA_REP 5 0
160 LouiseDoran SA_REP 5 4
161 SarathSewall SA_REP 6 4
162 ClaraVishney SA_REP 7 0
163 DanielleGreene SA_REP 6 0
164 MatteaMarvins SA_REP 7 2
165 DavidLee SA_REP 3 0
166 SundarAnde SA_REP 4 0
167 AmitBanda SA_REP 5 2
168 LisaOzer SA_REP 4 0
169 HarrisonBloom SA_REP 5 0
170 TaylerFox SA_REP 3 0
171 WilliamSmith SA_REP 5 0
172 ElizabethBates SA_REP 5 2
173 SunditaKumar SA_REP 5 4
174 EllenAbel SA_REP 4 0
175 AlyssaHutton SA_REP 6 0
176 JonathonTaylor SA_REP 6 2
177 JackLivingston SA_REP 10 0
178 KimberelyGrant SA_REP 5 3
179 CharlesJohnson SA_REP 7 0
202 PatFay MK_REP 3 2
203 SusanMavris HR_REP 6 2
204 HermannBaer PR_REP 4 2
33 rows selected
Oracle 11g: Character-Manipulation Functions
select 'Hello World' from dual;
select CONCAT('Hello World', 'Peah') from dual;
select SUBSTR('Hello World', 1,5) from dual;
select LENGTH('Hello World') from dual;
select INSTR('Hello World', 'W') from dual;
select LPAD('Hello World', 20,'*') from dual;
select RPAD('Hello World', 20,'*') from dual;
select REPLACE('Hello World', 'l','x') from dual;
select TRIM('H' FROM 'Hello World') from dual;
Results
'HELLOWORLD'
------------
Hello World
CONCAT('HELLOWORLD','PEAH')
---------------------------
Hello WorldPeah
SUBSTR('HELLOWORLD',1,5)
------------------------
Hello
LENGTH('HELLOWORLD')
----------------------
11
INSTR('HELLOWORLD','W')
-----------------------
7
LPAD('HELLOWORLD',20,'*')
-------------------------
*********Hello World
RPAD('HELLOWORLD',20,'*')
-------------------------
Hello World*********
REPLACE('HELLOWORLD','L','X')
-----------------------------
Hexxo Worxd
TRIM('H'FROM'HELLOWORLD')
-------------------------
ello World
select CONCAT('Hello World', 'Peah') from dual;
select SUBSTR('Hello World', 1,5) from dual;
select LENGTH('Hello World') from dual;
select INSTR('Hello World', 'W') from dual;
select LPAD('Hello World', 20,'*') from dual;
select RPAD('Hello World', 20,'*') from dual;
select REPLACE('Hello World', 'l','x') from dual;
select TRIM('H' FROM 'Hello World') from dual;
Results
'HELLOWORLD'
------------
Hello World
CONCAT('HELLOWORLD','PEAH')
---------------------------
Hello WorldPeah
SUBSTR('HELLOWORLD',1,5)
------------------------
Hello
LENGTH('HELLOWORLD')
----------------------
11
INSTR('HELLOWORLD','W')
-----------------------
7
LPAD('HELLOWORLD',20,'*')
-------------------------
*********Hello World
RPAD('HELLOWORLD',20,'*')
-------------------------
Hello World*********
REPLACE('HELLOWORLD','L','X')
-----------------------------
Hexxo Worxd
TRIM('H'FROM'HELLOWORLD')
-------------------------
ello World
Oracle 11g: Case-Manipulation Sample
select ('peAhShAn') from dual;
select lower('peAhShAn') from dual;
select upper('peAhShAn') from dual;
select Initcap('peAhShAn') from dual;
Results:
('PEAHSHAN')
------------
peAhShAn
LOWER('PEAHSHAN')
-----------------
peahshan
UPPER('PEAHSHAN')
-----------------
PEAHSHAN
INITCAP('PEAHSHAN')
-------------------
Peahshan
select lower('peAhShAn') from dual;
select upper('peAhShAn') from dual;
select Initcap('peAhShAn') from dual;
Results:
('PEAHSHAN')
------------
peAhShAn
LOWER('PEAHSHAN')
-----------------
peahshan
UPPER('PEAHSHAN')
-----------------
PEAHSHAN
INITCAP('PEAHSHAN')
-------------------
Peahshan
Saturday, August 14, 2010
Oracle 11g: Installing the Oracle 11g Sample Schemas
I wanted to test all SQL scripts without manually creating the tables. So, I downloaded the sample schema from here.
2. You will be receiving a zip file that contains these sql files.
3. You can refer to the article (refer to step 1) for steps on how to install the schema samples. My way is a bit different, I used the 'Oracle SQL Developer'.
Running script through 'Oracle SQL Developer'
1. If you are using the 'Oracle SQL Developer', first thing that you have to do is to connect either as 'SYS' or 'SYSDBA' that has the system's privileges.
2. Open the files that you have unzipped.
3. Press F5
2. You will be receiving a zip file that contains these sql files.
3. You can refer to the article (refer to step 1) for steps on how to install the schema samples. My way is a bit different, I used the 'Oracle SQL Developer'.
Running script through 'Oracle SQL Developer'
1. If you are using the 'Oracle SQL Developer', first thing that you have to do is to connect either as 'SYS' or 'SYSDBA' that has the system's privileges.
2. Open the files that you have unzipped.
- If you are accessing the database via "SYSDBA" , simply run the hr_main.sql..all tables will be created automatically..
- BUT.if you're accessing through "SYSTEM", run hr_cre.sql (tables) first then hr_popul.sql (data)
3. Press F5
Sunday, July 4, 2010
MOSS 2007: Enforce document storage business rules by using Document Policy.
o Create a custom document policy.
o Deploy a document policy by using a policy feature.
o Specify logic for a document policy by using a policy resource
Note: Script may have not entirely workable. Please recheck the steps.
o Expiration: Manage document retention rules by using the expiration feature policy.
o Expiration: Launch a workflow when a document expires.
o Deploy a document policy by using a policy feature.
o Specify logic for a document policy by using a policy resource
- . Create Policy Feature: Code Snippet
- . Create Policy Manifest: Code Snippet
- . Create Policy Configuration Page: Code Snippet
- . Register the Policy Feature in the Policy Catalog.
Note: Script may have not entirely workable. Please recheck the steps.
o Expiration: Manage document retention rules by using the expiration feature policy.
o Expiration: Launch a workflow when a document expires.
Saturday, July 3, 2010
How To Paste Your Code Snippet in Blogspot.
1. Goto Blogcrowds
2. Copy and paste your coding in the text area. Click 'Parse' button.
3. Copy the parsed code snippet, and paste it in the HTML mode in your post.
4. Add <blockquote></blockquote>to any lines to get much elegant look.
OR....
1. Goto to Bloggerindraft. Make sure that you have logged in into your Blogspot account.
2. Follow steps from this site, BlogPandit.
Reference: BlogPandit
2. Copy and paste your coding in the text area. Click 'Parse' button.
3. Copy the parsed code snippet, and paste it in the HTML mode in your post.
4. Add <blockquote></blockquote>to any lines to get much elegant look.
OR....
1. Goto to Bloggerindraft. Make sure that you have logged in into your Blogspot account.
2. Follow steps from this site, BlogPandit.
Reference: BlogPandit
Subscribe to:
Posts (Atom)