Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > IBM DB2 > DB2 'CASE' puzz...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 8956 of 9520
Post > Topic >>

DB2 'CASE' puzzle slqerr -811

by "lenygold via DBMonster.com" <u41482@[EMAIL PROTECTED] > Jun 7, 2008 at 07:30 PM

Hi  everybody?
here is 2 CASE EXAMPLES:

WITH CASE_SUB(A,B) AS
 (VALUES('z','1'),
              ('z','2'),
             ('x','1'))
SELECT
CASE
  WHEN (SELECT COUNT(A) from case_sub WHERE A='z') = 1
  THEN 'A'
  ELSE 'B'
END AS CASE
FROM CASE_SUB;

CASE
----
B   
B   
B   

  3 record(s) selected.

2ND EXAMPLE:

WITH CASE_SUB(A,B) AS
 (VALUES('z','1'),
               ('z','2'),
              ('x','1'))
SELECT
CASE
  WHEN (SELECT COUNT(A) from case_sub WHERE A='z') = 1
THEN
  (select B from CASE_SUB WHERE A='z')
ELSE 'B'
END  AS CASE
FROM CASE_SUB;

sqlcode: -811 The result of a scalar fullselect, SELECT INTO statement, or
VALUES INTO statement is more than one row.
WHY ELSE 'B' is not executed?

-- 
Message posted via http://www.dbmonster.com
 




 3 Posts in Topic:
DB2 'CASE' puzzle slqerr -811
"lenygold via DBMons  2008-06-07 19:30:17 
Re: DB2 'CASE' puzzle slqerr -811
Tonkuma <tonkuma@[EMAI  2008-06-07 19:10:48 
Re: DB2 'CASE' puzzle slqerr -811
"lenygold via DBMons  2008-06-08 02:33:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 20:40:19 CST 2008.