pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeda celko-puzzle from long time ago
3+ messages / 3 participants
[nested] [flat]
* a celko-puzzle from long time ago
@ 2006-11-05 18:46 stig erikson <stigerikson_nospam_@yahoo.se>
2006-11-06 19:54 ` Re: a celko-puzzle from long time ago Richard Broersma Jr <rabroersma@yahoo.com>
0 siblings, 1 reply; 3+ messages in thread
From: stig erikson @ 2006-11-05 18:46 UTC (permalink / raw)
To: pgsql-sql
While reading celko's SQL puzzles (second edition) i followed a reference to http://www.dbmsmag.com/9801d06.html.
There is a puzzle that counts items in boxes.
When i try to run the proposed solution on PG 8.1.5, PG says: ERROR: column reference "qty" is ambiguous
apparently the variable declaration used in the solution is not proper for PostgreSQL. Is there a way to solve this puzzle in PostgreSQL?
/stig
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: a celko-puzzle from long time ago
2006-11-05 18:46 a celko-puzzle from long time ago stig erikson <stigerikson_nospam_@yahoo.se>
@ 2006-11-06 19:54 ` Richard Broersma Jr <rabroersma@yahoo.com>
2006-11-06 23:47 ` Re: a celko-puzzle from long time ago George Pavlov <gpavlov@mynewplace.com>
0 siblings, 1 reply; 3+ messages in thread
From: Richard Broersma Jr @ 2006-11-06 19:54 UTC (permalink / raw)
To: stig erikson <stigerikson_nospam_@yahoo.se>; pgsql-sql
> While reading celko's SQL puzzles (second edition) i followed a reference to
> http://www.dbmsmag.com/9801d06.html.
> There is a puzzle that counts items in boxes.
> When i try to run the proposed solution on PG 8.1.5, PG says: ERROR: column reference "qty" is
> ambiguous
>
>
> apparently the variable declaration used in the solution is not proper for PostgreSQL. Is there
> a way to solve this puzzle in PostgreSQL?
I believe that qty is a parameter variable that must first be set in psql. I've seen some thread
in various lists that describe how to set parameter variables before executing a query that uses
them.
Regards,
Richard Broersma Jr.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: a celko-puzzle from long time ago
2006-11-05 18:46 a celko-puzzle from long time ago stig erikson <stigerikson_nospam_@yahoo.se>
2006-11-06 19:54 ` Re: a celko-puzzle from long time ago Richard Broersma Jr <rabroersma@yahoo.com>
@ 2006-11-06 23:47 ` George Pavlov <gpavlov@mynewplace.com>
0 siblings, 0 replies; 3+ messages in thread
From: George Pavlov @ 2006-11-06 23:47 UTC (permalink / raw)
To: Richard Broersma Jr <rabroersma@yahoo.com>; stig erikson <stigerikson_nospam_@yahoo.se>; pgsql-sql
Should be entirely executable in postgres using psql variables (once you
get around the psql quoting weirdnesses). do this:
gp_test=# \set item '\''Apple'
gp_test=# \set qty 6
gp_test=# \echo :item
'Apple'
gp_test=# \echo :qty
6
and then run his query.
Now, i am not sure what DBMS lets Mr. Celko insert the string 'Orange'
into a CHAR(5) field, but he's a smartie, so I am sure there must be a
way ;-)
George
> -----Original Message-----
> From: pgsql-sql-owner@postgresql.org
> [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Richard
> Broersma Jr
> Sent: Monday, November 06, 2006 11:55 AM
> To: stig erikson; pgsql-sql@postgresql.org
> Subject: Re: [SQL] a celko-puzzle from long time ago
>
> > While reading celko's SQL puzzles (second edition) i
> followed a reference to
> > http://www.dbmsmag.com/9801d06.html.
> > There is a puzzle that counts items in boxes.
> > When i try to run the proposed solution on PG 8.1.5, PG
> says: ERROR: column reference "qty" is
> > ambiguous
> >
> >
> > apparently the variable declaration used in the solution is
> not proper for PostgreSQL. Is there
> > a way to solve this puzzle in PostgreSQL?
>
> I believe that qty is a parameter variable that must first be
> set in psql. I've seen some thread
> in various lists that describe how to set parameter variables
> before executing a query that uses
> them.
>
> Regards,
>
> Richard Broersma Jr.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-11-06 23:47 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-11-05 18:46 a celko-puzzle from long time ago stig erikson <stigerikson_nospam_@yahoo.se>
2006-11-06 19:54 ` Richard Broersma Jr <rabroersma@yahoo.com>
2006-11-06 23:47 ` George Pavlov <gpavlov@mynewplace.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