[SQL] Test for file exists?

2004-09-19 Thread Richard Sydney-Smith
I want to use pgsql to send the command: Copy sometable from 'sometable.csv'; But only if 'sometable.csv' exists; If 'sometable.csv' does not exist as an input table I want to continue the next command. My full procedure is as follows and any help is greatly appreciated. Thanks Richard CREAT

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Christopher Browne
Clinging to sanity, [EMAIL PROTECTED] (Worik) mumbled into her beard: > [snip] >> Just to enforce the test is better looking for the entire executable >> path: >> ps aux | grep /usr/bin/postmaster | grep -v grep >> > > Does not work for me! > > [EMAIL PROTECTED]:~$ ps aux | grep /usr/bin/po

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Arne Stoelck
How about a simple " telnet localhost 5432 " ? assuming postmaster is listening on that host and port On Fri, 17 Sep 2004, Sandeep Gaikwad wrote: Hello Sir, I want to know how to check whether postgres database is running or not ? when I give command like ./postmaster -i &, whether

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Tom Lane
Worik <[EMAIL PROTECTED]> writes: > Perhaps I have a bug in pg_ctrl? More likely you have the wrong value of PGDATA in your environment (where "wrong" means "not what that postmaster is using"). regards, tom lane ---(end of broadcast)--

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Worik
Perhaps I have a bug in pg_ctrl? This is what I get... [EMAIL PROTECTED]:~$ ps aux | grep postmaster | grep -v grep ;/usr/lib/postgresql/bin/pg_ctl status postgres 670 0.0 0.6 8544 1688 pts/1S12:33 0:00 /usr/lib/postgresql/bin/postmaster pg_ctl: postmaster or postgres is not runnin

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Greg Stark
Tom Lane <[EMAIL PROTECTED]> writes: > > The paragraph continues: > > "If the SELECT command included the clause WHERE phone NOT NULL, > > PostgreSQL could use the index to satisfy the ORDER BY clause. > > An index that covers optional (NOT NULL) columns will not be used to > > speed table join

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Worik
[snip] Just to enforce the test is better looking for the entire executable path: ps aux | grep /usr/bin/postmaster | grep -v grep Does not work for me! [EMAIL PROTECTED]:~$ ps aux | grep /usr/bin/postmaster | grep -v grep [EMAIL PROTECTED]:~$ ps aux | grep postmaster | grep -v grep postg

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Andrew Sullivan
On Sun, Sep 19, 2004 at 01:12:07PM -0400, Tom Lane wrote: > > Except that on Solaris, ps -ef _always_ shows "postmaster", even for > > the individual back ends. > > Right, but if you see a backend then you can figure the system is up. Oops, good point. (And in any case, on Solaris you also have

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Gaetano Mendola
Tom Lane wrote: Geoffrey <[EMAIL PROTECTED]> writes: Worik wrote: Assuming it is unix The command ps xau|grep post You might want to change that to: ps aux|grep postgres As your suggestion will pick up extraneous data if one is running postfix on the same box. Actually I'd recommend greppin

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Gaetano Mendola
Jeff Eckermann wrote: --- Christopher Browne <[EMAIL PROTECTED]> wrote: In an attempt to throw the authorities off his trail, [EMAIL PROTECTED] ("Sandeep Gaikwad") transmitted: Hello Sir, I want to know how to check whether postgres database is running or not ? when I give command

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello Tom, Tom Lane wrote: T E Schmitz <[EMAIL PROTECTED]> writes: Greg Stark wrote: Which book is it? PostgreSQL by Korry Douglas + Susan Douglas, ISBN 0-7357-1257-3; Feb 2003 Hmm, I've heard of that book but never seen it. The authors are not participants in the PG community --- AFAICT neither

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Tom Lane
T E Schmitz <[EMAIL PROTECTED]> writes: > Greg Stark wrote: >> Which book is it? > PostgreSQL by Korry Douglas + Susan Douglas, ISBN 0-7357-1257-3; Feb 2003 Hmm, I've heard of that book but never seen it. The authors are not participants in the PG community --- AFAICT neither of them have ever p

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello Greg, Greg Stark wrote: T E Schmitz <[EMAIL PROTECTED]> writes: Quote: "PostgreSQL will not index NULL values. Because an index will never include NULL values, it cannot be used to satisfy the ORDER BY clause of a query that returns all rows in a table." You should just cross out that whole

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Tom Lane
T E Schmitz <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Whatever you were reading had it pretty badly garbled :-( > I just dug out the PostgreSQL book again because I thought I might've > garbled it: > Quote: "PostgreSQL will not index NULL values. Because an index will > never include NUL

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Greg Stark
T E Schmitz <[EMAIL PROTECTED]> writes: > I just dug out the PostgreSQL book again because I thought I might've garbled > it: > > Quote: "PostgreSQL will not index NULL values. Because an index will never > include NULL values, it cannot be used to satisfy the ORDER BY clause of a > query that r

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello Tom, Tom Lane wrote: T E Schmitz <[EMAIL PROTECTED]> writes: I read somewhere that an Index is not going to improve the performance of an ORDER BY if the sort column contains NULLs because NULLs aren't indexed? Whatever you were reading had it pretty badly garbled :-( I just dug out the Pos

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Tom Lane
Andrew Sullivan <[EMAIL PROTECTED]> writes: > On Sun, Sep 19, 2004 at 12:25:00PM -0400, Tom Lane wrote: >> ps aux | grep postmaster | grep -v grep >> (or use "ps -ef" if using a SysV-ish ps). > Except that on Solaris, ps -ef _always_ shows "postmaster", even for > the individual back ends. Right,

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Tom Lane
T E Schmitz <[EMAIL PROTECTED]> writes: > You must've been reading my mind. I was just wondering what to do about > indexing on that particular table. I read somewhere that an Index is not > going to improve the performance of an ORDER BY if the sort column > contains NULLs because NULLs aren't

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Andrew Sullivan
On Sun, Sep 19, 2004 at 12:25:00PM -0400, Tom Lane wrote: > ps aux | grep postmaster | grep -v grep > (or use "ps -ef" if using a SysV-ish ps). Except that on Solaris, ps -ef _always_ shows "postmaster", even for the individual back ends. A -- Andrew Sullivan | [EMAIL PROTECTED] In the f

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello Jean-Luc, You must've been reading my mind. I was just wondering what to do about indexing on that particular table. I read somewhere that an Index is not going to improve the performance of an ORDER BY if the sort column contains NULLs because NULLs aren't indexed? For the sake of the ex

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Tom Lane
Geoffrey <[EMAIL PROTECTED]> writes: > Worik wrote: >> Assuming it is unix The command >> ps xau|grep post > You might want to change that to: > ps aux|grep postgres > As your suggestion will pick up extraneous data if one is running > postfix on the same box. Actually I'd recommend greppin

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread Jean-Luc Lachance
select ... order by "FROM" is not null, "FROM"; If you have large amount of rows (with or without nulls) it is faster if use a partial index. create index ... on ...("FROM"); create index ... on ...("FROM") where "FROM" is null; JLL [EMAIL PROTECTED] wrote: Use the coalesce() function. (coalesce

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Jeff Eckermann
--- Christopher Browne <[EMAIL PROTECTED]> wrote: > In an attempt to throw the authorities off his > trail, [EMAIL PROTECTED] ("Sandeep Gaikwad") > transmitted: > > Hello Sir, > > I want to know how to check > whether postgres database > > is running or not ? when I give command

Re: [SQL] ORDER BY and NULLs

2004-09-19 Thread terry
Use the coalesce() function. (coalesce returns the first non-null value in its list) Specifically ORDER BY coalesce("TO", 0), "FROM" If you have records in "TO" column whose values is LESS then 0, then you need to replace 0 with something that sorts BEFORE the first most value that your TO res

[SQL] ORDER BY and NULLs

2004-09-19 Thread T E Schmitz
Hello, I am using PostgreSQL 7.4.2 and as I understand NULL values always sort last. However, I have a table from which select using two numerical sort keys "FROM" and "TO". "TO" might be NULL and I would like to display those rows first (without sorting the column in descending order). Is the

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Geoffrey
Worik wrote: Assuming it is unix The command ps xau|grep post You might want to change that to: ps aux|grep postgres As your suggestion will pick up extraneous data if one is running postfix on the same box. -- Until later, Geoffrey Registered Linux User #108567