Subject Multiple Rows in a singleton fetch
Author guido.klapperich@t-online.de
I have the following Query
select CS.CSID,
CS.CSSAPNR,
CS.CSNRFIRST,
CS.CSNRLAST,
CS.CSDANAME1,
CS.CSDACITY,
CS.CSDAZIPCODE,
CS.CSDASTREET
from USERS_SALESAREAS UA join CUSTOMERS CS
on UA.UASAID=CS.CSSAID
where UA.UAUSID=:USID

KeyLinks: CUSTOMERS.CSID

OrderingItems:
SAP-Nr.=CSSAPNR;CSSAPNR DESC
Nr=CSNRFIRST,CSNRLAST;CSNRFIRST DESC,CSNRLAST DESC
Name=CSDANAME1_CITY;CSDANAME1_CITY DESC
City=CSDACITY;CSDACITY DESC
Zipcode=CSDAZIPCODE;CSDAZIPCODE DESC

OrderingLinks:
CSSAPNR=1
CUSTOMERS.CSNRFIRST=2
CUSTOMERS.CSDANAME1=3
CUSTOMERS.CSDACITY=4
CUSTOMERS.CSDAZIPCODE=5

When I open the query and want to change the OrderingItemNo, I get an
exception:
Multiple Rows in a singleton fetch
Check KeyLinks and JoinLinks properties

Here's the Monitor output:
/*---
PREPARE STATEMENT
TR_HANDLE = 16556392
STMT_HANDLE = 16556228

select CS.CSID,
CS.CSSAPNR,
CS.CSNRFIRST,
CS.CSNRLAST,
CS.CSDANAME1,
CS.CSDACITY,
CS.CSDAZIPCODE,
CS.CSDASTREET
from USERS_SALESAREAS UA join CUSTOMERS CS
on UA.UASAID=CS.CSSAID
where UA.UAUSID=? /* USID */
AND ( UPPER( CSDANAME1 ) >= ? /* OLNK_CSDANAME1 */ )
ORDER BY CSDANAME1_CITY ASC

PLAN SORT (JOIN (UA INDEX (I_UA_US_SA),CS INDEX (RDB$FOREIGN141)))

FIELDS = [ Version 1 SQLd 8 SQLn 30
CUSTOMERS.CSID = <NIL>
CUSTOMERS.CSSAPNR = <NIL>
CUSTOMERS.CSNRFIRST = <NIL>
CUSTOMERS.CSNRLAST = <NIL>
CUSTOMERS.CSDANAME1 = <NIL>
CUSTOMERS.CSDACITY = <NIL>
CUSTOMERS.CSDAZIPCODE = <NIL>
CUSTOMERS.CSDASTREET = <NIL> ]

SECONDS = 0,010
----*/
/*---
EXECUTE STATEMENT
TR_HANDLE = 16556392
STMT_HANDLE = 16556228
PARAMS = [ Version 1 SQLd 2 SQLn 2
[USID] = 13
[OLNK_CSDANAME1] = '' ]

SECONDS = 0,020
----*/
/*---
PREPARE STATEMENT
TR_HANDLE = 16556392
STMT_HANDLE = 16556056

select CS.CSID,
CS.CSSAPNR,
CS.CSNRFIRST,
CS.CSNRLAST,
CS.CSDANAME1,
CS.CSDACITY,
CS.CSDAZIPCODE,
CS.CSDASTREET
from USERS_SALESAREAS UA join CUSTOMERS CS
on UA.UASAID=CS.CSSAID
WHERE CUSTOMERS.CSID=? /* BIND_0 */

PLAN JOIN (CS INDEX (RDB$PRIMARY26),UA INDEX (RDB$FOREIGN205))

FIELDS = [ Version 1 SQLd 8 SQLn 8
CUSTOMERS.CSID = <n> 0
CUSTOMERS.CSSAPNR = <n> 0
CUSTOMERS.CSNRFIRST = <n> 0
CUSTOMERS.CSNRLAST = <n> 0
CUSTOMERS.CSDANAME1 = <n> ''
CUSTOMERS.CSDACITY = <n> ''
CUSTOMERS.CSDAZIPCODE = <n> ''
CUSTOMERS.CSDASTREET = <n> '' ]

SECONDS = 0,010
----*/

Any ideas what I'm doing wrong ?


Guido