Re: [SQL] table as field type??

2000-10-03 Thread bmccoy

On Wed, 4 Oct 2000, Tod McQuillin wrote:

> > I noticed that it's possible to have a table as a field type.
> > For example:
> > create table foo (val1  integer);
> > create table bar (val2 foo);
> > 
> > val2 in table bar ends up as an int4, designed for storing an oid from
> > table foo.
> > Is there a way to perform a query on bar that will return values from table
> > foo (i.e., val1)?
> 
> I didn't know you could use a table name as a type either.  I thought
> something like this might join the tables:
> 
> select val1 from foo, bar where bar.val2::oid = foo.oid ;
> 
> But I get "ERROR:  Cannot cast type 'foo' to 'oid'"
> 
> You can't seem to cast an oid into a foo either.

Don't you need to use CREATE TYPE to use a new type in this fashion?

Brett W. McCoy
  http://www.chapelperilous.net
---
You are going to have a new love affair.




Re: [SQL] COUNT

2000-10-19 Thread bmccoy

On Fri, 20 Oct 2000, Craig May wrote:

> How do I get a row count, like "Select [COUNT] from Table" ??

SELECT COUNT(*) FROM  

Brett W. McCoy
  http://www.chapelperilous.net
---
Man's reach must exceed his grasp, for why else the heavens?




Re: [SQL]

2000-10-23 Thread bmccoy

On Mon, 23 Oct 2000 [EMAIL PROTECTED] wrote:

>  I have following problem with PostgreSQL 6.5.3, I haven't possiblity
> to check it on 7.0 and I want to know is it possible to run such query:
> 
> SELECTk.pic, id_g, id_k, count(*)
       
What table do these come from?

> FROM kart k, pictues p
   
This looks like a typo

> WHERE k.pic = p.pic
> GROUP BY k.pic
> 
> PICTURES(pic,id_g,id_k)
> KART  (pic,email,mess,date)
> 
> I've got answer from Postgres
> "Illegal attributes or non-group column"
> 
> Is it error in query or in parser ?

Probably the query.

Brett W. McCoy
  http://www.chapelperilous.net
---
The goys have proven the following theorem...
-- Physicist John von Neumann, at the start of a classroom
   lecture.




Re: [SQL] Create tables in one query

2000-11-23 Thread bmccoy

On Thu, 23 Nov 2000, Tomasz Gralewski wrote:

> I'd like to create a few tables in one SQL query, is that possible.
> What tools I have to use, Perl, Tcl, or maybe is there block command
> separator that I can write:
> CREATE TABLE abd
>  (
> atype,
> btype,
> ctype
>  ) and I whant to add the next table here, how can I separate, by this (";"
> that;s the end of table abd).

Not sure what you are trying to do here.  You can put statements like

CREATE TABLE (
...
);

CREATE TABLE (
...
);

CREATE INDEX ... ;
GRANT SELECT... ;

in a single file and load the file into psql via \i.  That's I build all
of my databases.

Brett W. McCoy
     http://www.chapelperilous.net/~bmccoy/
---
A bachelor is a selfish, undeserving guy who has cheated some woman out
of a divorce.
-- Don Quinn




Re: [SQL] psql question

2000-11-23 Thread bmccoy

On Sun, 19 Nov 2000, Joe Conway wrote:

> On machines where I've installed PostgreSQL 7.0.2 from RPM, psql allows use
> of the up arrow key for history and the escape/tab key for command
> completion, but on my remote web host (webpipe.net) those keys don't work.
> What do I need to do to get these features working on my remote web host?
> I've seen reference to .psqlrc in the psql man file, but not much else (no
> syntax, etc).

*sigh* another candidate for the FAQ, I think.

The history keys rely on the GNU readline library.  If that library is not
available on your system, the history keys don't work.  If you compile
postgres from scratch, make sure you have also installed the
readline-devel rpm as well, so you get the header files, else the
configure phase of the compile will not properly detect and use the
library.

Brett W. McCoy
     http://www.chapelperilous.net/~bmccoy/
---
Criticism comes easier than craftsmanship.
-- Zeuxis