<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - Insert INTO]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=1227&amp;type=atom"/>
	<updated>2012-02-14T17:38:29Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=1227</id>
		<entry>
			<title type="html"><![CDATA[Odp: Insert INTO]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3431#p3431"/>
			<content type="html"><![CDATA[Tabela zawiera tylko jedną kolumnę typu serial (czyli integer + sekwencja) w dodatku określoną jako klucz główny (btw nie trzeba dodawać explicite NOT NULL przy id, sam klucz to gwarantuje). Przy insercie można podać default values tzn.:

[code]Insert Into customer Default Values;[/code]

Jeśli dodatkowo przydzielone id ma zostać zwrócone, to wystarczy dodac returning tj.:

[code]Insert Into customer Default Values Returning id;[/code]

[url]http://www.postgresql.org/docs/current/static/sql-insert.html[/url]]]></content>
			<author>
				<name><![CDATA[gszpetkowski]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1223</uri>
			</author>
			<updated>2012-02-14T17:38:29Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3431#p3431</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Insert INTO]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=3430#p3430"/>
			<content type="html"><![CDATA[Mam tabele 

CREATE TABLE customer (
  id serial NOT NULL,
  CONSTRAINT customer_pkey PRIMARY KEY (id)
)

Jak wprowadzić pusty rekord , żeby postgres zwrócił unikalne id.
Polecenie 
insert into customer (id) values (''); 
zwraca błąd 
ERROR:  invalid input syntax for integer: ""
LINIA 1: insert into customer (id) values ('');
                                                                          ^

Z góry dziękuje za pomoc]]></content>
			<author>
				<name><![CDATA[costy]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=1367</uri>
			</author>
			<updated>2012-02-14T16:03:25Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=3430#p3430</id>
		</entry>
</feed>
