<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Jak uruchomić procedurę?]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=170&amp;type=atom"/>
	<updated>2009-04-02T14:59:25Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=170</id>
		<entry>
			<title type="html"><![CDATA[Odp: Jak uruchomić procedurę?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=684#p684"/>
			<content type="html"><![CDATA[Dziękuje wykonało się bez problemu. :)]]></content>
			<author>
				<name><![CDATA[woziu]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=64</uri>
			</author>
			<updated>2009-04-02T14:59:25Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=684#p684</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Jak uruchomić procedurę?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=682#p682"/>
			<content type="html"><![CDATA[Aha i byl jeszcze kiedyś dodatek to postgresa 'ora coś tam' się nazywał. Który dodawał funkcje z oracla (m.in. chyba była tam funkcja do ładnego wypisywania komunikatów). Jak sobie przypomnę nazwę to podrzucę na forum.]]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2009-04-02T14:33:48Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=682#p682</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Jak uruchomić procedurę?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=681#p681"/>
			<content type="html"><![CDATA[Rozwiązań pewnie będzie wiele np
[code]
create function f_test() returns setof test as '
declare r test%rowtype; 
begin 
    for r in select * from test loop 
      return next r; 
    end loop; 
end;
'
language plpgsql;
[/code]
i uruchamiasz poleceniem 
[code] 
select * from f_test();
[/code]
Albo np

[code]
create function f_test2() returns varchar as $$
declare r test%rowtype; 
begin 
   for r in select * from test loop 
    raise info 'wartosci %',r.i;  --i tu wymieniasz to co chcesz wypisac
   end loop; 
   return 'Done'; 
end; 
$$
language plpgsql;
[/code]
i wywołujesz
[code]
select f_test2();
[/code]

Pamiętaj, że plpgsql nie został stworzony do tego aby wypisywać dane na ekran w związku z czym nie ma tu specjalnej koemendy wypisywania czegoś na ekran (cos jak dbms_output w oraclu)]]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2009-04-02T14:23:20Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=681#p681</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Jak uruchomić procedurę?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=680#p680"/>
			<content type="html"><![CDATA[Tabela osoby wygląda tak:
CREATE TABLE osoby
(
  idosoby numeric(10) NOT NULL,
  iddzialu numeric(10),
  nazwisko character varying(15),
  imie character varying(15),
  rokurodz numeric(4),
  wzrost numeric(3,2),
  idszefa numeric(10),
  CONSTRAINT osoby_pkey PRIMARY KEY (idosoby)
)]]></content>
			<author>
				<name><![CDATA[woziu]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=64</uri>
			</author>
			<updated>2009-04-02T14:03:49Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=680#p680</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Jak uruchomić procedurę?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=677#p677"/>
			<content type="html"><![CDATA[Procedura ma wyświetlić to co się znajduje w tabeli osoby.

No właśnie nie wiem, jaki typ muszę podać " returns typ"?
A kolumny w tabeli osoby mam różnego typu.:)
Jak mam brak typu, to błąd składni?]]></content>
			<author>
				<name><![CDATA[woziu]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=64</uri>
			</author>
			<updated>2009-04-02T13:02:26Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=677#p677</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: Jak uruchomić procedurę?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=676#p676"/>
			<content type="html"><![CDATA[A co ta procedura ma robić? Bo piszesz 'returns numeric' a w kodzie masz 'select * form ...']]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2009-04-02T12:42:52Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=676#p676</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Jak uruchomić procedurę?]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=675#p675"/>
			<content type="html"><![CDATA[Mam taką procedurę,
CREATE FUNCTION p2() Returns numeric AS'
BEGIN 
select * from osoby ;
END; '
LANGUAGE 'plpgsql'

Zapytanie wykonało się.

Jak robię select p2; to mam taki błąd
BŁĄD: query has no destination for result data
Stan SQL:42601
Wskazówka:If you want to discard the results of a SELECT, use PERFORM instead.
Kontekst:PL/pgSQL function "p2" line 2 at SQL statement

przy EXECUTE p2; prepared statement "p2" does not exist

Co zrobić aby tą procedurę uruchomić. Jest to moja pierwsza procedura:)]]></content>
			<author>
				<name><![CDATA[woziu]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=64</uri>
			</author>
			<updated>2009-04-02T11:47:58Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=675#p675</id>
		</entry>
</feed>
