Subject SELECT .. WHERE TABLE_x.FEILD_x IN (VAL_x,VAL_y) AND TABLE_a.FEILD_a=VAL_a
Author LtColRDSChauhan
Hello,
1. I'm using FB 2.5.0.26124 [Admin tool FlameRobin 0.9.32048].
2. My select stored procedure [appended in full at Para 4 below] on
joined tables with a where clause on lines as above fetches the first
record which satisfies the where conditions, although there are other
records present satisfying the conditions. Such records get listed
when i remove the part :-

TABLE_x.FEILD_x IN (VAL_x,VAL_y)

from the stored procedure.
3. Stored procedure with similar where conditions but without joining
tables works fine.
4. The Stored Procedure:-
SET TERM ^ ;
ALTER PROCEDURE ZPATHO_DISPLAY_PT_RPT
(

IP_SEX char(1),

IP_SERVICEID integer )

RETURNS
(
REPORTID integer,

OP_TESTID integer,

OP_TESTNAME varchar(80),

OP_TXTVAL varchar(500),

OP_LDECVAL decimal(18,2),

OP_HDECVAL decimal(18,2),

OP_UNITS varchar(20),

OP_LAGE decimal(6,3),

OP_HAGE decimal(6,3),

OP_NORMAL_VAL varchar(200),

IS_DFLT smallint )

AS

declare variable COUNT_SRVCID smallint default 0;

BEGIN

/* 'suspend' the REPORT name only as the heading
[indicated in front end by REPORTID set to -1],
followed by the report test details */
select a.DESCRIPTION from CHARGES a where a.SERVICEID=:IP_SERVICEID
into :OP_TESTNAME;

REPORTID=-1;
suspend;

select count(r.SERVICEID) from ZPATHO_TESTS_IN_RPT r
where r.SERVICEID=:IP_SERVICEID
into :COUNT_SRVCID;

if(:COUNT_SRVCID > 0) then
begin
for
SELECT a.SERVICEID, r.TESTID, r.TESTNAME, r.TXTVAL, r.LDECVAL,
r.HDECVAL, r.UNITS, r.LAGE, r.HAGE, r.SEX, r.NORMAL_VAL,
r.IS_DFLT_TXT_VAL
FROM
ZPATHO_TESTS_IN_RPT a left outer join
ZPATHO_TEST_VALS r on a.TESTID=r.TESTID
where

upper(trim(r.SEX)) in (upper(trim(:IP_SEX)),'A')
and
a.SERVICEID = :IP_SERVICEID

order by a.LINE_NO asc, a.TESTID asc
into
:REPORTID, :OP_TESTID, :OP_TESTNAME, :OP_TXTVAL, :OP_LDECVAL,
:OP_HDECVAL, :OP_UNITS, :OP_LAGE, :OP_HAGE, :IP_SEX, :OP_NORMAL_VAL,
:IS_DFLT
do
begin
suspend;
end
end
else
begin
REPORTID=0; OP_TESTID=null; OP_TESTNAME='Not in pathology database';
OP_TXTVAL=''; OP_LDECVAL=0; OP_HDECVAL=0; OP_UNITS='';
OP_LAGE=null; OP_HAGE=null; OP_NORMAL_VAL='';
suspend;
end

END^

SET TERM ; ^



GRANT EXECUTE
ON PROCEDURE ZPATHO_DISPLAY_PT_RPT TO SYSDBA;

5. If any one can please identify what is incorrect in my stored procedure.
Thanks and Regards,

  Lt Col (Retd) Rajiv Dular Singh Chauhan
  09601704890
  0265-2637655
_____________________________