pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Piotr Adamiak <apj@vr.pl>
To: pgsql-sql@postgreSQL.org
Subject: Where is the problem ?
Date: Mon, 1 Jun 1998 14:29:37 +0200 (CEST)
Message-ID: <Pine.LNX.3.96.980601141400.22656A-100000@vr.pl> (raw)

Hi!

I am a beginning postgres user and having a more or less free weekend I
decided to do a test application using sql. Well all is not so great
because when I run "select logz('abc','mswindows',2)\g followed by a
select * from ipl_use\g I get a core dump :((( Does anybody know whats
wrong ? Also How do you use the transactions (begin/end) correctly ?
Also 2: Is there a way to get Insert to insert only when a condition is
met such as when there is no such user ?

BTW: I am running postgres 6.2.1 on a RedHat 5.* system.

Best regards,

/apj

-----------------------------[CUT]------------------------------------

CREATE TABLE ipl_ads (
ln int4,
ad varchar(60),
owner varchar(60),
fromwhen date,
counter int4
);

CREATE TABLE ipl_use (
ln int4,
user varchar(128),
prog varchar(128),
ad int4,
wdate date,
wtime time
);

CREATE SEQUENCE ad_ln;
CREATE SEQUENCE use_ln;

create table ad_num (f1 int4);
insert into ad_num values (1);

create table licz (f2 int4);
insert into licz values (1);

create function licznik() returns int4 as
'begin;
update licz set f2 = f2 + 1;
end;
select f2 from licz; '
language 'sql';

create function which_ad(int4) returns int4 as
'begin;
update ad_num set f1 = f1 + 1 where ad_num.f1 <= $1;
update ad_num set f1 = 1 where ad_num.f1 > $1;
update ipl_ads set counter = counter + 1 where ipl_ads.ln = ad_num.f1;
end;
select ln from ipl_ads where ipl_ads.ln = ad_num.f1; '
language 'sql';

create function logz(varchar, varchar, int4) returns int4 as
'insert into ipl_use values (licznik(), $1, $2, $3, current_date, current_time);
select ln from ipl_use where ipl_use.ln = licz.f2; '
language 'sql';

update licz set f2 = 2;





view thread (2+ messages)  latest in thread

Message-ID: <Pine.LNX.3.96.980601141400.22656A-100000@vr.pl>
Permalink:  ../Pine.LNX.3.96.980601141400.22656A-100000@vr.pl/
Also on:    postgresql.org/message-id/Pine.LNX.3.96.980601141400.22656A-100000@vr.pl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: apj@vr.pl
  Subject: Re: Where is the problem ?
  In-Reply-To: <Pine.LNX.3.96.980601141400.22656A-100000@vr.pl>
  References: <Pine.LNX.3.96.980601141400.22656A-100000@vr.pl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox