Re: [SQL] CAST(ipaddress as text) -- HOW?

2001-07-20 Thread Bhuvan A
hi ipaddr::text I got it! few among the many ways are SELECT * FROM .. WHERE CAST(ipaddr::inet as text) ~ '200'; SELECT * FROM .. WHERE text(ipaddr::inet) ~ '200'; SELECT * FROM .. WHERE host(ipaddr::inet) ~ '200'; Regards, Bhuvaneswar. On Thu, 19 Jul 2001, omid omoomi wrote: > Sorry fr

Re: [SQL] nextval on insert by arbitrary sequence

2001-07-20 Thread David Stanaway
Have you looked at the serial type? This type creates an explicity sequence with a predictable name: tblname_rowname_seq and has a default value that selects the next val from that sequence. You can get the value of the most recently inserted row in your session with CurrVal('tblname_rowname_se

Re: [SQL] nextval on insert by arbitrary sequence

2001-07-20 Thread Dado Feigenblatt
Josh Berkus wrote: > Dado, > > Maybe we're looking at this the hard way. Have you thought of simply > putting in a DATETIME column and sorting by that? > > -Josh > Sorting? I might have expressed myself wrong. I'm not concerned about sorting. I'm concerned about giving rows in a single table an

[SQL] Re: PLpgSQL

2001-07-20 Thread Dado Feigenblatt
Jeff Eckermann wrote: >You will need to use "EXECUTE" to create the sequence. The docs on pl/pgsql >cover it: basically, "EXECUTE string" will cause that string to be executed >as a SQL statement. > Now that I found the documentation, I started to suspect that. Although nowhere it is mentioned t

Re: [SQL] Get the tables names?

2001-07-20 Thread Tom Lane
Dado Feigenblatt <[EMAIL PROTECTED]> writes: > The only thing is that this includes system tables. > So if you want to strip those you need to > SELECT relname , relowner FROM pg_class WHERE relkind = 'r' and > relowner != 26; > Is user postgres always 26? It certainly is not. Even if it w

[SQL] RE: PLpgSQL

2001-07-20 Thread Jeff Eckermann
You will need to use "EXECUTE" to create the sequence. The docs on pl/pgsql cover it: basically, "EXECUTE string" will cause that string to be executed as a SQL statement. > -Original Message- > From: Dado Feigenblatt [SMTP:[EMAIL PROTECTED]] > Sent: Friday, July 20, 2001 2:26 PM > To:

Re: [SQL] TODO List

2001-07-20 Thread Chris Ruprecht
Josh, I would love to do something like that. Unfortunately, on a scale from 1 to 10, my C knowledge is about minus 5. Maybe, if my current project makes any profit and I don't have to work for a boss any longer, I might find some time to learn how to program in C and then, I might add the one or

[SQL] RE: example of [outer] join

2001-07-20 Thread Jeff Eckermann
You could make your FROM clause something like: FROM members m INNER JOIN address a ON m.madd = a.aid INNER JOIN teams t ON m.team = t.tid LEFT JOIN emails e ON m.memail = e.eid I think that should work: if not, try putting everything between (but not including) FROM and LE

Re: [SQL] TODO List

2001-07-20 Thread Josh Berkus
Bruce, Chris, A lot of us would like a fuller PL/SQL implementation in PL/pgSQL. However, Jan is busy with other things and I don't see anyone stepping up to the plate to take on the project. -Josh __AGLIO DATABASE SOLUTIONS___

[SQL] Re: Get the tables names?

2001-07-20 Thread Joel Burton
On Fri, 20 Jul 2001, Dado Feigenblatt wrote: > Magnus Landahl wrote: > > >Hi everybody! > > > >Is it possible to get the names of all tables in the database with a sql > >query?? > > > >Best regards, > > > >Magnus > > > > > > > >---(end of broadcast)--

Re: [SQL] nextval on insert by arbitrary sequence

2001-07-20 Thread Josh Berkus
Dado, Maybe we're looking at this the hard way. Have you thought of simply putting in a DATETIME column and sorting by that? -Josh __AGLIO DATABASE SOLUTIONS___ Josh Berkus Complete information technology [EMAIL PROTECTE

Re: [SQL] Get the tables names?

2001-07-20 Thread Dado Feigenblatt
Magnus Landahl wrote: >Hi everybody! > >Is it possible to get the names of all tables in the database with a sql >query?? > >Best regards, > >Magnus > > > >---(end of broadcast)--- >TIP 3: if posting/reading through Usenet, please send an appropriat

[SQL] PLpgSQL

2001-07-20 Thread Dado Feigenblatt
3 questions: 1. Can I use CREATE SEQUENCE inside a function? 2. I can create this function but I can't get it to run: CREATE FUNCTION new_proj_pts_seq(int4) RETURNS text AS 'DECLARE proj_ID alias for $1; seq_name TEXT; BEGIN seq_name := ''proj_pts_'' || proj_ID;

Re: [SQL] Get the tables names?

2001-07-20 Thread Roberto Mello
On Thu, Jul 19, 2001 at 11:04:40AM +0200, Magnus Landahl wrote: > Hi everybody! > > Is it possible to get the names of all tables in the database with a sql > query?? SELECT tablename FROM pg_tables WHERE tablename NOT LIKE '%pg_%'; The "NOT LIKE" part is to avoid getting the PostgreSQL

[SQL] RE: Records exactly the same.

2001-07-20 Thread Jeff Eckermann
If you include "oid" in your GROUP BY clause, you will get each distinct record. That will get you by for right now, but Josh's point is correct. You need some kind of unique key in your table. But... if you want to see every distinct record: why are you using a GROUP BY? > -Original Message

Re: [SQL] nextval on insert by arbitrary sequence

2001-07-20 Thread Dado Feigenblatt
Henry House wrote: >On Thu, Jul 19, 2001 at 07:17:20PM -0700, Dado Feigenblatt wrote: > >>I'm not sure if I worded the subject right, but my problem is this: >> >>I have a few entries in one table. Each row is the parent of many >>entries in a second table. >>In the second table I have a lot of

Re: [SQL] nextval on insert by arbitrary sequence

2001-07-20 Thread Dado Feigenblatt
Josh Berkus wrote: >Dado, > >>I'm not sure if I worded the subject right, but my problem is this: >> >>I have a few entries in one table. Each row is the parent of many >>entries in a second table. >>In the second table I have a lot of entries referencing the entries >>on >>the first table. >>S

Re: [SQL] Query optimizing - paradox behave

2001-07-20 Thread Tom Lane
"David M. Richter" <[EMAIL PROTECTED]> writes: > The query with the 3 tables is faster than the query with 2 tables. How you figure that? > time psql -d compare -c "SELECT patient.*,study.* FROM > patient,study,relpatient_study000 r0 WHERE > (patient.chiliOID=r0.parentOID AND study.chiliOID=r0.

Re: [SQL] Cast '' (blank) to null date

2001-07-20 Thread Tom Lane
"Mattis Jiderhamn" <[EMAIL PROTECTED]> writes: > I'm trying to create a trigger so that, if I try to insert blank, that is > '', into a date field it will be converted to null so that I don't get > ERROR: Bad date external representation '' I don't think it's possible to do that with a trigger

[SQL] Re: Records exactly the same.

2001-07-20 Thread Nils Zonneveld
Fons Rave wrote: > > I'm writing a program in Delphi. > In SQL I'm a beginner. > > I have a file in which there are records with what people have done. In the file > are records with name, date, what they have done, time-length, etc. It is > possible that there are two records that are exactly

Re: [SQL] TODO List

2001-07-20 Thread Bruce Momjian
> Bruce, > > while you're at TO-DO list additions: > > I'd like to have a construct like: > > loop > if then > next [loop]; > end if; > [more statements] > end loop; > > I want to be able to skip to the next iteration of the loop, if a certain > condition is met but I do not

[SQL] Get the tables names?

2001-07-20 Thread Magnus Landahl
Hi everybody! Is it possible to get the names of all tables in the database with a sql query?? Best regards, Magnus ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL

Re: [SQL] multiple lookup per row

2001-07-20 Thread Tom Lane
"Josh Berkus" <[EMAIL PROTECTED]> writes: > ... LEFT OUTER JOIN ... Another way is correlated subselects in the output list: SELECT mid, name, address, (SELECT phone FROM phones WHERE members.mid = phones.mid and ptype = 'home') AS home_phone, (SELECT phone FROM phones WHERE me

[SQL] When PostgreSQL compliant JDBC 2.0?

2001-07-20 Thread Raymond Chui
Currently the JDBC drive in PostgreSQL 7.0, 7.1 are not support batch updates. I am wonder anybody know is there other PostgreSQL JDBC drive support batch updates? Thanks! --Raymond begin:vcard n:Chui;Raymond tel;fax:(301)713-0963 tel;work:(301)713-0624 Ext. 168 x-mozilla-html:TRUE url:http:

Re: [SQL] multiple lookup per row

2001-07-20 Thread Josh Berkus
Gary, > I had the same problem the first time I went from writing sequential > batch > mainframe apps to event-driven interactive windows apps. Different > mindset > completely. I grapple with the procedural <--> declarative switchover all the time. In a way, procedural is easier, since set t

[SQL] TODO List

2001-07-20 Thread Chris Ruprecht
Bruce, while you're at TO-DO list additions: I'd like to have a construct like: loop if then next [loop]; end if; [more statements] end loop; I want to be able to skip to the next iteration of the loop, if a certain condition is met but I do not want to exit the loop all tog

Re: [SQL] Records exactly the same.

2001-07-20 Thread Josh Berkus
Fons, > I have a file in which there are records with what people have done. > In the file > are records with name, date, what they have done, time-length, etc. > It is > possible that there are two records that are exactly the same > (somebody has done > the same, on the same day for one hour).

Re: [SQL] multiple lookup per row

2001-07-20 Thread Josh Berkus
Gary, First: Go out and buy "SQL for Smarties". Now. Read it. However, I'll give you this one as a freebie: > I've got a table 'phones' which has an indexed key 'pid' of type > int4, and a > phone number of type varchar(12). > > I've then got a table 'members' which as an index key 'mid'

Re: [SQL] pl/pgsql - code review + question

2001-07-20 Thread Bruce Momjian
> Josh - if I try and do OFFSET at the same time (presumably it's the same > change) do you fancy acting as a sanity test site? > Both LIMIT and OFFSET seem to have that restriction. I will add this to the TODO list. -- Bruce Momjian| http://candle.pha.pa.us [EMAI

[SQL] querying values defined in a check constraint

2001-07-20 Thread danno
I would like to query values defined in a check constraint on a field so I can populated a web form dynamically with options for users. Can this be done? I'm using Python with the PgSQL and libpq drivers to interface with the database. regards Danno ---(end of broadca

[SQL] Re: Get the tables names?

2001-07-20 Thread Nils Zonneveld
Magnus Landahl wrote: > > Hi everybody! > > Is it possible to get the names of all tables in the database with a sql > query?? > select tablename from pg_tables where tablename !~ '^pg_'; or more SQL92 like: select tablename from pg_tables where tablename not like 'pg_%'; Kind regards, N

[SQL] Records exactly the same.

2001-07-20 Thread Fons Rave
I'm writing a program in Delphi. In SQL I'm a beginner. I have a file in which there are records with what people have done. In the file are records with name, date, what they have done, time-length, etc. It is possible that there are two records that are exactly the same (somebody has done the s

[SQL] Cast '' (blank) to null date

2001-07-20 Thread Mattis Jiderhamn
Hi there everyone. I'm trying to create a trigger so that, if I try to insert blank, that is '', into a date field it will be converted to null so that I don't get ERROR: Bad date external representation '' I believe my ploblem is that I don't know the type of blank (''), and therefore do not

Re: [SQL] example of [outer] join

2001-07-20 Thread David Stanaway
On Friday, July 20, 2001, at 08:22 PM, Gary Stainburn wrote: My view so far is: CREATE view member_dets as select *, getphone(m.mphone) as phone, getphone(m.mfax) as fax, getphone(m.mmobile) as mobile, getunitno(m.mid) as munitno from members m, address a, teams t, emails e where m.madd = a.aid

[SQL] example of [outer] join

2001-07-20 Thread Gary Stainburn
Hi, me again. I'm having fun here, but here's another question for you. Could someone please give me an example of a join where one of the fields is missing - I think reading from the docs that this is an OUTER join, but I'm having a problem with the syntax. I'm trying to create a view that p

[SQL] multiple lookup per row

2001-07-20 Thread Gary Stainburn
Hi all, I've got a table 'phones' which has an indexed key 'pid' of type int4, and a phone number of type varchar(12). I've then got a table 'members' which as an index key 'mid' of type int4. Now, obviously, if each member only had one phone number, I could simply pull it in using a join.

[SQL] Query optimizing - paradox behave

2001-07-20 Thread David M. Richter
(Here again; my email adress was killed) Hallo ! I want to tune a database. There a many redundant datas in the database , because of all the relations were consider as n:m relations. But the most of them are 1:n Relations. So my approach was to cut the redundancies to get more performance. But

Re: [SQL] nextval on insert by arbitrary sequence

2001-07-20 Thread Henry House
On Thu, Jul 19, 2001 at 07:17:20PM -0700, Dado Feigenblatt wrote: > I'm not sure if I worded the subject right, but my problem is this: > > I have a few entries in one table. Each row is the parent of many > entries in a second table. > In the second table I have a lot of entries referencing the