Transaction Question

From: mark lonsdale <mark(at)marklonsdale(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Transaction Question
Date: 2002-05-02 15:38:15
Message-ID: 3CD15D67.8030705@marklonsdale.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi

Im a newbie to this but am trying to set up a transaction that will
insert a new row into a table based on values in other tables ( multiple
tables )

I can see that insert's like

insert into links select max(link_id) + 1 from agent

seem to work okay, but I want to pull in information from multiple
tables.. I thought something like this would work..

insert into links select max(link_id) + 1, a.agent_id, n.node_id from
links l, agent a, nodes n ;

but it doesn't seem to..

When I used to use sybase a few years back I remember being able to do
something like

select @variable=field fom table
insert into newtable values(@variable)

Is there any similar variable substitution I can do in postgresql to do
the same thing.. Ideally I need my code to also work on other rdms's as
well so it would have to be a standard sql feature.

Also, is there any way to do conditional statements from within a
transactinon e.g. if statements ?

Thanks

Mark

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2002-05-02 16:31:22 Re: error messages
Previous Message mark lonsdale 2002-05-02 15:08:35 subscribe