Tuesday, October 28, 2008

How to Handle Apostophes in DB2

Let us say if we have a table named EMPLOYEE having 2 coloumns EMPLY_ID, EMPLY__NM . if we want to update the name of EMPLLOYEE (ID:142082) from Satish to S'atish then we can use the below query.
UPDATE EMPLOYEE SET EMPLY_NM = 's''atish' where EMPLY_ID =142082.
Just use the double quotes instead of single quote to avoid SQL error 'Unbalanced Apsotrphes'
The MF database will recognize the double quote as 'Apostophe'.


Where it will be useful:
when you are passing a input parametre value having apostophe to stored procedure or COBOL program,to update it into database.

No comments:

Computers Add to Technorati Favorites Programming Blogs - BlogCatalog Blog Directory