SQL concatenation operator

cms technology web page configuration drupal web site
Setup and configuration of cms and drupal web site

using the || operator (two vertical bar) some databese use + operator

 

SQL> select 'my name is '||ename||', I started work on ' || hiredate from emp ;

'MYNAMEIS'||ENAME||',ISTARTEDWORKON'||HIREDATE
--------------------------------------------------
my name is SMITH, I started work on 17-DEC-80
my name is ALLEN, I started work on 20-FEB-81
my name is WARD, I started work on 22-FEB-81
my name is JONES, I started work on 02-APR-81
my name is MARTIN, I started work on 28-SEP-81
my name is BLAKE, I started work on 01-MAY-81
my name is CLARK, I started work on 09-JUN-81
my name is SCOTT, I started work on 19-APR-87
my name is KING, I started work on 17-NOV-81
my name is TURNER, I started work on 08-SEP-81
my name is ADAMS, I started work on 23-MAY-87

'MYNAMEIS'||ENAME||',ISTARTEDWORKON'||HIREDATE
--------------------------------------------------
my name is JAMES, I started work on 03-DEC-81
my name is FORD, I started work on 03-DEC-81
my name is MILLER, I started work on 23-JAN-82

14 rows selected.

 



SQL> select 'my name is '||ename||', I started work on ' || hiredate from emp
2


SQL> list
1* select 'my name is '||ename||', I started work on ' || hiredate from emp


SQL> save mynameis.sql
Created file mynameis.sql


SQL> run mynameis
1* select 'my name is '||ename||', I started work on ' || hiredate from emp

'MYNAMEIS'||ENAME||',ISTARTEDWORKON'||HIREDATE
--------------------------------------------------
my name is SMITH, I started work on 17-DEC-80
my name is ALLEN, I started work on 20-FEB-81
my name is WARD, I started work on 22-FEB-81
my name is JONES, I started work on 02-APR-81
my name is MARTIN, I started work on 28-SEP-81
my name is BLAKE, I started work on 01-MAY-81
my name is CLARK, I started work on 09-JUN-81
my name is SCOTT, I started work on 19-APR-87
my name is KING, I started work on 17-NOV-81
my name is TURNER, I started work on 08-SEP-81
my name is ADAMS, I started work on 23-MAY-87

'MYNAMEIS'||ENAME||',ISTARTEDWORKON'||HIREDATE
--------------------------------------------------
my name is JAMES, I started work on 03-DEC-81
my name is FORD, I started work on 03-DEC-81
my name is MILLER, I started work on 23-JAN-82

14 rows selected.

SQL>

SQL> edit mynameis

edit using the sql default editor

/*
File :mynameis.sql
Purpose: Display information from the emp table in the following format:
"My name is INITCAP(ename), I started work on hiredate."
*/


select
'my name is ' || INITCAP(ename) ||
', I started work on ' || hiredate
from emp
/

edit using textpad

 

SQL> start mynameis
DOC>File :mynameis.sql
DOC>Purpose: Display information from the emp table in the following format:
DOC>"My name is INITCAP(ename), I started work on hiredate."
DOC>*/

'MYNAMEIS'||INITCAP(ENAME)||',ISTARTEDWORKON'||HIR
--------------------------------------------------
my name is Smith, I started work on 17-DEC-80
my name is Allen, I started work on 20-FEB-81
my name is Ward, I started work on 22-FEB-81
my name is Jones, I started work on 02-APR-81
my name is Martin, I started work on 28-SEP-81
my name is Blake, I started work on 01-MAY-81
my name is Clark, I started work on 09-JUN-81
my name is Scott, I started work on 19-APR-87
my name is King, I started work on 17-NOV-81
my name is Turner, I started work on 08-SEP-81
my name is Adams, I started work on 23-MAY-87

'MYNAMEIS'||INITCAP(ENAME)||',ISTARTEDWORKON'||HIR
--------------------------------------------------
my name is James, I started work on 03-DEC-81
my name is Ford, I started work on 03-DEC-81
my name is Miller, I started work on 23-JAN-82

14 rows selected.

SQL> 

 

ADJUST SCREEN SIZE TO FIT ALL THE OUTPUT ON ONE SCREEN:

SQL> show pagesize
pagesize 14
SQL> show linesize
linesize 80
SQL> set pagesize 25
SQL> run mynameis
  1  select
  2     'my name is ' || INITCAP(ename) ||
  3     ', I started work on ' || hiredate
  4* from emp

'MYNAMEIS'||INITCAP(ENAME)||',ISTARTEDWORKON'||HIR
--------------------------------------------------
my name is Smith, I started work on 17-DEC-80
my name is Allen, I started work on 20-FEB-81
my name is Ward, I started work on 22-FEB-81
my name is Jones, I started work on 02-APR-81
my name is Martin, I started work on 28-SEP-81
my name is Blake, I started work on 01-MAY-81
my name is Clark, I started work on 09-JUN-81
my name is Scott, I started work on 19-APR-87
my name is King, I started work on 17-NOV-81
my name is Turner, I started work on 08-SEP-81
my name is Adams, I started work on 23-MAY-87
my name is James, I started work on 03-DEC-81
my name is Ford, I started work on 03-DEC-81
my name is Miller, I started work on 23-JAN-82

14 rows selected.

SQL> 

 


Custom Search