I am calculating the length of a sentence using Length (scalar function), then
I also used that keyword in the sentence, but I am having an error for all the
queries below:
Error: Missing right parenthesis.
1-SELECT LENGTH('This sentence's length will be calculated') "Length of
characters"
FROM dual;
2- SELECT LENGTH('This sentence's 'length' will be calculated') "Length of
characters"
FROM dual;
3- SELECT LENGTH('This sentence's "length" will be calculated')
"Length of characters"
FROM dual;
4-SELECT LENGTH('This sentence's "\length\" will be calculated')
"Length of characters"
FROM dual;
5- SELECT LENGTH('This sentence's '\length\' will be calculated') "Length
of characters"
FROM dual;
What should be the correct way to write this query?
Thanks in advance
Loading

Suthish NairRank #92 · 22.8K reputationPosted Jan 31, 2011, 9:19 PM EST
Manikavelu VelayuthamRank #413 · 6K reputationPosted Jan 31, 2011, 9:35 PM EST
SELECT len('This sentence''s length will be calculated') "Length of characters" FROM dual
This is the right way
sanjay dobhal7 reputationPosted Jan 31, 2011, 11:25 PM EST
Syed Arbab Ahmed88 reputationPosted Feb 1, 2011, 12:38 AM EST
SELECT LENGTH('This sentence''s length will be calculated') "Length of characters"
FROM dual;
Your query had Len instead of length which gave "Invalid Identifier" error.
2- The good point of your reply was single quote after sentence word along with its apostrophe, I got it from there, but it took time as you did not defined it.
Suthish NairRank #92 · 22.8K reputationPosted Feb 1, 2011, 8:32 AM EST
Syed Arbab Ahmed88 reputationPosted Feb 1, 2011, 8:05 PM EST
use " (double quotes) or '' (two single quotes) to escape single quote
where, when & how to use it? If you would have write the query using quotes, It would have been better for a novice like me.
Suthish NairRank #92 · 22.8K reputationPosted Feb 1, 2011, 9:26 PM EST
As you said "I want to learn, how to be a good programmer. ", did you tried to explore why the error came up.
No, but you got a reply with sql statement and you copy paste that statement into editor and executed, you got the o/p.
I posted clearly, to escape single quote you need to use double quotes or two single quotes.
This is how people learn, from errors, mistakes etc...
Suthish NairRank #92 · 22.8K reputationPosted Feb 4, 2011, 9:15 AM EST
So other members can easily find the answers.