[SQL] COPY use in function with variable file name

2003-02-01 Thread Sondaar Roelof
Hello, I can't figure out how to make this work, or is not possible? In a function i would like to read a file. The file name is determined by a value from a table. However the COPY statement does not to accept this? I tried various forms of adding (single)-quotes but no luck. Anyone any ideas?

Re: [SQL] Creating tables from within functions

2003-02-01 Thread Sondaar Roelof
Hello, Try this: CREATE FUNCTION _testcreate () RETURNS text AS ' BEGIN CREATE TABLE switch_table2 (switch_id varchar(32), selection_name varchar(100)); RETURN ''true''; END; ' language 'plpgsql'; SELECT _testcreate(); Result: snlsor=# SELECT _testcreate(); _testcreate -

[SQL] Function x returns opaque in error typeidTypeRelid

2001-03-30 Thread Sondaar Roelof
Hello, I am a bit at a loss here. If I create a function which returns something it works fine. If it returns opaque I get the following: ERROR: typeidTypeRelid: Invalid type - oid = 0 What am I doing wrong ? Thanks in advance. Best regards, Roelof Sondaar dhcp=# drop function lalala(); DROP

RE: [SQL] Some questions about PLpgSql

2001-03-15 Thread Sondaar Roelof
Hello jack, To check if a table exists you could use: select tablename from pg_tables; For instance: dhcp=# select count(*) from pg_tables where tablename='dhcp_subnet'; count --- 1 (1 row) dhcp=# select count(*) from pg_tables where tablename='dhcp_subnetaa'; count --- 0 (1

[SQL] How to cast text to cidr/inet

2001-03-15 Thread Sondaar Roelof
Hello, I am battleling around to get a text field into a cidr and inet type field. The documentation says things like CAST(val AS text) but inet and cidr does not seem to exist. However the following works: dhcp=# insert into dhcp_subnet(ipaddress) values('139.122.172/18'); INSERT 46172 1 dhcp=#

RE: [SQL] Help creating rules/triggers/functions

2001-03-06 Thread Sondaar Roelof
Hello Blaise, I included a script I used to build/maintain a database. It also includes triggers and history logging. I hope you can use it. In the DO NOT use this part are test things which might not be correct. Best regards, Roelof <> > -Original Message- > From: Blaise Carrupt [SMT

RE: [SQL] Help creating rules/triggers/functions

2001-03-02 Thread Sondaar Roelof
Hello Blaise, The following is how I tested your question; DROP SEQUENCE b_id_seq; DROP TABLE b; CREATE TABLE b ( id SERIAL, description TEXT ); INSERT INTO b (description) VALUES('a'); INSERT INTO b (description) VALUES('b'); SELECT * FROM b; D