Re: [GENERAL] Automate Postgres Backup In windows - resolved

2005-06-03 Thread Shaun Clements
Title: RE: [GENERAL] Automate Postgres Backup In windows - resolved





Thanks Richard.


For anyone interested
The link Richard was referring to can be found below.


http://www.postgresql.org/docs/8.0/interactive/libpq-pgpass.Html




Kind Regards,
Shaun Clements


-Original Message-
From: Richard Huxton [mailto:dev@archonet.com] 
Sent: 03 June 2005 09:20 AM
To: Shaun Clements
Cc: List
Subject: Re: [GENERAL] Automate Postgres Backup In windows


Shaun Clements wrote:
 Problem there is the pg_dump requires a password.


Ah - you'll be wanting the .pgpass password file - there's a section in the manuals under Client Interfaces/libpq


Not the place you'd first look, I'll admit.


Oh - might be worth googling for .pgpass and windows in case there are any differences from *nix.
--
 Richard Huxton
 Archonet Ltd





[GENERAL] Automate Postgres Backup In windows

2005-06-02 Thread Shaun Clements



Apologies if this post is a repeat.

I am trying to automate a postgres database data and schema 
dump through windows.
Does anyone have any suggestions on best way to do 
so.
Thanks



Kind Regards,Shaun 
Clements


[GENERAL] Automate Postgres Backup In windows

2005-06-02 Thread Shaun Clements



I am trying to automate a postgres database data and schema 
dump through windows.
Does anyone have any suggestions on best way to do 
so.
Thanks



Kind Regards,Shaun 
Clements


[GENERAL] Postgres PHP error

2005-05-23 Thread Shaun Clements
Title: [GENERAL] Postgres PHP error





Hi All


Im receiving the following error, on a php page, conneting to postgres 7.4, installed on Mandrake 10.0
snip
Error Description: pg_connect(): Unable to connect to PostgreSQL server: FATAL: sorry, too many clients already . 
/snip
Can anyone tell me what this means? 
Is there a performance setting I need to set under the postgresql conf file.
I have checked, and its set to 100 users.
This error strangely has only happened once. Last week Monday.


Kind Regards,
Shaun Clements





Re: [GENERAL] Postgres PHP error

2005-05-23 Thread Shaun Clements
Title: RE: [GENERAL] Postgres PHP error





Thanks. Great idea.
I assume there is more than one connection per user.
As judging by the scope of the system, more than one connection is made.
Would you suggest I increase the size of the connections.
What kind of performance decrease would I see, even if 100 isnt always used.


Kind Regards,
Shaun Clements


-Original Message-
From: Richard Huxton [mailto:dev@archonet.com] 
Sent: 23 May 2005 03:29 PM
To: Shaun Clements
Cc: 'pgsql-general@postgresql.org'
Subject: Re: [GENERAL] Postgres PHP error


Shaun Clements wrote:
 Hi All
 
 Im receiving the following error, on a php page, conneting to postgres 
 7.4, installed on Mandrake 10.0 snip Error Description: 
 pg_connect(): Unable to connect to PostgreSQL server:
 FATAL: sorry, too many clients already . 
 /snip
 Can anyone tell me what this means? 


It means exactly what it says - too many clients.


 Is there a performance setting I need to set under the postgresql conf file.
 I have checked, and its set to 100 users.
 This error strangely has only happened once. Last week Monday.


Well - you probably had 100 connections then (actually, 100 - your superuser reserved connections, default=2).


There are two possibilities:
 1. You had 100 users last Monday
 2. You are using more than one connection per user.


The second is the most likely. Turn connection logging on and try with a couple of users to see how many connections you generate as you use the site.

--
 Richard Huxton
 Archonet Ltd





[GENERAL] Postgres 8.02 connectivity

2005-05-05 Thread Shaun Clements
Title:  [GENERAL] Postgres 8.02 connectivity





Hi All


I have been quite content with postgres, until a recent installation on a windows box, in an attempt to setup a new server.

There is an option when you install Postgres, to allow other computers to connect to the DB server. I selected that option, so I can connect over the network to the database, but I cant connect. It cant find the database. Giving that usual, listening on port 5432, failed to find database...etc

Any suggestions, on what needs to be configured further. 


Kind Regards,
Shaun Clements





Re: [GENERAL] Postgres 8.02 connectivity

2005-05-05 Thread Shaun Clements
Title: RE: [GENERAL] Postgres 8.02 connectivity





Hi Richard


I worked out what the problem was.
I needed an IP Mask(subnet) after the IP.
255.255.255.0 solved that 
Thanks again for you help!!


Kind Regards,
Shaun Clements


-Original Message-
From: Richard Huxton [mailto:dev@archonet.com] 
Sent: 05 May 2005 12:15 PM
To: Shaun Clements; List
Subject: Re: [GENERAL] Postgres 8.02 connectivity


Shaun Clements wrote:
 Thanks.
 Firewall was the problem.im going to kill the technician who installed 
 windows :) Im now coming up with a new error.
 Missing or erroneous pg_hba.conf file.
 
 Ive added the following line.
 Host all all myip trust


Try a /32 on the end of the client's ip:


host all all 192.168.1.20/32 trust


--
 Richard Huxton
 Archonet Ltd





: [GENERAL] Postgres IX

2005-04-01 Thread Shaun Clements
Title: : [GENERAL] Postgres IX





Can someone please explain to me , the use of 
snip
CONSTRAINT ix_tablename
/snip


Kind Regards,
Shaun Clements





FW: [GENERAL] Help with order by into a RECORD

2005-04-01 Thread Shaun Clements
Title: FW: [GENERAL] Help with order by into a RECORD





Hi


I have a questions regarding my order by problem.
If you index a table, can you query the table using ORDER BY. ?


Kind Regards,
Shaun Clements





Re: : [GENERAL] Postgres order by into a RECORD, not ordering

2005-04-01 Thread Shaun Clements
Title: RE: : [GENERAL] Postgres order by into a RECORD, not ordering





Hi Again.


I hope you can explain this. 
I have a stored procedure which does a query of a table using order by, into a RECORD.
The statement I mentioned earlier, is a FOR IN.
the data stored into the RECORD, is not ordered by the columns specified, because when I loop through the record, the columns returned in the row are different, to when I manually do a Select query using order by.

I assumed this may have something to do with the index.


Is there any reason why this is so ?


Kind Regards,
Shaun Clements





Re: : [GENERAL] Postgres order by into a RECORD, not ordering

2005-04-01 Thread Shaun Clements
Title: RE: : [GENERAL] Postgres order by into a RECORD, not ordering





RESOLVED.


It must be a bug in 7.3
I resolved the problem, by changing the FOR IN statement to FOR IN EXECUTE.
By changing the Statement into a string, it accommodated for the ORDER BY.


Thanks for all your responses.


Kind Regards,
Shaun Clements


-Original Message-
From: Shaun Clements 
Sent: 01 April 2005 12:22 PM
To: 'Richard Huxton'
Cc: PostgreSQL General
Subject: RE: : [GENERAL] Postgres order by into a RECORD, not ordering



Hi Again.


I hope you can explain this. 
I have a stored procedure which does a query of a table using order by, into a RECORD.
The statement I mentioned earlier, is a FOR IN.
the data stored into the RECORD, is not ordered by the columns specified, because when I loop through the record, the columns returned in the row are different, to when I manually do a Select query using order by.

I assumed this may have something to do with the index.


Is there any reason why this is so ?


Kind Regards,
Shaun Clements





Re: : [GENERAL] Postgres order by into a RECORD, not ordering

2005-04-01 Thread Shaun Clements
Title: RE: : [GENERAL] Postgres order by into a RECORD, not ordering



Ignore last email.
must 
have been delayed.



Kind Regards,Shaun 
Clements

  -Original Message-From: Shaun Clements 
  [mailto:[EMAIL PROTECTED]Sent: 01 April 2005 12:22 
  PMTo: 'Richard Huxton'Cc: PostgreSQL 
  GeneralSubject: Re: : [GENERAL] Postgres order by into a RECORD, 
  not ordering
  Hi Again. 
  I hope you can explain this. I have a 
  stored procedure which does a query of a table using order by, into a 
  RECORD. The statement I mentioned earlier, is a 
  FOR IN. the data stored into the RECORD, is not 
  ordered by the columns specified, because when I loop through the record, the 
  columns returned in the row are different, to when I manually do a Select 
  query using order by.
  I assumed this may have something to do with the index. 
  
  Is there any reason why this is so ? 
  Kind Regards, Shaun Clements 
  


Re: [GENERAL] Catch of ERROR in PLPGSQL

2005-03-31 Thread Shaun Clements
Title: RE: [GENERAL] Catch of ERROR  in PLPGSQL





Begin
Exception
of a basic Function.
is provided for.
What I was thinking then, it to create separate functions for the INSERT and UPDATE
which take parameters, for the table, column, and values.
Which I can then make use of the EXCEPTION.


Kind Regards,
Shaun Clements


-Original Message-
From: Richard Huxton [mailto:dev@archonet.com]
Sent: 31 March 2005 09:10 AM
To: Shaun Clements; pgsql-general@postgresql.org
Subject: Re: [GENERAL] Catch of ERROR in PLPGSQL



Shaun Clements wrote:
 Thanks for your response.
 I unfortunately have to use 7.3.
 Will try the Exception wrap. It does appear in the manual.


No it doesn't. Version 7.3 doesn't have any programmatic exception 
handling. Perhaps you are reading the wrong version of the manuals?


-- 
 Richard Huxton
 Archonet Ltd





[GENERAL] Postgres PL SQL bug?

2005-03-31 Thread Shaun Clements



Hi 
All

Im hoping someone 
has an answer for this mystery.
I have a stored 
procedure, which queries a table, of about 400-000 records, into a RECORD, 
ordered by three columns.
I am using a 
conditional INSERT, UPDATE command, basedon evaluating the last 
record.column, against the new record.column, to ascertain whether it requires, 
an UPDATE or INSERT.

The problem is the 
records are not ORDERED properly into the RECORD, and when looping through it,it 
is trying to INSERT somewhere down the line, and is returning an error, saying 
it cant INSERT a duplicate key into unique.. etc.

Any suggestions, 
the postgres version is 7.3

Thanks in 
advance.



Kind Regards,Shaun 
Clements


Re: [GENERAL] Postgres mystery

2005-03-30 Thread Shaun Clements



Hi 
Guys

Thanks again for 
your responses.
You were all RIGHT 
.. again!
a null column was 
returned, which bombed out the stored procedure.
This was resolved 
using ur advice.

Kind Regards,Shaun 
Clements
B.Com 
(Hons) IST
Software Developer 
Relyant Group ITBusiness ConneXion (Pty) 
LtdAs service provider for: 
Relyant

  
  
 
Office:
 +27 (0)31 
  3674722
  
 
Mobile:
 +27 (0)84 
  6166777
  
 Fax:
 +27 (0)31 
  3055289
  
 Email:
 [EMAIL PROTECTED]
  
 Web Site: 

 www.bcx.co.za" Obstacles 
are what we see when we take our eyes off the goal " 



[GENERAL] Postgres plpgsql

2005-03-30 Thread Shaun Clements
Title:  [GENERAL] Postgres plpgsql





Im finding a problem with updating in PGPLSQL
Can anyone find anything wrong with this code below. It appears Postgres isnt picking up a change in the dynamic first column. So the same column is being updated.

.
snip
EXECUTE ''UPDATE TABLENAME SET ''||quote_ident(variable1)||''=''||quote_literal(Variable2)||'' where columnname1 =''||quote_literal(variable3)||'' and columnname2 = ''||quote_literal(variable4)||'' and month = 07 and year = 2004'';

/snip


There is clearly a need for a debugging facility.



Kind Regards,
Shaun Clements





Re: [GENERAL] Postgres plpgsql

2005-03-30 Thread Shaun Clements
Title: RE: [GENERAL] Postgres plpgsql





Hi Richard


Thanks for your help.
Im stuck on this statement.
Am I missing the '' ???
snip
PERFORM distinct COLUMN1 FROM TABLE where COLUMN1 = || quote_literal(VARIABLE1)'' ||'' AND COLUMN2 = ||quote_literal(VARIABLE2)||;

IF NOT FOUND THEN
/snip


The statement is failing to perform the check in the function.


Kind Regards,
Shaun Clements
-Original Message-
From: Richard Huxton [mailto:dev@archonet.com]
Sent: 30 March 2005 03:56 PM
To: Shaun Clements
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Postgres plpgsql



Shaun Clements wrote:
 Im finding a problem with updating in PGPLSQL
 Can anyone find anything wrong with this code below. It appears Postgres
 isnt picking up a change in the dynamic first column. So the same column is
 being updated.
 .
 snip
 EXECUTE ''UPDATE TABLENAME SET
 ''||quote_ident(variable1)||''=''||quote_literal(Variable2)||'' where
 columnname1 =''||quote_literal(variable3)||'' and columnname2 =
 ''||quote_literal(variable4)||'' and month = 07 and year =
 2004'';
 /snip
 
 There is clearly a need for a debugging facility.


You're not wrong there. However, you can use RAISE NOTICE - something like
 RAISE NOTICE ''my vars = % / %'',variable1,variable2;


-- 
 Richard Huxton
 Archonet Ltd





[GENERAL] Catch of ERROR in PLPGSQL

2005-03-30 Thread Shaun Clements



Hi 
All

Does 
anyone know if Postgres supports Catching of errors, from an EXECUTE, for 
Procedural Language Postgres.

Thanks in advance



Kind Regards,Shaun 
Clements



[GENERAL] Postgres mystery

2005-03-29 Thread Shaun Clements
Title: [GENERAL] Postgres mystery





Can anyone tell me what the problem is here:
I am inserting into a table via a stored procedure, to a few columns within the table and postgres is throwing a 
CANNOT EXECUTE NULL QUERY.


code snip
EXECUTE ''INSERT INTO table (column1, column2, column3, ''||quote_ident(column4)||'') values (''||quote_literal(RECORDNAME.column1)||'',''||quote_literal(RECORDNAME.column2)||'',stringvalue,''||quote_literal(RECORDNAME.column2)||'')'';

/code snip


Is this a bug, as I am ensuring that the NOT NULL columns are supplied, as well as one other.


Kind Regards,
Shaun Clements





[GENERAL] PLPGSQL

2005-03-23 Thread Shaun Clements
Title:  [GENERAL] PLPGSQL





Hi All


Im trying to assign the value of a dynamic variable, to a variable.
How is this done in PostgresQL. Is this allowed in Postgres Procedural Language


Here is my attempt.


variable1:= quote_ident('variable_'||quote_literal(year));


Where the variable is called
variable_2004
where name, represents the year


RESULT WANTED: variable1 gets assigned the value of variable_2004.



Any help is appreciated.Thanks


Kind Regards,
Shaun Clements





++ [GENERAL] PLPGSQL

2005-03-23 Thread Shaun Clements
Title: ++ [GENERAL] PLPGSQL





Adding to that.


Can you assign the value of a dynamic record value.
For example


If I have written dataset returned, into a record.
I now want to call on a particular column value from the first row.
The column name is dynamic.
Can I use something like this


sales_month1_x := RECORDNAME.quote_ident('month1_'||quote_literal(yr2));


Where the value of 
RECORDNAME.month1_2004
is assigned to sales_month1_x


Is this possible.
It doesnt look right, in that I have referenced RECORDNAME.quote_ident
That should bomb out..
how would I reference the dynamic column of the record.


Thanks in advance.


Kind Regards,
Shaun Clements





[GENERAL] PLPGSQL

2005-03-23 Thread Shaun Clements
Title: [GENERAL] PLPGSQL





Is there no way in pgplsql 
to call on a dynamic column.
I need to be able to dynamically determine the latest month column within a dataset, and to get that columns data.
I am unfamiliar with other languages within Postgres 


Kind Regards,
Shaun Clements





FW: [GENERAL] PLPGSQL

2005-03-23 Thread Shaun Clements
Title: FW: [GENERAL] PLPGSQL





Hi Sean


Ive chosen the table structure on purpose.
Im transforming data from one table to another. The problem is still there. 
I receive the column name from a query in one table, and then need to update the table with that column name in another.

This needs to be done dynamically as part of a loop. So the column name needs to be called as a variable.
Im stuck.


Any suggestions


Kind Regards,
Shaun Clements



-Original Message-
From: Sean Davis [mailto:[EMAIL PROTECTED]]
Sent: 23 March 2005 03:33 PM
To: Shaun Clements
Cc: 'pgsql-general@postgresql.org'
Subject: Re: [GENERAL] PLPGSQL




On Mar 23, 2005, at 7:56 AM, Shaun Clements wrote:


 Is there no way in pgplsql
 to call on a dynamic column.
 I need to be able to dynamically determine the latest month column 
 within a dataset, and to get that columns data.
 I am unfamiliar with other languages within Postgres

 Kind Regards,
 Shaun Clements



You can get all the column names for a table called 'testtable' using:


select a.attname
 from
  pg_attribute a,
  pg_class c
 where
  a.attrelid=c.oid and
  a.attnum0 and
  c.relname='testtable';


You can then decide what column to use based on whatever logic you 
like. You will then need to construct the SQL statement using || 
(concatenate) and execute it using EXECUTE.


http://www.postgresql.org/docs/current/static/plpgsql- 
statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN


Does this help? Another simpler way to do this would be a different 
table structure where you put the month in a column by itself rather 
than a different column for each month.


Sean





[GENERAL] PHP SQL

2005-03-22 Thread Shaun Clements
Title:  [GENERAL] PHP SQL





Hi All


I am designing a data loader script that can transform data in one table schema into a new table schema in Postgres for reporting purposes.

I wanted to ask, on a performance issue.
Which is more efficient, in reading in a row of data, and assigning individual column values to variables, and then inserting a new row into the new table.

pg_fetch_row
pg_fetch_assoc
pg_fetch_object
pg_fetch_result
pg_fetch_array


Are there performance differences, which are noticeable?


Kind Regards,
Shaun Clements





Re: [GENERAL] PHP SQL

2005-03-22 Thread Shaun Clements
Title: RE: [GENERAL] PHP SQL





Excellent idea. Yes, I would prefer to write in plpgsql.
My next concern then, is, does Postgres, perform some kind of Load Balancing.
I dont want the stored procedure once run, to DOS other users, who are running reports.. or perform queries using some application.

The reason for asking, is I plan on taking, 350 000 rows, and transforming them, into hopefully about 50% smaller number (in a new schema)

It is critical, that I dont DOS the database server, because it is being used in a PRODUCTION enviroment


Kind Regards,
Shaun Clements



-Original Message-
From: Michael Fuhr [mailto:[EMAIL PROTECTED]]
Sent: 22 March 2005 02:01 PM
To: Shaun Clements
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] PHP SQL



On Tue, Mar 22, 2005 at 01:25:30PM +0200, Shaun Clements wrote:


 Which is more efficient, in reading in a row of data, and assigning
 individual column values to variables, and then inserting a new row into the
 new table.
 
 pg_fetch_row
 pg_fetch_assoc
 pg_fetch_object
 pg_fetch_result
 pg_fetch_array
 
 Are there performance differences, which are noticeable?


The best way to determine this would be to benchmark each method
in your own environment and observe whether there are significant
differences.


Have you considered using a server-side function to avoid passing
the data back and forth between the client and the server? Are you
familiar with constructs like CREATE TABLE AS and INSERT...SELECT?


-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/





Re: [GENERAL] PHP SQL

2005-03-22 Thread Shaun Clements
Title: RE: [GENERAL] PHP SQL





Thanks for your response.
It is as you mentioned, within the same database.
I will get working on a stored procedure this morning.


Thanks for your response.


Kind Regards,
Shaun Clements



-Original Message-
From: Jeff Davis [mailto:[EMAIL PROTECTED]]
Sent: 22 March 2005 10:48 PM
To: Shaun Clements
Cc: PgSQL General List
Subject: Re: [GENERAL] PHP SQL




 pg_fetch_row 
 pg_fetch_assoc 
 pg_fetch_object 
 pg_fetch_result 
 pg_fetch_array
 
 Are there performance differences, which are noticeable?



I doubt you'll see much real difference. Your real bottleneck will be
I/O.


You might be able to save something by using COPY out and then back in.
If it's a lot of data I would definately try that, because it's got a
lot more chance of helping you. Or you could use a server side function
rather than doing the work in the client. contrib/dblink may be able to
help you a lot.


However, your question made it sound like the tables were in the same DB
already and just in different schemas? If that's the case, you can just
select one table into another and avoid all that unecessary overhead.


Regards,
 Jeff Davis





Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Shaun Clements
Title: RE: [GENERAL] pl sql to check if table of table_name exists





Hi


Hate to ask, but it isnt obvious to me from the documentation.
How do I perform a query in pgplsql, to check it a table exists of a particular name.


Thanks in advance


Kind Regards,
Shaun Clements





Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Shaun Clements
Title: RE: [GENERAL] pl sql to check if table of table_name exists





Much appreciated.
Thanks


Kind Regards,
Shaun Clements


-Original Message-
From: Adam Tomjack [mailto:[EMAIL PROTECTED]]
Sent: 10 March 2005 11:04 AM
To: Shaun Clements
Cc: postgresql
Subject: Re: [GENERAL] pl sql to check if table of table_name exists



Shaun Clements wrote:
 Hi
 
 Hate to ask, but it isnt obvious to me from the documentation.
 How do I perform a query in pgplsql, to check it a table exists of a
 particular name.
 
 Thanks in advance
 
 Kind Regards,
 Shaun Clements
 


-- A list of tables:
SELECT schemaname, tablename FROM pg_tables;


-- Returns true if a table exists:
SELECT count(*)0 FROM pg_tables
 WHERE schemaname='...' AND tablename='...'


-- Here's an untested function:
CREATE OR REPLACE FUNCTION table_exists(TEXT, TEXT)
 RETURNS BOOLEAN AS '
DECLARE
 r RECORD;
BEGIN
 SELECT INTO r count(*)0 AS exists
 FROM pg_tables WHERE schemaname='$1' AND tablename='$2'
 RETURN r.exists;
END;
' LANGUAGE plpgsql STABLE;



Check out http://www.postgresql.org/docs/8.0/static/catalogs.html for 
more info.



Adam





Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Shaun Clements
Title: RE: [GENERAL] pl sql to check if table of table_name exists



Hi 
Sim

Thanks for your response. I had it working from a 
previous post by Adam Tomjack.
snip

-- A list of tables:
SELECT schemaname, tablename FROM pg_tables;
-- Returns true if a table exists:
SELECT count(*)0 FROM pg_tables
WHERE schemaname='...' AND tablename='...'
/snip


Your 
response does not work for me. Perhaps you can explain the posted 
command

snip
* from pg_class where 
relkind='r' and relname=your_tablename
/snip



Kind 
Regards,Shaun Clements


-Original Message-From: Sim Zacks 
[mailto:[EMAIL PROTECTED]Sent: 10 March 2005 01:24 PMTo: 
pgsql-general@postgresql.orgSubject: Re: [GENERAL] pl sql to check if 
table of table_name exists

  i mean 
  select* from pg_class where relkind='r' and 
  relname=your_tablename 
  
"Sim Zacks" [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]...
selectyour_tablename from pg_class where 
relkind='r'
    
      "Shaun Clements" [EMAIL PROTECTED] wrote in 
  message news:[EMAIL PROTECTED]...
  Hi 
  Hate to ask, but it isnt obvious to me from the 
  documentation. How do I perform a query in 
  pgplsql, to check it a table exists of a particular name. 
  Thanks in advance 
  Kind Regards, Shaun 
  Clements 


Re: [GENERAL] pl sql to check if table of table_name exists

2005-03-10 Thread Shaun Clements
Title: RE: [GENERAL] pl sql to check if table of table_name exists



Hi 
Sim

Thanks for your input.



Kind Regards,Shaun 
Clements
-Original 
Message-From: Sim Zacks 
[mailto:[EMAIL PROTECTED]Sent: 10 March 2005 02:47 PMTo: 
pgsql-general@postgresql.orgSubject: Re: [GENERAL] pl sql to check if 
table of table_name exists

  I'm gladto hear yougot 
  itworking. 
  In explanation to my response:
  the pg_class internal table lists all the 
  relationships in the database.
  relkind='r' means that the relation you are 
  looking for is a table (relation), I believe that will also find 
  views.
  relname is the name of the object if your table 
  is called parts
  select * from pg_class where relkind='r' and 
  relname='parts' will give you the pg_class record for the table if it exists 
  and nothing if it doesn't.
  you could also do a select count(*) or select 1 
  In any case if there is a resultset the table exists and if there is no 
  resultset the the table does not.
  Using the pg_tables view is a better idea in any 
  case, as it is cleaner.
  
  Sim
  
"Shaun Clements" [EMAIL PROTECTED] wrote in 
message news:[EMAIL PROTECTED]...
Hi Sim

Thanks for your response. I had it working from a 
previous post by Adam Tomjack.
snip

-- A list of tables:
SELECT schemaname, tablename FROM pg_tables;
-- Returns true if a table exists:
SELECT count(*)0 FROM pg_tables
WHERE schemaname='...' AND tablename='...'
/snip


Your response does not work for me. Perhaps you can 
explain the posted command

snip
* from pg_class where 
relkind='r' and relname=your_tablename
/snip



Kind 
    Regards,Shaun Clements


-Original Message-From: Sim Zacks 
[mailto:[EMAIL PROTECTED]Sent: 10 March 2005 01:24 
PMTo: pgsql-general@postgresql.orgSubject: Re: 
[GENERAL] pl sql to check if table of table_name exists

  i mean 
  select* from pg_class where relkind='r' 
  and relname=your_tablename 
  
"Sim Zacks" [EMAIL PROTECTED] wrote in 
message news:[EMAIL PROTECTED]...
selectyour_tablename from pg_class 
where relkind='r'
    
  "Shaun Clements" [EMAIL PROTECTED] wrote 
  in message news:[EMAIL PROTECTED]...
  Hi 
  Hate to ask, but it isnt obvious to me from the 
  documentation. How do I perform a query in 
  pgplsql, to check it a table exists of a particular name. 
  Thanks in advance 
  Kind Regards, Shaun 
  Clements 



[GENERAL] Porting MySQL PHP to Postgres

2005-02-21 Thread Shaun Clements
Title: [GENERAL] Porting MySQL PHP to Postgres





Hi All


I am going to attempt to move an Intranet Application across from MySQL, to Postgres.
I would like to know is there any best method / tool to do this.
The application is written in PHP. Perhaps there is someone who is using Postgres, who had this problem.


Thanks in advance.


Kind Regards,
Shaun Clements





Re: [GENERAL] Porting MySQL PHP to Postgres

2005-02-21 Thread Shaun Clements
Title: RE: [GENERAL] Porting MySQL PHP to Postgres





Hi Russel


I assumed as much. I was hoping there was a tool available which someone had used and (or) what kind of stumbling blocks to run into.

Thanks again.



Kind Regards,
Shaun Clements


-Original Message-
From: Russell Smith [mailto:[EMAIL PROTECTED]]
Sent: 21 February 2005 12:38 PM
To: Shaun Clements
Cc: Postgres general mailing list
Subject: Re: [GENERAL] Porting MySQL PHP to Postgres



On Mon, 21 Feb 2005 08:41 pm, you wrote:
 Hi All
 
 I am going to attempt to move an Intranet Application across from MySQL, to
 Postgres.
 I would like to know is there any best method / tool to do this.
 The application is written in PHP. Perhaps there is someone who is using
 Postgres, who had this problem.
 
I can be simple or it can be hard.


It all depends on the complexity, and setup of the PHP scripts.


You may just need to change mysql_query for pg_query, the open and close
function, and it might just mostly work. However if you app has mysql specific
code, or you are using some complicated classes to manage it, it may be harder to
port.


Unless the application is known, it difficult to give any real analysis on the difficulty of 
the task.


Regards


Russell Smith.


 Thanks in advance.
 
 Kind Regards,
 Shaun Clements
 





Re: [GENERAL]

2005-02-08 Thread Shaun Clements
Title: RE: [GENERAL]





You would need to use EXCEPTION, to trap the error.


Kind Regards,
Shaun Clements


-Original Message-
From: Jan Poslusny [mailto:pajout@gingerall.cz]
Sent: 08 February 2005 12:01 PM
To: Surabhi Ahuja
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL]



You can use savepoints in pg 8.0:
http://www.postgresql.org/docs/8.0/static/sql-savepoint.html


Surabhi Ahuja wrote:


 in a transaction i try to insert into a table1, followed by insert 
 into table 2 then insert into table 3 and last insert into table 4. 
 However if a unique key violation occurs in the table 1 , the whole 
 trabnsaction aborts. is there no way , where i can ignore this 
 violation, and continue with the remaining insertions.
 ?



---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
 subscribe-nomail command to [EMAIL PROTECTED] so that your
 message can get through to the mailing list cleanly
Subject to www.relyant.co.za/edisclaim.htm





[GENERAL] Problem performing a restore of a data schema in Windows

2005-02-07 Thread Shaun Clements
Title: Problem performing a restore of a data schema in Windows





Hi All


Im having a problem restoring a data schema on Postgres 8.01 for Windows.
Im using the following command
psql -U username -d db1  filename.dmp


This should have restored the schema from the file, filename.dmp to the database, db1
I did create the database before restoring the data schema. And its not working.


Am I missing something?
Thanks in advance.


Kind Regards,
Shaun Clements
Subject to www.relyant.co.za/edisclaim.htm





Re: [GENERAL] Problem performing a restore of a data schema in Wi

2005-02-07 Thread Shaun Clements
Title: RE: [GENERAL] Problem performing a restore of a data schema in Windows





Yeah, thats right.
Sorry, Typo.


Any suggestions. 


Kind Regards,
Shaun Clements


-Original Message-
From: Shridhar Daithankar [mailto:[EMAIL PROTECTED]]
Sent: 07 February 2005 03:33 PM
To: Shaun Clements
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] Problem performing a restore of a data schema in
Windows



On Monday 07 Feb 2005 6:52 pm, Shaun Clements wrote:
 Im having a problem restoring a data schema on Postgres 8.01 for Windows.
 Im using the following command
 psql -U username -d db1  filename.dmp


Shouldn't that be 
psql -U username -d db1  filename.dmp


Shridhar
Subject to www.relyant.co.za/edisclaim.htm





Re: [GENERAL] Problem performing a restore of a data schema in Wi

2005-02-07 Thread Shaun Clements
Title: RE: [GENERAL] Problem performing a restore of a data schema in Windows





Hi John


Thanks for the suggestion. It worked perfectly.


Thanks


Kind Regards,
Shaun Clements



-Original Message-
From: John DeSoi [mailto:[EMAIL PROTECTED]]
Sent: 07 February 2005 04:21 PM
To: Shaun Clements
Cc: 'PgSql General'
Subject: Re: [GENERAL] Problem performing a restore of a data schema in
Windows




On Feb 7, 2005, at 8:22 AM, Shaun Clements wrote:


 psql -U username -d db1  filename.dmp


Try


psql.exe -U username -d db1 -f filename.dmp


If it does not work, paste the output from the terminal so we can see 
what error you have. Are you sure filename.dmp is a plain text dump? If 
not, you need to use pg_restore instead of psql.



John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
Subject to www.relyant.co.za/edisclaim.htm