Re: [SQL] Inserting values in arrays

2005-03-15 Thread Richard Huxton
[EMAIL PROTECTED] wrote: CREATE TABLE test ( details varchar[]); CREATE TABLE test2 ( textvalue1 varchar, textvalue2 varchar); INSERT INTO test2 VALUES ('Hello1', 'World1'); INSERT INTO test2 VALUES ('hello2', 'World2'); and I am expecting the following rows in test {'Hello1', 'World1'} {'Hello2',

Re: [SQL] select multiple immediate values, but in multiple rows

2005-03-15 Thread Richard Huxton
Luca Pireddu wrote: Hello all. I'd like to write a query does a set subtraction A - B, but A is is a set of constants that I need to provide in the query as immediate values. I thought of something like select a from (1,2,3.4) except select col_name from table; richardh=> SELECT * FROM foo; a

Re: [SQL] Inserting values in arrays

2005-03-15 Thread Robert . Farrugia
Richard, So the solution can be:         (i) either write a function to insert the values into the array one by one         (ii) or else upgrade to 7.4 (or 8) to use the ARRAY syntax. Thanks a lot. Regards Robert Richard Huxton 03/15/2005 09:08 AM To [EMAIL PROTECTED] cc pgsql-sq

Re: [SQL] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-15 Thread Christoph Haller
Seems my remembrance was wrong, ::TEXT::BYTEA causes ERROR: cannot cast type text to bytea on my 7.4.5 version too. Looking into "Other Binary String Functions" within the manual, sheds light on how to do it: ::TEXT::BYTEA Function decode(string text, type text) Return Type bytea select deco

[SQL] comparing 2 tables

2005-03-15 Thread U K Laxmi
I've two Ms Access tables with the same structure. Tablestructure is as follows: Table table1 SbPartNo char(50) PartDesc char(200) manPartNo char(200) manufacturer char(100) vendor char(100) refDesi char(200) qty char(5) My requirement is as follows: table 1 partDesc1 11 xyz1 vendor1

Re: [SQL] Parameterized views proposition

2005-03-15 Thread Tambet Matiisen
... > > I wonder if it could be possible to improve CREATE VIEW > syntax by adding parameters? Something like this: > > CREATE VIEW product_sales(date,date) AS > select p.product_id, coalesce(sum(s.amount), 0) > from product p > left join sales s on p.product_id = s.product_id and s.date > bet

Re: [SQL] comparing 2 tables

2005-03-15 Thread Richard Huxton
U K Laxmi wrote: I've two Ms Access tables with the same structure. This is a PostgreSQL list - you'd probably be better using a Microsoft-Access list. [snip] Here what we should observe is, 1st row in table 1 not present in table2. 2nd row in table1 is modified in table2. 3rd row in table 2 is n

Re: [SQL] comparing 2 tables

2005-03-15 Thread U K Laxmi
Thank you for the reply. Sorry for posting this problem here. Thought SQL syntax for Ms Access and PostgreSQL are similar. So, i posted here. My problem is: I've original version of a table called PMM (Product Material Master). Thro' a web interface, user can change that table contents. Once cha

[SQL] How to force subquery scan?

2005-03-15 Thread Tambet Matiisen
Another (possibly design?) problem of mine. I have a function product_cost(product_id, date), which does simple SELECT call. I declared it as STABLE, hoping that multiple invocations of the same function are replaced with one. Query is something like this: SELECT p.product_id, avg(product_

Re: [SQL] comparing 2 tables

2005-03-15 Thread Richard Huxton
U K Laxmi wrote: Thank you for the reply. Sorry for posting this problem here. Thought SQL syntax for Ms Access and PostgreSQL are similar. So, i posted here. My problem is: I've original version of a table called PMM (Product Material Master). Thro' a web interface, user can change that table co

Re: [SQL] Generic Function

2005-03-15 Thread George Weaver
- Original Message - From: <[EMAIL PROTECTED]> To: Sent: Monday, March 14, 2005 12:15 PM Subject: [SQL] Generic Function Hi, Can I built a generic function like: CREATE FUNCTION f (text) RETURNS TEXT as $$ return 'select * from $1'; $$ I know its impossible as writed. Also I have lo

Re: [SQL] How to force subquery scan?

2005-03-15 Thread Christoph Haller
Tambet Matiisen wrote: > > Another (possibly design?) problem of mine. I have a function > product_cost(product_id, date), which does simple SELECT call. I > declared it as STABLE, hoping that multiple invocations of the same > function are replaced with one. Query is something like this: > > SEL

Re: [SQL] outputting dates

2005-03-15 Thread Christoph Haller
Kenneth Gonsalves wrote: > > hi, > i have set my datetype to 'European, SQL'. This correctly accepts > dates of the form dd/mm/. However, the output is still in the > '-mm-dd' format. How do i get the default output as dd/mm/? > -- > regards > kg > I have select version();

Re: [SQL] select multiple immediate values, but in multiple rows

2005-03-15 Thread PFC
You need a function like this : CREATE OR REPLACE FUNCTION array_srf( integer[] ) RETURNS SETOF integer LANGUAGE PLPGSQL etc... AS $$ DECLARE _data ALIAS FOR $1; _i INTEGER; BEGIN FOR _i IN 1..icount(_data) LOOP RETURN NEXT _data[_i];

Re: [SQL] Parameterized views proposition

2005-03-15 Thread Tom Lane
"Tambet Matiisen" <[EMAIL PROTECTED]> writes: > How tough it would be to implement > CREATE VIEW xxx PARAMETERS (yyy) AS zzz; > as > CREATE TYPE xxx; > CREATE FUNCTION xxx(yyy) RETURNING SETOF xxx LANGUAGE sql AS 'zzz'; What's the point? It'd be nonstandard anyway, so just use the function.

[SQL] Scheme not dropping

2005-03-15 Thread Graham Vickrage
I am dropping a database with an additional scheme other than public on version 7.3.2. When I come to recreate the database with the same scheme it gives me the error: ERROR: namespace "xxx" already exists Is this temp table issue, if so how do I get round it? Many thanks in advance. Graham

Re: [SQL] Scheme not dropping

2005-03-15 Thread Ragnar Hafstað
On Tue, 2005-03-15 at 18:44 +, Graham Vickrage wrote: > I am dropping a database with an additional scheme other than public on > version 7.3.2. > > When I come to recreate the database with the same scheme it gives me > the error: > > ERROR: namespace "xxx" already exists does the scheme e