Article View: borland.public.interbase.sql
Article #268Joining stored procs in a query gives different results in IB 2007 and IB 7.5
From: Kjell Ljungqvist
Date: Thu, 07 Feb 2008 21:17
Date: Thu, 07 Feb 2008 21:17
94 lines
3067 bytes
3067 bytes
I entered this report into QC a few days ago (57839). No comments have been
made there yet so I thought I would like to here from you guys here in the
NG. Any comments on this? This change in behaviour between IB2007 and
earlier versions of IB (tested with IB 7.5 and IB 5.6) has caused as a
number of unpleasent experiences already.
When using "left join" to a stored proc in a select statement with IB 2007
the result set differs (see the NULL values in section 4 below) from the
result set that IB 7.x and IB 5.6 gives. In the example given here it seems
like only the last record in the dataset contains the correct information
from the SP. Hence queries that give only one record back are correct in IB
2007 too (section 5 below).
Regards,
Kjell
* * * * *
1. TABLE AND SP SETUP
-------------------------------------------
CREATE TABLE TEST_DATA (
ID INTEGER NOT NULL,
QTY INTEGER,
QTY2 INTEGER
);
ALTER TABLE TEST_DATA ADD CONSTRAINT PK_TEST_DATA PRIMARY KEY (ID);
CREATE PROCEDURE IS_EQUAL(
PLINK_ID INTEGER,
PVALUE1 INTEGER,
PVALUE2 INTEGER
)
RETURNS (
R_LINK_ID INTEGER,
R_EQUAL CHAR(1)
)
AS
BEGIN
R_LINK_ID=PLINK_ID;
if (PVALUE1=PVALUE2) then
R_EQUAL='T';
else
R_EQUAL='F';
suspend;
end
2. TESTDATA
-------------------------
INSERT INTO TEST_DATA (ID, QTY, QTY2 ) VALUES (1, 0, 0);
INSERT INTO TEST_DATA (ID, QTY, QTY2 ) VALUES (2, 1, 0);
INSERT INTO TEST_DATA (ID, QTY, QTY2 ) VALUES (3, 0, 1);
3. QUERY
-----------------
select * from TEST_DATA T
LEFT JOIN IS_EQUAL(T.ID,T.QTY,T.QTY2) CD
ON CD.R_LINK_ID=T.ID
4. RESULTS
---------------------
IB 2007:
ID QTY QTY2 R_LINK_ID R_EQUAL
1 0 0 NULL NULL
2 1 0 NULL NULL
3 0 1 3 F
IB 7.5
ID QTY QTY2 R_LINK_ID R_EQUAL
1 0 0 1 T
2 1 0 2 F
3 0 1 3 F
5. SINGLETON QUERY
--------------------------------------
select * from TEST_DATA T
LEFT JOIN IS_EQUAL(T.ID,T.QTY,T.QTY2)CD ON CD.R_LINK_ID=T.ID
where T.ID=2
IB 2007:
ID QTY QTY2 R_LINK_ID R_EQUAL
2 1 0 2 F
IB 7.5
ID QTY QTY2 R_LINK_ID R_EQUAL
2 1 0 2 F
* * * * *
Technical Details
Message-ID:
<47ab755a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!62.111.101.3.MISMATCH!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,6d404279065eef77,start X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Kjell Ljungqvist" <kjell@REMOVETHIS.iki.fi> Newsgroups: borland.public.interbase.sql Subject: Joining stored procs in a query gives different results in IB 2007 and IB 7.5 Date: Thu, 7 Feb 2008 23:17:04 +0200 Lines: 96 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 213.250.81.14 Message-ID: <47ab755a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1202419034 213.250.81.14 (7 Feb 2008 13:17:14 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!62.111.101.3.MISMATCH!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail