<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - funkcja wyzwalająca z pętlą]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=488&amp;type=atom"/>
	<updated>2010-10-04T18:07:13Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=488</id>
		<entry>
			<title type="html"><![CDATA[Odp: funkcja wyzwalająca z pętlą]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2211#p2211"/>
			<content type="html"><![CDATA[Chyba bez funkcji się nie obejdzie bo z grupwaniem to chyba będzie trudno zwykłego selecta w petlę wrzucić.
Próbowałeś napisać funkcję plpgsql z pętlą LOOP
[url]http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html[/url]]]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2010-10-04T18:07:13Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2211#p2211</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: funkcja wyzwalająca z pętlą]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2209#p2209"/>
			<content type="html"><![CDATA[hej, ma ktoś jakiś  pomysł, gdzie może być błąd?]]></content>
			<author>
				<name><![CDATA[pawmar]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1130</uri>
			</author>
			<updated>2010-09-30T21:15:36Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2209#p2209</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: funkcja wyzwalająca z pętlą]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2207#p2207"/>
			<content type="html"><![CDATA[oczywiście, że brakuje grupowania, polecenie to:
insert into testowa2 select '8:00', trader_id, sum(net_pl), event_date from baza
where time between '8:00' and '8:59'
group by trader_id, event_date;

Pojawia się błąd przy słowie select, muszą być 2 selecty?
Jeżeli usunę jednego selecta i przekształcę to trochę:

insert into testowa2 
select (h||':00', trader_id, sum(net_pl), event_date from baza
where time between (h||':00')::time and (h||':59')::time
group by trader_id, event_date)
from generate_series(8,17) h

to wywala błąd przy 'from' tym przed słowem baza. Nie wiem gdzie może być błąd.]]></content>
			<author>
				<name><![CDATA[pawmar]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1130</uri>
			</author>
			<updated>2010-09-22T21:37:00Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2207#p2207</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: funkcja wyzwalająca z pętlą]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2206#p2206"/>
			<content type="html"><![CDATA[A to polecenie 
[quote]
select '8:00', trader_id, sum(net_pl), event_date from baza
where time between '8:00' and '8:59';
[/quote]
to Ci dział, bo mi tu chyba jakiegoś grupowania brakuje. Jakiego postgresa ty używasz?

Jeśli powyższe Ci działa (w wątpię)  to rozwiązaniem twojego problemu może być

[code]
insert into testowa2 
select h||':00', 
select (trader_id, sum(net_pl), event_date from baza
where time between (h||':00')::time and (h||':59')::time)
from generate_series(8,17) h
[/code]]]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2010-09-21T18:31:47Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2206#p2206</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[funkcja wyzwalająca z pętlą]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2205#p2205"/>
			<content type="html"><![CDATA[witam, jak zamienić poniższą instrukcję:

insert into testowa2 select '8:00', trader_id, sum(net_pl), event_date from baza
where time between '8:00' and '8:59';

na funkcję wyzwalająca z pętlą aby godzina zmieniała od 8 do 17?]]></content>
			<author>
				<name><![CDATA[pawmar]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1130</uri>
			</author>
			<updated>2010-09-21T12:13:21Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2205#p2205</id>
		</entry>
</feed>
