Re: [SQL] pl/PgSQL: Samples doing UPDATEs ...

2005-08-18 Thread Michael Fuhr
On Fri, Aug 19, 2005 at 02:38:01AM -0300, Marc G. Fournier wrote: > I have an older PostgreSQL book here, that has chapter on pl/PgSQL in it, > but no good samples > > What I'm looking for is a sample of a function that returns # of rows > updated, so that I can make a decision based on tha

Re: [SQL] pl/PgSQL: Samples doing UPDATEs ...

2005-08-18 Thread daq
MGF> I have an older PostgreSQL book here, that has chapter on pl/PgSQL in it, MGF> but no good samples MGF> What I'm looking for is a sample of a function that returns # of rows MGF> updated, so that I can make a decision based on that ... does anyone know MGF> where I could find such (a

[SQL] pl/PgSQL: Samples doing UPDATEs ...

2005-08-18 Thread Marc G. Fournier
I have an older PostgreSQL book here, that has chapter on pl/PgSQL in it, but no good samples What I'm looking for is a sample of a function that returns # of rows updated, so that I can make a decision based on that ... does anyone know where I could find such (and others, would be gre

Re: [SQL] Tables are not being updated Properly through Trigger

2005-08-18 Thread A. Kretschmer
am 15.08.2005, um 18:07:23 +0530 mailte Venkatesh Krishnamurthy folgendes: > We have written a trigger on insertion which is supposed to update 3 > tables with new data. We are seeing a weird thing happening with > Postgres, i.e. If we have 4 records to be updated on insertion trigger, > postgre

Re: [SQL] Parentheses in FROM clause and evaluation order.

2005-08-18 Thread Dario Bahena Tapia
Hi, The final result seems to be the same, I just was curious about the standard behavior. Does the SQl says something about this execution order? Thanks for your response. salu2 dario estepario ... 2005/8/15, Stephan Szabo <[EMAIL PROTECTED]>: > On Wed, 10 Aug 2005 [EMAIL PROTECTED] wrote: >

[SQL] Tables are not being updated Properly through Trigger

2005-08-18 Thread Venkatesh Krishnamurthy
Title: Tables are not being updated Properly through Trigger We have written a trigger on insertion which is supposed to update 3 tables with new data.  We are seeing a weird thing happening with Postgres, i.e.  If we have 4 records to be updated on insertion trigger, postgres updates the fir

Re: [SQL] sql function: using set as argument

2005-08-18 Thread Akshay Mathur
Thanks! Thomas   Actually I am going to use many functions for different counts and a wrapper function to return all count in one shot. My function1 is going to be a part of all count functions. If I use it as sub query in all the functions, performance degrades drastically, as my query o

[SQL] PGSQL function for converting between arbitrary numeric bases?

2005-08-18 Thread Simon Kinsella
Hello, I'm looking - without luck so far - for a PGSQL function for converting numbers between two arbitrary bases (typically base 10,16 and 26 in my case). Something similar to the C 'strtol' function or, ideally, PHP's baseconvert(string,frombase,tobase) function. I've search the docs, lists a

Re: [SQL] Parentheses in FROM clause and evaluation order.

2005-08-18 Thread Dario Bahena Tapia
Ok, thanks for the responses guys. Then, in the case where the final result is the same, could we think the parentheses in the FROM clause, as a tool to clarify the query to the user? Since in the end, this order could be changed by the implementation for performance reasons. salu2 dario estepari

[SQL] pgsql-bugs

2005-08-18 Thread Lee Hyun soon
From: "Lee Hyun soon" <[EMAIL PROTECTED]> To: pgsql-bugs@postgresql.org Date: Wed, 17 Aug 2005 05:36:23 +0100 (BST) Subject: BUG #1826: pgsql odbc & ADO.NET The following bug has been logged online: Bug reference: 1826 Logged by: Lee Hyun soon Email address: [EMAIL PROTECTED] P

[SQL] Updateing pg_trigger and pg_constraint

2005-08-18 Thread Craig Servin
I am trying to make some foreign keys deferrable and initially deferred. These foreign key constraints already exist so I was going to change them by updating pg_trigger and pg_constraint. However the changes do not seem to take affect. Is there something I need to do to get PostgreSQL to rec

Re: [SQL] dates and selection

2005-08-18 Thread Josh Berkus
Joel, > Now I found I had to do something like this just to have a timestamp > (problem is I do not want the format of the time stamp, my clients want to > see the month as a string) Um, what's wrong with: to_char(some_timestamp, 'Mon DD HH:MI:SS') ? -- Josh Berkus Aglio Database Soluti

Re: [SQL] SQL CASE Statements

2005-08-18 Thread Dmitri Bichko
I am not sure what you are asking... SELECT CASE WHEN EXISTS (SELECT foo FROM bar WHERE baz = 'a') THEN 1 ELSE 0 END; Or SELECT CASE WHEN 'a' = ANY (SELECT froo FROM bar) THEN 1 ELSE 0 END; Both work, but that's pretty much what you had already - am I missing what you are trying to achieve? Th

[SQL] SQL CASE Statements

2005-08-18 Thread Lane Van Ingen
In the following CASE statement, is it possible to put a SELECT ... WHERE EXISTS in the of a CASE statement, and have it work? The I want to do is to yield a result of '1' if the statement finds the value 'a' in a table (EXISTS evaluates true), and '0' if it evaluates false ('a' not found). SEL

Re: [SQL] How to secure PostgreSQL Data for distribute?

2005-08-18 Thread Ferindo Middleton Jr
On 8/17/05, Premsun Choltanwanich <[EMAIL PROTECTED]> wrote: Dear All, I need to distribute my application that use PostgreSQL as database to my customer. But I still have some questions in my mind on database security. I understand that everybody who get my application database will

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Hi to all, there was a BIG MISTAKE in my proposition regarding my last post: In fact, after examining the online documentation (Note that I don't have enough experience in postgreSQL !!) I found that select '(' || replace('1 2', " ", ",") || ')'; could not, in any way, be equivalent to: selec

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Hi, If you put pg_index.indkey in the select statement, you'd notice that it's sometimes 1 ( it's when we have one PK field) and sometimes 1 2 ( for two PK fields), etc. So I tried to use a replace command like the following: (just to add parentheses, replace the space by a comma to use the res

[SQL] nevermind answered my own question by looking at my question what a DOH!

2005-08-18 Thread Joel Fradkin
select * from viwEmpIncCube where clientnum ='MSI' and Incidentdate::timestamp between '01/01/2005' and '08/18/2005 23:59' woks fine.   Joel Fradkin   Wazagua, Inc. 2520 Trailmate Dr Sarasota, Florida 34243 Tel.  941-753-7111 ext 305   [EMAIL PROTECTED] www.wazagua.com Powere

[SQL] dates and selection

2005-08-18 Thread Joel Fradkin
After my conversion to Unicode and implementing new drivers (Thank god still up no down time J) I do have an issue with some of my sql selects concerning dates.   I know the long answer, but am asking if there is a short one.   I have in some of my slq : (to_char(e.incidentdate, 'Mon D

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Tom Lane
"D'Arcy J.M. Cain" writes: > That's a good question. The following query does this in a very > unsatisfactory way. Anyone know what the general solution would be? > ... > ( > pg_index.indkey[0]=pg_attribute.attnum OR > pg_index.indkey[1]=pg_attribute.attnum OR > pg_index.i

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread D'Arcy J.M. Cain
On Thu, 18 Aug 2005 09:40:57 -0700 (PDT) Roger Tannous <[EMAIL PROTECTED]> wrote: > Thanks for your query :) > > But it only shows the first of the primary keys of tables having multiple > primary keys :) > > This is apparently because of the pg_index.indkey[0] thing, so how can we > manage this

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Yes, I want only field names, not values. Thanks, Roger Tannous. __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ---(end of broadcast)--- TIP

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Thanks for your query :) But it only shows the first of the primary keys of tables having multiple primary keys :) This is apparently because of the pg_index.indkey[0] thing, so how can we manage this query in order to get all of the keys :) Thanks in advance, Roger Tannous. --- "D'Arcy J.M.

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread D'Arcy J.M. Cain
On Thu, 18 Aug 2005 07:36:22 -0700 (PDT) Roger Tannous <[EMAIL PROTECTED]> wrote: > Is there any means to get a list of the Primary Keys (or simply the > Primary Key if there's only one :) ) for a given table using an SQL query Here is what I do in PyGreSQL: SELECT pg_namespace.nspname, pg_class.

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread daq
RT> Hi to all, RT> Is there any means to get a list of the Primary Keys (or simply the RT> Primary Key if there's only one :) ) for a given table using an SQL query RT> ? RT> Regards, RT> Roger Tannous. Something like this? select (select attname from pg_attribute where attrelid=pg_index.ind

Re: [SQL] A Table's Primary Key Listing

2005-08-18 Thread Michael Fuhr
On Thu, Aug 18, 2005 at 07:36:22AM -0700, Roger Tannous wrote: > Is there any means to get a list of the Primary Keys (or simply the > Primary Key if there's only one :) ) for a given table using an SQL query? Are you looking for the primary key definition or do you want the primary key values the

[SQL] A Table's Primary Key Listing

2005-08-18 Thread Roger Tannous
Hi to all, Is there any means to get a list of the Primary Keys (or simply the Primary Key if there's only one :) ) for a given table using an SQL query ? Regards, Roger Tannous. __ Do you Yahoo!? Yahoo! Mail - You care about securi

Re: [SQL] [despammed] converting varchar to integer

2005-08-18 Thread Halley Pacheco de Oliveira
A function to check for valid integers: CREATE OR REPLACE FUNCTION retInt(VARCHAR) RETURNS integer AS ' DECLARE number ALIAS FOR $1; i INTEGER := 1; BEGIN IF ((number IS NULL) OR (number = )) THEN RETURN NULL; END IF; WHILE (i <= length(number)) LOOP IF ((subs

Re: [SQL] How to secure PostgreSQL Data for distribute?

2005-08-18 Thread Christopher Browne
> Premsun Choltanwanich wrote: > >> Dear All, >> I need to distribute my application that use PostgreSQL as >> database to my customer. But I still have some questions in my mind >> on database security. I understand that everybody who get my >> application database will be have a full contr