Обсуждение: UPDATE subselect?

Поиск
Список
Период
Сортировка

UPDATE subselect?

От
Chris Bitmead
Дата:
What is the correct syntax for this UPDATE?

CREATE TABLE category ( name text, image text, url text, parent oid[]
);
update category set parent = '{0,0}' where name='slr';
So far so good...
update category set parent[0] = (SELECT oid from mfr where
name='canon');
ERROR:  parser: parse error at or near "select"



-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com


Re: [SQL] UPDATE subselect?

От
José Soares
Дата:
Take a look at PostgreSQL User's Guide
Chapter 10. Arrays

syntax:
INSERT INTO SAL_EMP   VALUES ('Bill',   '{10000, 10000, 10000, 10000}',   '{{"meeting", "lunch"}, {}}');

José

Chris Bitmead ha scritto:

> What is the correct syntax for this UPDATE?
>
> CREATE TABLE category (
>   name text,
>   image text,
>   url text,
>   parent oid[]
> );
> update category set parent = '{0,0}' where name='slr';
> So far so good...
> update category set parent[0] = (SELECT oid from mfr where
> name='canon');
> ERROR:  parser: parse error at or near "select"
>
> --
> Chris Bitmead
> http://www.bigfoot.com/~chris.bitmead
> mailto:chris.bitmead@bigfoot.com



Re: [SQL] UPDATE subselect?

От
Chris Bitmead
Дата:
José Soares wrote:
> 
> Take a look at PostgreSQL User's Guide
> Chapter 10. Arrays

Which doesn't help me because I need to update individual array elements
from subselects.

> 
> syntax:
> INSERT INTO SAL_EMP
>     VALUES ('Bill',
>     '{10000, 10000, 10000, 10000}',
>     '{{"meeting", "lunch"}, {}}');
> 
> José
> 
> Chris Bitmead ha scritto:
> 
> > What is the correct syntax for this UPDATE?
> >
> > CREATE TABLE category (
> >   name text,
> >   image text,
> >   url text,
> >   parent oid[]
> > );
> > update category set parent = '{0,0}' where name='slr';
> > So far so good...
> > update category set parent[0] = (SELECT oid from mfr where
> > name='canon');
> > ERROR:  parser: parse error at or near "select"
> >
> > --
> > Chris Bitmead
> > http://www.bigfoot.com/~chris.bitmead
> > mailto:chris.bitmead@bigfoot.com

-- 
Chris Bitmead
http://www.bigfoot.com/~chris.bitmead
mailto:chris.bitmead@bigfoot.com