<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - update timestamp]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1427&amp;type=atom"/>
	<updated>2012-12-05T22:42:52Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1427</id>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3832#p3832"/>
			<content type="html"><![CDATA[wielkie dzieki za pomoc, własnie o to chodziło...]]></content>
			<author>
				<name><![CDATA[mkarach]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1197</uri>
			</author>
			<updated>2012-12-05T22:42:52Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3832#p3832</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3830#p3830"/>
			<content type="html"><![CDATA[Jeśli nie zależy Ci na kolejności, a tylko by zmienić pole czas to może wystarczy zrobić tak:

drop sequence lp;
create sequence lp START WITH  1;
update zgloszenie set czas=czas+nextval ('lp') * interval '00:01:00' where opid='6667' and czas='2012-12-31 00:00:00' and pesel<>'0']]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2012-12-05T14:47:39Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3830#p3830</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3829#p3829"/>
			<content type="html"><![CDATA[Jak masz uprawnienia do utworzenia widoku to może zrób 
1. create view v_tabela as select t.id ,czas from zgloszenie t where opid='6667' and czas='2012-12-31 00:00:00' and pesel<>'0' order by czas,id;
2. drop sequence lp;
3. create sequence lp START WITH  1;
4. update z tak zmodyfikowanym selectem
(select t.id ,czas+nextval ('lp') * interval '00:01:00' as nowa_data from v_tabela) t where t.id=d.id ;
5. drop sequence lp;]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2012-12-05T13:59:29Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3829#p3829</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3828#p3828"/>
			<content type="html"><![CDATA[Moje zapytanie select wyglada tak:

(select t.id ,czas+nextval ('lp') * interval '00:01:00' as nowa_data from
(select t.id ,czas from zgloszenie t order by czas,id) z) t where t.id=d.id and opid='6667' and czas='2012-12-31 00:00:00' and pesel<>'0';


jak je uruchamiam to mam:
LINE 3: ...t.id ,czas from zgloszenie t order by czas,id) z) d where t....
                                                             ^

********** Błąd **********

BŁĄD: błąd składni w lub blisko "d"
Stan SQL: 42601
Znak: 134]]></content>
			<author>
				<name><![CDATA[mkarach]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1197</uri>
			</author>
			<updated>2012-12-05T13:49:54Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3828#p3828</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3827#p3827"/>
			<content type="html"><![CDATA[a sam select się wykonuje?]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2012-12-05T13:46:04Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3827#p3827</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3826#p3826"/>
			<content type="html"><![CDATA[Czas chyba na aktualizacje postgresa


teraz mam takie cóś:
BŁĄD:  subquery in FROM cannot refer to other relations of same query level

********** Błąd **********

BŁĄD: subquery in FROM cannot refer to other relations of same query level
Stan SQL: 42P10]]></content>
			<author>
				<name><![CDATA[mkarach]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1197</uri>
			</author>
			<updated>2012-12-05T13:42:14Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3826#p3826</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3824#p3824"/>
			<content type="html"><![CDATA[no to trzeba wrócić do prehistorii :):):)

wykonaj wszystkie komendy naraz

create sequence lp START WITH  1;
update tabela t set data=d.nowa_data from 
(select id , data+nextval('lp') * interval '00:01:00' as nowa_data from (select t.id ,data from tabela t order by data,id) z) d where t.id=d.id;
drop sequence lp;]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2012-12-05T08:07:47Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3824#p3824</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3823#p3823"/>
			<content type="html"><![CDATA[mam wersje 8.3.7]]></content>
			<author>
				<name><![CDATA[mkarach]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1197</uri>
			</author>
			<updated>2012-12-04T22:07:51Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3823#p3823</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3822#p3822"/>
			<content type="html"><![CDATA[Napisz którą wersją postgresql dysponujesz. jeśli masz wyższą niż 8.4 to wszystko powinno być OK.]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2012-12-04T22:07:02Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3822#p3822</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3821#p3821"/>
			<content type="html"><![CDATA[dostałem błąd:
BŁĄD:  błąd składni w lub blisko "over"
LINE 2: (select t.id ,czas+row_number () over(order by czas,id ) * i...
                                                                 ^

********** Błąd **********]]></content>
			<author>
				<name><![CDATA[mkarach]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1197</uri>
			</author>
			<updated>2012-12-04T21:54:53Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3821#p3821</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3819#p3819"/>
			<content type="html"><![CDATA[Problem polega na tym, że najpierw musisz ustalić prawidłowa kolejność rekordów. Ja założyłem, że pole timestamp, które nazwałem "data" ma stałą wartość, a kolejność dodawania rekordów wyznacza pole id (im większa liczba w id tym później rekord został dodany). Ale gdyby było inaczej dodałem dodatkowe sortowanie też po polu data w poniższym update (co nic nie zmienia przy moich założeniach)

update tabela t set data=d.nowa_data from 
(select t.id ,data+row_number () over(order by data,id ) * interval '00:01:00' as nowa_data from tabela t) d where t.id=d.id]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2012-12-04T20:06:01Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3819#p3819</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[update timestamp]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3818#p3818"/>
			<content type="html"><![CDATA[Witam,

proszę o podpowiedź, mam tabele z 1500 rekordów która ma takie kolumny id,imie,nazwisko,pesel,timestamp
np 1, michal,michal,11111000111, 2012-12-30 00:00:00
     2, kasia,kasia, 22222000111,2012-12-30 00:00:00
itd do 1500

chodzi o napisanie query które dodaje minutę do każdego kolejnego rekordu


np 1, michal,michal,11111000111, 2012-12-30 00:01:00
     2, kasia,kasia, 22222000111,2012-12-30 00:02:00
itd do 1500


czy macie jakiś pomysł jak to ugryź?]]></content>
			<author>
				<name><![CDATA[mkarach]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1197</uri>
			</author>
			<updated>2012-12-04T14:00:45Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3818#p3818</id>
		</entry>
</feed>
