<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Funkcja zwracająca tabelę]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1891&amp;type=atom"/>
	<updated>2013-10-02T12:13:32Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1891</id>
		<entry>
			<title type="html"><![CDATA[Odp: Funkcja zwracająca tabelę]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4738#p4738"/>
			<content type="html"><![CDATA[Można by też utworzyć widok z ilosc*10 i w funkcji odwoływać się "returns setof widok" , "Select *.." do widoku, a nie do tabeli]]></content>
			<author>
				<name><![CDATA[adamleon]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=873</uri>
			</author>
			<updated>2013-10-02T12:13:32Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4738#p4738</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Funkcja zwracająca tabelę]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4737#p4737"/>
			<content type="html"><![CDATA[najszybciej zrobic to tak

create or replace function()
returns setof kolorowanka
as
$$ select id,kolor,ilość*10 as koszt
     from kolorowanka;
$$
language sql;

Jeśli takie rozwiązanie Cie nie zadowala to musisz stworzyć nowy typ danych zobacz polecenie CREATE TYPE w postgresql i podpiąć go jako typ zwracany pod swoją funkcję]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2013-10-02T11:21:13Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4737#p4737</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Funkcja zwracająca tabelę]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=4735#p4735"/>
			<content type="html"><![CDATA[Mam przykładowo tabelę kolorowanka:

id | kolor | ilość
-------------------
1 | r         | 3
2 | g        | 4
3 | b        | 1
...|...        |

---------------------------------------------------
Piszę funkcję:

create or replace function()
returns setof kolorowanka
as 
$$ select * 
     from kolorowanka;
$$
language sql;

Działa OK.

--------------------------------------------
Jak powinienem napisać funkcję, abym mógł w niej wstawić takiego selecta ?


create or replace function()
returns setof kolorowanka  + ???????
as 
$$ select *,
              ilość*10 as koszt
    from kolorowanka;
$$
language sql;


???????????????]]></content>
			<author>
				<name><![CDATA[tomek]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1459</uri>
			</author>
			<updated>2013-10-02T08:05:24Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=4735#p4735</id>
		</entry>
</feed>
