Sunday 21 February 2010

String Operator and Converting Uppercase ( Interbase Tutorial # 13 )

String Operator

We can also join two or more character strings into a single string using string operator. The string to be joined can be the value of a column we retrieve, or we may add some character strings. The operator for joining some character strings is || .

Execute these some SQL statements below :

    select name || ‘ is ’ || age || ‘ years old’ from employee

and we’ll get the data output :

================================== 
Isaac Newton is 30 years old  
Blaise Pascal is 25 years old  
Archimedes is 32 years old  
George Boole is 27 years old  
Frank Borland is 31 years old  
Max Planck is 28 years old

    select ’Boolean Algebra is developed by ‘ || name from employee
    where name=’George Boole’


the output is :

==================================== 
Boolean Algebra is developed by George Boole

select name || ‘ earns USD ‘ || totalsalary || ‘ per month’
from employee, salary
where id=employee_id


the output is :

================================ 
Isaac Newton earns USD 1100 per month  
Blaise Pascal earns USD 2200 per month  
Archimedes earns USD 3300 per month  
George Boole earns USD 4400 per month  

select ‘The highest salary is USD ‘ || max(totalsalary)from salary

the output is :

====================================== 
The highest salary is USD 4400

select ‘The total expense for salary is USD ‘ || sum(totalsalary)   from salary

the output is :

================================================ 
The total expense for salary is USD 11000

Now you can try another combinations of some character strings.

Converting Uppercase

To convert character values to uppercase, we use UPPER function. When you create a domain, use CHECK constraint to ensure that the value you enter is always in uppercase.
If you want the value of ‘name’ column always in uppercase, the statement to create domain is :

    CREATE DOMAIN string30 AS varchar(30)
    CHECK (VALUE = UPPER (VALUE))

Go to Previous Tutorial or Next Tutorial

11 comments:

  1. Makasih infonya Bang
    Bendol gaptek urusan yang begituan...
    Sukses ya bang
    Salam

    ReplyDelete
  2. Nice blog!!Plese follow my blog!!and visit
    http://teoringeblog.blogspot.com

    ReplyDelete
  3. masih belom paham kang
    kubaca pelan2 dulu ya

    ReplyDelete
  4. Karena Bendol bingung, numpang baca-2 lagi bro
    Smoga sukses ya...
    Salam

    ReplyDelete
  5. Bang Bendol, Adib, Satya :
    thanks a lot for dropping by, espescially bang bendol you've been here twice.. :)

    ReplyDelete
  6. walopun aku ga paham tapi bisa buat belajar... keren

    ReplyDelete
  7. sintax hampir mirip dengan MySQL... Benar gak??

    ReplyDelete
  8. Makasih infonya mas ari... tapi masih belum paham nich... hahaha...

    ReplyDelete
  9. All : thanks for dropping by
    Anas : all the SQL server has similar SQL codes..thanks

    ReplyDelete

These links are part of a pay per click advertising program called Infolinks. Infolinks is an In Text advertising service; they take my text and create links within it. If you hover your mouse over these double underlined links, you will see a small dialog box containing an advertisement related to the text. You can choose to move the mouse away and go on with your browsing, or to click on the box and visit the relevant ad. Click here to learn more about Infolinks Double Underline Link Ads.