Hi everybody,
I need to have a primary key which has to be unique on two tables.
E.g.:
CREATE TABLE first
(
id serial NOT NULL,
testo text,
)
CREATE TABLE second
(
id serial NOT NULL,
testo text,
)
When I insert some text on first, I would like first.id = second.id
+ 1, and vice versa.
When you use serial a kind of macro is performed: in fact an integer field is
created, a sequence is created with a name based on the table's name and the
nextval of that sequence is used as the default value for the field. Now you
have to do these steps manually.
CREATE SEQUENCE
am Thu, dem 22.11.2007, um 12:01:59 +0100 mailte Daniel bodom_lx Graziotin
folgendes:
Hi everybody,
I need to have a primary key which has to be unique on two tables.
E.g.:
CREATE TABLE first
(
id serial NOT NULL,
testo text,
)
CREATE TABLE second
(
id serial NOT NULL,
Am Dienstag, 20. November 2007 schrieb Andreas Joseph Krogh:
Is it considered safe to use 8.1's pg_dump to dump an 8.2-db and load it
into 8.1?
No, pg_dump will complain if you try that. It could work, with manual fixups
perhaps, but it is far from safe.
--
Peter Eisentraut
Richard Broersma Jr wrote:
Below I've included sample table definitions for a vertically
partitioned disjunctive table hierarchy. I wanted to point out the
use of the composite primary key declaration that is applied to two
columns that are clearly not a candidate key. However, using the
badly
On Thu, 22 Nov 2007 12:11:20 +0100
Bart Degryse [EMAIL PROTECTED] wrote:
When you use serial a kind of macro is performed: in fact an integer field is
created, a sequence is created with a name based on the table's name and the
nextval of that sequence is used as the default value for the
On Wed, Nov 21, 2007 at 09:14:14AM +0100, Bart Degryse wrote:
I would do something like this (not tested, but conceptually working):
Hello,
BEGIN
if old.story is not null and new.story != old.story then
new.story = sanitize_text(new.story);
end if;
--checks on other field can be included
On Tue, Nov 20, 2007 at 11:56:02AM -0500, Tom Lane wrote:
Louis-David Mitterrand [EMAIL PROTECTED] writes:
I'd like to use it on other tables an columns but how can the column
name be dynamic inside the procedure.
It can't --- plpgsql has no support for that. You could probably make
it
I don't really see how you could test a non-existing column. Here
if old.story is not null and new.story != old.story then
new.story = sanitize_text(new.story);
you would always use fields from OLD and NEW otherwise you can't even create
the trigger.
If a table has 3 fields (field1, field2
Hi,
I got the message "SQL state: 22P02"
to produce:
create table test (num varchar(20));
insert into test (num) values (null);
select * from test where cast(num as int8) = 0; --ok, no error
insert into test (num) values ('123123');
select * from test where cast(num as int8) = 123123;
On Nov 22, 2007 11:24 AM, Franklin Haut [EMAIL PROTECTED] wrote:
num return
--
0 0
null false
1212
a false
12ab false
it´s possible get these results ?
Try:
SELECT
NUM
, CASE
WHEN TRIM(NUM) ~
Tom Lane escribió:
Martin Marques [EMAIL PROTECTED] writes:
I have always heard that modification queries should be EXECUTED in PL.
AFAICR.
Run far away from whatever source gave you that advice...
Sorry, it was with DDL commands.
---(end of
Martin Marques [EMAIL PROTECTED] writes:
Tom Lane escribió:
Martin Marques [EMAIL PROTECTED] writes:
I have always heard that modification queries should be EXECUTED in PL.
AFAICR.
Run far away from whatever source gave you that advice...
Sorry, it was with DDL commands.
That's not
13 matches
Mail list logo