From: | Jon Griffin <jon(at)jongriffin(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | plpgsql question |
Date: | 2010-08-28 01:48:40 |
Message-ID: | 4C786AF8.40602@jongriffin.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am trying to calculate a value from a current record in a query and
can't seem to get it working.
Here is the shortened query;
SELECT
s.id,
r.the_date_time,
s.open_price,
s.high_price,
s.low_price,
s.close_price,
thesheet_onepair.symbol,
r.buy_long,
r.buy_stop,
r.sell_cl,
r.stop_sell,
r.sell_short,
r.sell_stop,
r.buy_os,
r.stop_buy,
check_long_profit ()as tst
FROM
public.thesheet_dailystats s,
public.thesheet_recommendation r,
public.thesheet_onepair
WHERE
s.one_pair_id = thesheet_onepair.id AND
s.the_date = r.the_date_time::date AND
r.one_pair_id = thesheet_onepair.id
ORDER BY
r.the_date_time DESC,
thesheet_onepair.id ASC;
check_long_profit is the function. I basically want to do some
calculations on this record and return some calculated fields.
I can't seem to figure out how to pass the row.
Here is my header for the function
create or replace function check_long_profit () returns integer AS $$
I know I am missing something easy.
Thanks
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2010-08-28 03:25:09 | Re: plpgsql question |
Previous Message | John R Pierce | 2010-08-27 22:36:03 | Re: Index File locations |