Re: Isn't the following variant much more "human"?
Originally posted by nandu
A touch of Genius ! jmodic you have ur own ways of refining!
Hm, I did not get you .What's wrong with that query.
Okay if I have a DECODE in the statement, can I use the BETWEEN function to finc the character value? For example:
In some cases while building the sql statements dynamically in some front end languages, we need to concatenate strings . While concatenation it is very difficult to merge strings like 'A' or '1'. Because single quote means different. In that case it is very easy to use chr(65) like to build dynamic SQL's . Any way it depends case by case.
str1='SELECT ename FROM Emp
WHERE upper(substr(ename,2,1)) BETWEEN'
str2 = str1 + ''A'' + ' AND ' + ''B''
It will trough an error
str2 = str1 + 'char(65)' it is easy so that we can get our whole select statement for immediate execute.
Hm, wonder why they invented a concept of BIND VARIABLES....
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
If I put the Between clause in quotes, it tries to interpret it as a literal. Do you know exactly how to code a between in the decode? I can't find any literature on it specifically.
,BETWEEN 'A' and 'Z','Water'
where table_id like 'C%'
Do you know exactly how to code
Try this way !
SELECT case when UPPER(SUBSTR(ename,2,1)) = '1' then 'Fire'
when UPPER(SUBSTR(ename,2,1)) BETWEEN 'A' and 'M' then 'Water'
when UPPER(SUBSTR(ename,2,1)) BETWEEN 'L' and 'Z' then 'Waste' else 'Unknown' end from emp
Never give up !
Nanda Kumar - Vellore
Click Here to Expand Forum to Full Width