Quantcast
Channel: VBForums - Database Development
Viewing all articles
Browse latest Browse all 2918

Oracle: better way to pull and manipulate this data?

$
0
0
The data in question are series (Levelx in the query below) of data from a tester (torque, pressure, etc), 100 points per series. The issue is I need to interpolate readings at a couple specific points on the curves for trend analysis. I'd like the end result to go into a temp table as below, which will then be what my .Net app pulls from to put into Excel.

CREATE GLOBAL TEMPORARY TABLE TEMPPUMPHISTORY
(SERIALNO mfgunit.serialno%type NOT NULL
,OPERATION operation.operation%type NOT NULL
,TESTDATE pumpdata.datetested%type NOT NULL
,FLOW75 NUMBER(6)
,FLOW150 NUMBER(6)
,TORQUE75 NUMBER(6)
,TORQUE150 NUMBER(6)
,PRESSURE7 NUMBER(6)
,PRESSURE5 NUMBER(6)
)
ON COMMIT DELETE ROWS;

So far, the initial query to obtain the points I need is below (pumptestID will eventually come from a cursor and 75 may be a parameter).

Select ph.Levelx, pp.PointNumber, pp.Valuex
From PumpDataHeader PH, PumpDataPoints PP
Where ph.PumpDataHeaderID = pp.PumpDataHeaderID AND ph.pumptestID = 5678680 and ph.FlowPark=0
and (pp.pointnumber = (select max(pointnumber)
from PumpDataHeader PH, PumpDataPoints PP
where ph.PumpDataHeaderID = pp.PumpDataHeaderID AND ph.pumptestid=5678680 and flowpark=0
and levelx=1 and valuex <= 75)
or pp.pointnumber = (select max(pointnumber) + 1
from PumpDataHeader PH, PumpDataPoints PP
where ph.PumpDataHeaderID = pp.PumpDataHeaderID AND ph.pumptestid=5678680 and flowpark=0
and levelx=1 and valuex <= 75));

It provides the points for all series (Levelx) on either side of 75 bar for one test, which happens to be points 4 and 5 in the series for this case.

Levelx Point# Valuex
0 4 26.013
0 5 26.421
1 4 73.685
1 5 75.394
2 4 701.012
2 5 701.373
3 4 10.723
3 5 10.665

This is where I'm not certain how best to continue (assuming what I've done above is OK). Not sure if I should stick this into a second temp table, cursor, varray, ???

If it was a .Net array, I could easily do the calculations I need by using the individual array elements in the equation: Flow @ 75 bar = 10.723 + (75 - 73.685) * (10.665 - 10.723) / (75.394 - 73.685)

I'm trying to do everything on the server to reduce network traffic. I'm just having brain freeze on how to best to accomplish this in PL/SQL.

Once I figure it out, the sproc will do the same routine again for 150 bar and then pressure at a specific flow. Finally INSERT into the temp table and loop to the next testID in the cursor.

Viewing all articles
Browse latest Browse all 2918

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>