[SQL] loosing connection after function call

2001-06-25 Thread Markus Wagner
Hi, I would like to put one table create command into a C function "my_init", just to provide a simple interface for all tables where these tables are needed. When I execute "select my_init();" I loose the database connection (pgaccess). Using psql -f I get the errors below. I reduced the complex

[SQL] pl/pgSQL and escaping LIKE clauses

2001-06-25 Thread Robby Slaughter
I'm having trouble getting LIKE clauses to work correctly inside a plpgSQL function. Here's my table: id | val +- 1 | hello 2 | there 3 | everyone Here's my function: CREATE FUNCTION intable(char) RETURNS INTEGER AS ' DECLARE input ALIAS FOR $1; temp INTEGER; B

[SQL] select with multiple occurences in same table

2001-06-25 Thread William Herring
  Table "inventorytrack"  Attribute  |   Type    | Modifier +---+--  tattoo | text  |  past_group | text  |  ranch  | text  |  ent_date   | timestamp |  indate | date  |     In the above table, I have multiple occurrences

Re: [SQL] Problems using a rule with the WHERE clause

2001-06-25 Thread Tom Lane
Luis Sousa <[EMAIL PROTECTED]> writes: > CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno" > WHERE OLD.idpessoal != 0 > DO INSTEAD ( > ... > When I execute the INSERT into de view docentesturno I got the message: > ERROR: Cannot update a view without an appropriate

[SQL] control structure in a transaction block?

2001-06-25 Thread Wei Weng
I am using postgresql 7.1.2. I am trying to implement the following pseudo code: BEGIN aid = select id from table_a where name = 'test'; if(aid != NULL) then { update set name = 'test_test' where id = aid; } else { insert into table_a values (nextval('table_a_id_seq'), 'test'); } COMMIT

Re: [SQL] Foreign key problem

2001-06-25 Thread Stephan Szabo
On 25 Jun 2001, Itai Zukerman wrote: > According to the documentation for CREATE TABLE: > > In addition, the referenced columns are supposed to be the columns > of a UNIQUE constraint in the referenced table, however Postgres > does not enforce this. > > Well, it looks like PostgreSQL *do

Re: [SQL] Foreign key problem

2001-06-25 Thread Itai Zukerman
Je Mon, 25 Jun 2001 09:34:01 +0200 (CEST), Andreas Tille <[EMAIL PROTECTED]> scribis: > CREATE TABLE ResKulturDetail > ( > IdLabNr int, > IdIndex smallint > ); > > CREATE TABLE ResKulturDetailDay > ( > IdLabNr int, > IdIndex smallint > ); > > CREATE INDEX IX_IdLabNr_KulturDe

[SQL] Foreign key problem

2001-06-25 Thread Andreas Tille
Hello, I tried to track down the database definitions from a more complex database which I have to convert from MS SQL to PostgreSQL. I have only one last syntactical error. Here is the striped down code to the shortest snipped which shows the problem: CREATE TABLE ResKulturDetail ( IdLabN