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 NairPosted Feb 4, 2011, 2:15 PM
So other members can easily find the answers.
Suthish NairPosted Feb 2, 2011, 2:26 AM
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...
Syed Arbab AhmedPosted Feb 2, 2011, 1:05 AM
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 NairPosted Feb 1, 2011, 1:32 PM
Syed Arbab AhmedPosted Feb 1, 2011, 5:38 AM
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.
sanjay dobhalPosted Feb 1, 2011, 4:25 AM
Manikavelu VelayuthamPosted Feb 1, 2011, 2:35 AM
SELECT len('This sentence''s length will be calculated') "Length of characters" FROM dual
This is the right way
Suthish NairPosted Feb 1, 2011, 2:19 AM