Tuesday 8 November 2011

Toad for Oracle and literals containing the ampersand character

The best way to construct a valid varchar literal that won't be rejected by the script execution in Toad for Oracle is to do something like this:
'john'||chr(38)||'sally'
The fact that the chr() function returns the ampersand as execution result makes it less problematic.

The above solution works well when you have to deal with the ampersand character within a stored procedure or forms script where you can assign the value to a declared variable.

However, when it comes to a normal update statement the following works much better:
update my_table set url='/faces/myservlet?paramOne=valueOne' || '&' || 'paramTwo=valueTwo' where id='myId'

When the ampersand stands alone in a literal value it seems to get bypassed as special character!!

Hope you find it handy ampersandy!

No comments:

Post a Comment