Gunther Schadow <gunther(at)aurora(dot)regenstrief(dot)org> writes:
> SELECT fever.patient_id AS patient_id,
> fever.value AS fever,
> wbc.value AS wbc
> FROM (SELECT patient_id, value
> FROM STDIN) fever
> INNER JOIN Observation wbc
> ON fever.patient_id = wbc.patient_id
> WHERE wbc.type_code = 'WHITE BLOOD CELL COUNT'
> AND wbc.value < 1000;
A much more direct way of doing it is to leave the client out of the
loop. The data from system A could be pulled directly into system B,
using e.g. Joe Conway's contrib/dblink package. dblink is pretty
awkward to use in 7.2 but in 7.3 it should be a lot nicer --- the
returned data can be treated as a table function...
regards, tom lane