pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
UPDATE subselect?
4+ messages / 3 participants
[nested] [flat]

* UPDATE subselect?
@ 1999-04-16 13:10  Chris Bitmead <chris.bitmead@bigfoot.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Chris Bitmead @ 1999-04-16 13:10 UTC (permalink / raw)
  To: pgsql-sql


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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] UPDATE subselect?
@ 1999-04-16 14:58  José Soares <jose@sferacarta.com>
  parent: Chris Bitmead <chris.bitmead@bigfoot.com>
  0 siblings, 1 reply; 4+ messages in thread

From: José Soares @ 1999-04-16 14:58 UTC (permalink / raw)
  To: Chris Bitmead <chris.bitmead@bigfoot.com>; +Cc: pgsql-sql

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




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [SQL] UPDATE subselect?
@ 1999-04-16 15:27  Chris Bitmead <chris.bitmead@bigfoot.com>
  parent: José Soares <jose@sferacarta.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Chris Bitmead @ 1999-04-16 15:27 UTC (permalink / raw)
  To: pgsql-sql

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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* RE: [SQL] UPDATE subselect?
@ 1999-04-16 16:35  Jackson, DeJuan <djackson@cpsgroup.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Jackson, DeJuan @ 1999-04-16 16:35 UTC (permalink / raw)
  To: Chris Bitmead <chris.bitmead@bigfoot.com>; pgsql-sql

try:
 UPDATE category
 SET parent[0] = mfr.oid
 FROM mfr
 WHERE mfr.name='canon';

	-DEJ

> 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



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~1999-04-16 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-04-16 13:10 UPDATE subselect? Chris Bitmead <chris.bitmead@bigfoot.com>
1999-04-16 14:58 ` José Soares <jose@sferacarta.com>
1999-04-16 15:27   ` Chris Bitmead <chris.bitmead@bigfoot.com>
1999-04-16 16:35 RE: [SQL] UPDATE subselect? Jackson, DeJuan <djackson@cpsgroup.com>

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