<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - problem z funkcja, przekazanie ścieżki do pliku jako argument]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=470&amp;type=atom"/>
	<updated>2010-07-25T20:26:16Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=470</id>
		<entry>
			<title type="html"><![CDATA[Odp: problem z funkcja, przekazanie ścieżki do pliku jako argument]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2156#p2156"/>
			<content type="html"><![CDATA[dzięki, problem rozwiązany]]></content>
			<author>
				<name><![CDATA[pawmar]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1130</uri>
			</author>
			<updated>2010-07-25T20:26:16Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2156#p2156</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: problem z funkcja, przekazanie ścieżki do pliku jako argument]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2155#p2155"/>
			<content type="html"><![CDATA[1) Zamień funkcję z sql na plpgsql, dodaj bloki begin i end (i już powinna się utworzyć)
[code]
create function .... $$
begin
....
end;
$$
language 'plpgsql' 
[/code]
(jeśli nie masz zainstalowanego języka plpgsql musisz go wcześniej dodać)
2) Żeby dodać parametr z nazwą pliku dodaj po prostu parametr tekstowy
[code]
create function test(text)....
[/code]

i zmodyfikuj polecenie copy na 
[code]
execute ' copy tymczasowa from '||quote_literal($1)||...;
[/code]]]></content>
			<author>
				<name><![CDATA[rski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=26</uri>
			</author>
			<updated>2010-07-25T18:58:08Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2155#p2155</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[problem z funkcja, przekazanie ścieżki do pliku jako argument]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=2154#p2154"/>
			<content type="html"><![CDATA[dlaczego jak próbuję stworzyć taką funkcję:
create or replace function funkcja() returns void as
$$ 
create temporary table tymczasowa (
   trader_id character(8),
   full_date character(17),
   order_nbr integer,
   symbol character(4),
   order_action character(1),
   share_price numeric(8,4),
   fill_amount smallint,
   gateway character(4),
   order_price numeric(10,6),
   currency_code character(3),
   per_share_pl numeric(4,4),
   liquidity_flag character(1),
   billable_flag character(1),
   gross_pl numeric(7,4),
   exe_fee numeric(4,4),
   clr_fee numeric(4,4),
   gateway_charge numeric(11,8),
   act_fee numeric(4,4),
   sec_fee numeric(6,4),
   net_pl numeric(8,4),
   event_date character(8),
   time time without time zone );
   
   delete from baza;
   
   copy tymczasowa from 'd:/baza testowa.csv' csv quote '"';
   
   insert into baza
   select trader_id, to_timestamp(full_date, 'YYYYMMDDHH24MISSMS'),
   order_nbr, symbol, order_action, share_price, fill_amount,
   gateway, order_price, currency_code, per_share_pl, liquidity_flag,
   billable_flag, gross_pl, exe_fee, clr_fee, gateway_charge, act_fee,
   sec_fee, net_pl, to_date(event_date, 'MMDDYYYY'), time
   from tymczasowa;
$$
language 'sql';

pojawia się komunikat:
ERROR:  relation "tymczasowa" does not exist
LINE 37:    from tymczasowa;

oraz jak przekazywać ścieżkę do pliku jako argument funkcji?]]></content>
			<author>
				<name><![CDATA[pawmar]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1130</uri>
			</author>
			<updated>2010-07-24T23:02:35Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=2154#p2154</id>
		</entry>
</feed>
