Unix Technical Forum

different results procedure versus query analyser

This is a discussion on different results procedure versus query analyser within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hi, I use a 'sum/group by' query in a stored procedure to calculate some aggregated levels. However, the results ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 10:33 AM
Blaenzo
 
Posts: n/a
Default different results procedure versus query analyser

Hi,

I use a 'sum/group by' query in a stored procedure to calculate some
aggregated levels.

However, the results are slightly different from the EXACT SAME query
run by hand in a query analyser window (same user).

The procedure stores some records of a certain table1 into a temporary
table and directly uses a insert/select sum statement to add summed
values to an other table2.

Directly selecting/summing these data from table1 by hand results in
(some) different records.

The use of the temp table is for other purposes.
I stripped the code as much as posible and replaced the temp table by a
'real' table and still get different results.

I use Oracle 10g XE on Win2K.

Does this sound familiar to anyone?
Many thanks,
Martijn

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 10:34 AM
Blaenzo
 
Posts: n/a
Default Re: different results procedure versus query analyser

This is my sproc btw:

CREATE OR REPLACE PROCEDURE "VARADMIN"."INSERTPNLVECTORFORAGGPOS2"(
VMRTKCOBDATE IN DATE,
VAGGPOSLONGID IN VARCHAR2)
AS
BEGIN
INSERT INTO TEMPTABLE
SELECT VAGGPOSLONGID, MRTKCOBDATE, PNLVECTORTYPEID,
SCENARIOID, ELEMENTNUMBER ,NEWVALUE,ERRORSTATUS,
RISKFACTORGROUPID, NEWIGNOREREPORTSTATUS, ALTVALUE
FROM PNLVECTOR
WHERE MRTKCOBDATE=VMRTKCOBDATE
AND SCENARIOID=0
AND ERRORSTATUS='V'
AND NEWIGNOREREPORTSTATUS='R'
AND DESKLONGID IN
(SELECT DESKLONGID
FROM AGGDESKMAPPING
WHERE AGGPOSLONGID=VAGGPOSLONGID
AND CRTDATETIME=VMRTKCOBDATE
AND DESKLONGID NOT IN
(SELECT DESKLONGID
FROM AGGDESKMAPPING, AGGHIERARCHY
WHERE PARENT=VAGGPOSLONGID
AND CHILD=AGGPOSLONGID
AND AGGDESKMAPPING.CRTDATETIME=AGGHIERARCHY.CRTDATETIM E));

/* INSERT INTO TEMPTABLE
SELECT *
FROM AGGPNLVECTOR
WHERE MRTKCOBDATE=VMRTKCOBDATE
AND AGGPOSLONGID IN
(SELECT DISTINCT CHILD
FROM AGGHIERARCHY
WHERE PARENT=VAGGPOSLONGID
AND CRTDATETIME=VMRTKCOBDATE); */

INSERT INTO AGGPNLVECTOR
SELECT AGGPOSLONGID, MRTKCOBDATE, PNLVECTORTYPEID,
SCENARIOID, ELEMENTNUMBER ,SUM(NEWVALUE),
ERRORSTATUS, RISKFACTORGROUPID,
NEWIGNOREREPORTSTATUS, SUM(ALTVALUE)
FROM TEMPTABLE
WHERE AGGPOSLoNGID=VAGGPOSLONGID
GROUP BY AGGPOSLONGID, MRTKCOBDATE, PNLVECTORTYPEID,
SCENARIOID, ELEMENTNUMBER ,ERRORSTATUS,
RISKFACTORGROUPID, NEWIGNOREREPORTSTATUS;

END;

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:32 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com