|
|
|
|
|
|
| Author |
Message |
deanclowe@nf.sympatico.ca *nix forums beginner
Joined: 18 Feb 2005
Posts: 2
|
Posted: Fri Feb 18, 2005 6:30 pm Post subject:
Re: Field created from case statement / SQL0312
|
|
|
Thanks Serge,
That's exactly what I was looking for.
Dean |
|
| Back to top |
|
 |
Serge Rielau *nix forums Guru
Joined: 29 Apr 2005
Posts: 1583
|
Posted: Fri Feb 18, 2005 11:56 am Post subject:
Re: Field created from case statement / SQL0312
|
|
|
deanclowe@nf.sympatico.ca wrote:
| Quote: | Hi I have a query that is trying to use a field that is created "AS"
based on a case statement like this:
SELECT
CASE
WHEN IPOVH = 'Y' THEN '01'
WHEN IPHSI = 'Y' THEN '02'
WHEN IPVIS = 'Y' THEN '03'
ELSE ' '
END AS CRIT_CODE,
Func_Retreive_GenericTableDescription('CRIT', CRIT_CODE)
AS STAT_DESC
FROM ..... and so on...
But it doesn't seem to want to let me use CRIT_CODE in my function
call. (This runs on iSeries V5R3 and is part of a stored procedure).
Same thing happens when I try to use CRIT_CODE in a join. Is there
some way I can use the result of this case statement in
functions/joins?
Currently I get error SQL0312 Variable CRIT_CODE not defined or not
usable.
You cannot correlate within the select list. Conceptually all columns |
get generated in parallel. Try a nested select instead:
SELECT CRIT_CODE,
Func_Retreive_GenericTableDescription('CRIT', CRIT_CODE)
AS STAT_DESC
FROM (SELECT CRIT_CODE FROM .....) AS X
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab |
|
| Back to top |
|
 |
deanclowe@nf.sympatico.ca *nix forums beginner
Joined: 18 Feb 2005
Posts: 2
|
Posted: Fri Feb 18, 2005 3:29 am Post subject:
Field created from case statement / SQL0312
|
|
|
Hi I have a query that is trying to use a field that is created "AS"
based on a case statement like this:
SELECT
CASE
WHEN IPOVH = 'Y' THEN '01'
WHEN IPHSI = 'Y' THEN '02'
WHEN IPVIS = 'Y' THEN '03'
ELSE ' '
END AS CRIT_CODE,
Func_Retreive_GenericTableDescription('CRIT', CRIT_CODE)
AS STAT_DESC
FROM ..... and so on...
But it doesn't seem to want to let me use CRIT_CODE in my function
call. (This runs on iSeries V5R3 and is part of a stored procedure).
Same thing happens when I try to use CRIT_CODE in a join. Is there
some way I can use the result of this case statement in
functions/joins?
Currently I get error SQL0312 Variable CRIT_CODE not defined or not
usable. |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Jan 08, 2009 3:26 am | All times are GMT
|
|
Personal Loans | Bankruptcy | Car Finance | Mobile Phones | Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|