Re: [SQL] Postgresql function which compares values from both tables

2012-03-19 Thread Jayadevan M
Hi, > To: pgsql-sql@postgresql.org > Subject: [SQL] Postgresql function which compares values from both tables > > hi , > how to write a function which should read data from 2 tables having > same number of columns and should show the common values from those tables. If you want to compare and

Re: [SQL] Postgresql function which compares values from both tables

2012-03-19 Thread David Johnston
> -Original Message- > From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql- > ow...@postgresql.org] On Behalf Of Richard Huxton > Sent: Monday, March 19, 2012 4:59 PM > To: David Johnston > Cc: 'Rehan Saleem'; pgsql-sql@postgresql.org > Subject: Re:

Re: [SQL] Postgresql function which compares values from both tables

2012-03-19 Thread Richard Huxton
On 19/03/12 20:04, David Johnston wrote: You would need to install the “HSTORE” extension to convert the record into a key->value pair then perform the comparison on that. No, you can do this just fine with a simple join. BEGIN; CREATE TABLE ta (id int PRIMARY KEY, d date, t text); CREATE TAB

Re: [SQL] Postgresql function which compares values from both tables

2012-03-19 Thread David Johnston
You would need to install the "HSTORE" extension to convert the record into a key->value pair then perform the comparison on that. Dave From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Rehan Saleem Sent: Monday, March 19, 2012 3:40 PM To: pgsql-sq

Re: [SQL] PostgreSQL Function

2012-01-18 Thread Pavel Stehule
Hello 2012/1/18 Rehan Saleem > hi > i want to create a function in postgresql that take input for columns from > user for example first_name , last_name, addres. and will put them into > table , and i also want to use exception if user enters wrong data. will > some one help me how can i create

Re: [SQL] PostgreSQL Function: how to know the number of the returned results of the Query

2009-09-02 Thread Harun Bolat
count aggregate function can be use like this. "SELECT count(rate) into row_count from voiptariff where id= 9;" CREATE OR REPLACE FUNCTION get_credit_time(text, text) RETURNS integer AS $BODY$ DECLARE row_count integer; BEGIN rate numberic(9,4); SELECT count(rate) into row_count from v

Re: [SQL] PostgreSQL Function: how to know the number of the returned results of the Query

2009-08-31 Thread Pavel Stehule
Hello look on PERFORM and GET DIAGNOSTICS statements http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-NORESULT http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS regards Pavel Stehule 2009/9/1 bilal ghayyad :

Re: [SQL] postgresql function not accepting null valuesinselect statement

2008-02-25 Thread Bart Degryse
OTECTED]> 2008-02-25 6:20 >>> I have tried this, but it is showing following error: ERROR: syntax error at or near "DISTINCT" SQL state: 42601 Thanks, Jyoti -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of johnf Sent: Friday, Febru

Re: [SQL] postgresql function not accepting null values inselect statement

2008-02-24 Thread Robins Tharakan
ED] [mailto: > > [EMAIL PROTECTED] > > On Behalf Of johnf > > Sent: Friday, February 22, 2008 10:01 PM > > To: pgsql-sql@postgresql.org > > Subject: Re: [SQL] postgresql function not accepting null values > > inselect > > statement > > >

Re: [SQL] postgresql function not accepting null values inselect statement

2008-02-24 Thread Robins Tharakan
http://www.postgresql.org/docs/current/static/functions-comparison.html This document states this: Lets assume: A = NULL B = 10 C = NULL SELECT 1 WHERE A = B returns no rows SELECT 1 WHERE A = C returns no rows (even though both A and C are NULL) SELECT 1 WHERE A IS NOT DISTINCT FROM C returns 1

Re: [SQL] postgresql function not accepting null values inselect statement

2008-02-24 Thread Jyoti Seth
gresql.org Subject: Re: [SQL] postgresql function not accepting null values inselect statement On Friday 22 February 2008 01:35:47 am Bart Degryse wrote: > Can you try this... > > CREATE OR REPLACE FUNCTION getfunctionaries(p_statecd integer) > RETURNS SETOF t_functionaries AS >

Re: [SQL] postgresql function not accepting null values inselect statement

2008-02-22 Thread johnf
On Friday 22 February 2008 01:35:47 am Bart Degryse wrote: > Can you try this... > > CREATE OR REPLACE FUNCTION getfunctionaries(p_statecd integer) > RETURNS SETOF t_functionaries AS > $BODY$ > DECLARE > rec t_functionaries%ROWTYPE; > BEGIN > FOR rec IN ( > SELECT f.functionaryid, f.categ

Re: [SQL] postgresql function not accepting null values inselect statement

2008-02-22 Thread Bart Degryse
nt separately it gives values Thanks, Jyoti -Original Message- From: Richard Huxton [mailto:[EMAIL PROTECTED] Sent: Friday, February 22, 2008 2:35 PM To: Jyoti Seth Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] postgresql function not accepting null values in select statement Jyoti Seth wrot

Re: [SQL] postgresql function not accepting null values in select statement

2008-02-22 Thread Richard Huxton
Jyoti Seth wrote: Hi, I have a the following procedure CREATE OR REPLACE FUNCTION getfunctionaries(p_statecd integer) SELECT f.functionaryid, f.category,f.description FROM functionaries f where f.statecd=p_statecd In the functionaries table statecd is a null field.

Re: [SQL] postgresql function not accepting null values in select statement

2008-02-22 Thread Robins Tharakan
quot; > > As the document suggests you may want to try this way out: > > WHERE f.statecd IS NOT DISTINCT FROM p_statecd > > This would take care of both NULL and non-NULL values. > > *Robins* > > > -- Forwarded message ------ > From: Jyoti Seth &l

Re: [SQL] postgresql function not accepting null values in select statement

2008-02-22 Thread Jyoti Seth
@postgresql.org Subject: Re: [SQL] postgresql function not accepting null values in select statement Jyoti Seth wrote: > > If I pass null value as the parameter of postgresql function, which is used > in the where clause of select statement is not functioning properly. Either: 1. You'r

Re: [SQL] postgresql function not accepting null values in select statement

2008-02-22 Thread Richard Huxton
Jyoti Seth wrote: If I pass null value as the parameter of postgresql function, which is used in the where clause of select statement is not functioning properly. Either: 1. You're talking about frooble(), in which case it's supposed to do that. or 2. You'll need to tell us what function it