Re: quering NULL values

Lists: pgsql-novice
From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: sending N selects with begin and commit and get the result
Date: 2006-01-05 16:36:24
Message-ID: BAY18-F301C19E3CFDAA0A89158A3B52E0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I there, is it possible to send a undefine number of queries (SELECTS) with
transactions, and if one of then doesn't return anything do rollback and do
not commit? if not, is there another tool that does that. I need to get the
result of the COMMIT. thanks in advance

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/


From: Andrew Chambers <andychambers2002(at)yahoo(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: sending N selects with begin and commit and get the result
Date: 2006-01-05 20:51:02
Message-ID: 20060105205102.GA29504@yapgi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On 16:36 Thu 05 Jan , Luis Silva wrote:
> I there, is it possible to send a undefine number of queries (SELECTS) with
> transactions, and if one of then doesn't return anything do rollback and do
> not commit? if not, is there another tool that does that. I need to get the
> result of the COMMIT. thanks in advance

If you're only selecting, there would be nothing to rollback

Regards,
Andy


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: problem with returning values from pl/pgsql
Date: 2006-01-27 17:49:50
Message-ID: BAY18-F9D38D16E550BAF1CB2DE0B5140@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


I there!! I'm using pl/pgsql in my application, but I'm having a problem
with the returning value. What my function does is quering the db and
according to the result of the different queries returns a error message or
some information from the db. I'm inserting the correct information in a
record variable, but I cant insert text in a variable like this,the error
message created by me. Is it possible, or is there another returning type
that I can use??

DECLARE
val_pub text;
asds Record;

BEGIN
RAISE NOTICE 'validate_user()';
val_pub:=$1;

EXECUTE 'SELECT count(*) FROM public_identif WHERE
identity='||quote_literal(val_pub) INTO asds;

IF asds.count=0 THEN
RETURN 'DIAMETER_ERROR_USER_UNKNOWN';
END IF;

EXECUTE 'SELECT name FROM public_identif WHERE
identity='||quote_literal(val_pub) INTO asds;

RETURN name; -----array of text!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

RETURN NULL;
END;

tks a lot in advance


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: quering NULL values
Date: 2006-01-30 15:41:10
Message-ID: BAY18-F216D1BDE006E99E0D49E27B5090@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I there I'm having a problem.

I'm doing this SQL query

select count(*) from public_identif INNER JOIN ifc ON
ifc.spid=public_identif.spid where (ifc.profilepartindicator='' OR
ifc.profilepartindicator='UNREGISTERED') AND
public_identif.identity='sip:joao(at)ptinovacao(dot)pt'

ifc.profilepartindicator='' can be a NULL value that is why i'm doing this,
but it's not working. I tried ifc.profilepartindicator=NULL but i get
nothing again. Can you help please?? Tks a lot


From: Charley Tiggs <ctiggs(at)xpressdocs(dot)com>
To: Luis Silva <lfs12(at)hotmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: quering NULL values
Date: 2006-01-30 15:47:10
Message-ID: 43DE34FE.6040609@xpressdocs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Luis Silva wrote:
> I there I'm having a problem.
>
> I'm doing this SQL query
>
> select count(*) from public_identif INNER JOIN ifc ON
> ifc.spid=public_identif.spid where (ifc.profilepartindicator='' OR
> ifc.profilepartindicator='UNREGISTERED') AND
> public_identif.identity='sip:joao(at)ptinovacao(dot)pt'
>
>
> ifc.profilepartindicator='' can be a NULL value that is why i'm doing
> this, but it's not working. I tried ifc.profilepartindicator=NULL but i
> get nothing again. Can you help please?? Tks a lot

change your query as follows:

select count(*) from public_identif INNER JOIN ifc ON
ifc.spid=public_identif.spid where (ifc.profilepartindicator='' OR
ifc.profilepartindicator IS NULL OR
ifc.profilepartindicator='UNREGISTERED') AND
public_identif.identity='sip:joao(at)ptinovacao(dot)pt'

Note the addition of "ifc.profilepartindicator IS NULL" within the
parentheses.

Charley


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: quering NULL values
Date: 2006-01-30 15:55:55
Message-ID: BAY18-F225527EF47057A4F427FFAB5090@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

>From: Charley Tiggs <ctiggs(at)xpressdocs(dot)com>
>To: Luis Silva <lfs12(at)hotmail(dot)com>
>CC: pgsql-novice(at)postgresql(dot)org
>Subject: Re: [NOVICE] quering NULL values
>Date: Mon, 30 Jan 2006 09:47:10 -0600
>
>Luis Silva wrote:
>>I there I'm having a problem.
>>
>>I'm doing this SQL query
>>
>>select count(*) from public_identif INNER JOIN ifc ON
>>ifc.spid=public_identif.spid where (ifc.profilepartindicator='' OR
>>ifc.profilepartindicator='UNREGISTERED') AND
>>public_identif.identity='sip:joao(at)ptinovacao(dot)pt'
>>
>>
>>ifc.profilepartindicator='' can be a NULL value that is why i'm doing
>>this, but it's not working. I tried ifc.profilepartindicator=NULL but i
>>get nothing again. Can you help please?? Tks a lot
>
>
>change your query as follows:
>
>select count(*) from public_identif INNER JOIN ifc ON
>ifc.spid=public_identif.spid where (ifc.profilepartindicator='' OR
>ifc.profilepartindicator IS NULL OR
>ifc.profilepartindicator='UNREGISTERED') AND
>public_identif.identity='sip:joao(at)ptinovacao(dot)pt'
>
>Note the addition of "ifc.profilepartindicator IS NULL" within the
>parentheses.
>
>Charley
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: explain analyze is your friend


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: substring result
Date: 2006-02-13 10:53:48
Message-ID: BAY18-F244DEDDD4E3820C14731C5B5070@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


I there!! I'm trying to use regular expressions with postgresql. My
objective is to get from a long string the information that I need.
For example

"name='joe' , address='portugal' " and I need to get 'joe' and 'portugal'.
can I do it with select substring()? if I can,how? tks a lot


From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: substring result
Date: 2006-02-13 12:06:28
Message-ID: 20060213120628.GB30335@webserv.wug-glas.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

am 13.02.2006, um 10:53:48 +0000 mailte Luis Silva folgendes:
>
> I there!! I'm trying to use regular expressions with postgresql. My
> objective is to get from a long string the information that I need.
> For example
>
> "name='joe' , address='portugal' " and I need to get 'joe' and 'portugal'.
> can I do it with select substring()? if I can,how? tks a lot

test=# select * from foo;
string
---------------------------------
name='joe' , address='portugal'
(1 row)

Write a function:
- count the fields separeted by ',' and then for every field:

test=# select regexp_replace(split_part(string,',',1), '\\m.*=', '') from foo;
regexp_replace
----------------
'joe'
(1 row)

test=# select regexp_replace(split_part(string,',',2), '\\m.*=', '') from foo;
regexp_replace
----------------
'portugal'
(1 row)

You can with trim() remove spaces if you need.

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: andreas(dot)kretschmer(at)schollglas(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: substring result
Date: 2006-02-13 15:36:06
Message-ID: BAY18-F21A610453467C5A2E42C00B5070@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

HI!!! that worked fine, but is it possible to get 'name' and 'address'
using the regexp_replace too? TKS A LOT again

>From: "A. Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
>To: pgsql-novice(at)postgresql(dot)org
>Subject: Re: [NOVICE] substring result
>Date: Mon, 13 Feb 2006 13:06:28 +0100
>
>am 13.02.2006, um 10:53:48 +0000 mailte Luis Silva folgendes:
> >
> > I there!! I'm trying to use regular expressions with postgresql. My
> > objective is to get from a long string the information that I need.
> > For example
> >
> > "name='joe' , address='portugal' " and I need to get 'joe' and
>'portugal'.
> > can I do it with select substring()? if I can,how? tks a lot
>
>test=# select * from foo;
> string
>---------------------------------
> name='joe' , address='portugal'
>(1 row)
>
>
>Write a function:
>- count the fields separeted by ',' and then for every field:
>
>
>test=# select regexp_replace(split_part(string,',',1), '\\m.*=', '') from
>foo;
> regexp_replace
>----------------
> 'joe'
>(1 row)
>
>test=# select regexp_replace(split_part(string,',',2), '\\m.*=', '') from
>foo;
> regexp_replace
>----------------
> 'portugal'
>(1 row)
>
>
>You can with trim() remove spaces if you need.
>
>
>
>HTH, Andreas
>--
>Andreas Kretschmer (Kontakt: siehe Header)
>Heynitz: 035242/47215, D1: 0160/7141639
>GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
> === Schollglas Unternehmensgruppe ===
>
>---------------------------(end of broadcast)---------------------------
>TIP 6: explain analyze is your friend


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: substring result
Date: 2006-02-13 15:39:33
Message-ID: BAY18-F12B8742E32C8BE692AF172B5070@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


Ok , I've used .....,'\\M.*','') tks again

>From: "Luis Silva" <lfs12(at)hotmail(dot)com>
>To: andreas(dot)kretschmer(at)schollglas(dot)com, pgsql-novice(at)postgresql(dot)org
>Subject: Re: [NOVICE] substring result
>Date: Mon, 13 Feb 2006 15:36:06 +0000
>
>HI!!! that worked fine, but is it possible to get 'name' and 'address'
>using the regexp_replace too? TKS A LOT again
>
>>From: "A. Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
>>To: pgsql-novice(at)postgresql(dot)org
>>Subject: Re: [NOVICE] substring result
>>Date: Mon, 13 Feb 2006 13:06:28 +0100
>>
>>am 13.02.2006, um 10:53:48 +0000 mailte Luis Silva folgendes:
>> >
>> > I there!! I'm trying to use regular expressions with postgresql. My
>> > objective is to get from a long string the information that I need.
>> > For example
>> >
>> > "name='joe' , address='portugal' " and I need to get 'joe' and
>>'portugal'.
>> > can I do it with select substring()? if I can,how? tks a lot
>>
>>test=# select * from foo;
>> string
>>---------------------------------
>> name='joe' , address='portugal'
>>(1 row)
>>
>>
>>Write a function:
>>- count the fields separeted by ',' and then for every field:
>>
>>
>>test=# select regexp_replace(split_part(string,',',1), '\\m.*=', '') from
>>foo;
>> regexp_replace
>>----------------
>> 'joe'
>>(1 row)
>>
>>test=# select regexp_replace(split_part(string,',',2), '\\m.*=', '') from
>>foo;
>> regexp_replace
>>----------------
>> 'portugal'
>>(1 row)
>>
>>
>>You can with trim() remove spaces if you need.
>>
>>
>>
>>HTH, Andreas
>>--
>>Andreas Kretschmer (Kontakt: siehe Header)
>>Heynitz: 035242/47215, D1: 0160/7141639
>>GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
>> === Schollglas Unternehmensgruppe ===
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 6: explain analyze is your friend
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: quering NULL values
Date: 2006-02-15 10:23:53
Message-ID: BAY18-F1751829F628832F1D0E6F7B5FA0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I there!!! Can you help with an urgent question. I'm doing a pl/pgsql
function and need to return a record value or a text value. Can I pass the
text to record? the return type "unknown" works for this?? does it has a
good performance? tks a lot


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: lfs12(at)hotmail(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: returning Record type problem
Date: 2006-02-15 12:03:29
Message-ID: BAY18-F1854D18736138B496BAAE8B5FA0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


sorry again. another question. When I return a Record value I only get the
first row of the result. What might be the problem? tks again


From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: returning Record type problem
Date: 2006-02-15 12:18:30
Message-ID: 20060215121829.GH18481@webserv.wug-glas.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

am 15.02.2006, um 12:03:29 +0000 mailte Luis Silva folgendes:
>
> sorry again. another question. When I return a Record value I only get the
> first row of the result. What might be the problem? tks again

Please:

If you start a new thread (question), then start a new thread and don't
change the subject from a old mail. Many people have mail-clients with
the possibility to show threads.

Secondly, can you explain your problem? My guess: you need a SRF:
http://www.varlena.com/GeneralBits/26, chapter 'Returning Sets'.

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: andreas(dot)kretschmer(at)schollglas(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: returning Record type problem
Date: 2006-02-15 12:50:38
Message-ID: BAY18-F6475D449C723D0ED580A5B5FA0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Sorry for that. I think this will help me resolve my problem. Thanks a lot
and sorry again

>From: "A. Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
>To: pgsql-novice(at)postgresql(dot)org
>Subject: Re: [NOVICE] returning Record type problem
>Date: Wed, 15 Feb 2006 13:18:30 +0100
>
>am 15.02.2006, um 12:03:29 +0000 mailte Luis Silva folgendes:
> >
> > sorry again. another question. When I return a Record value I only get
>the
> > first row of the result. What might be the problem? tks again
>
>Please:
>
>If you start a new thread (question), then start a new thread and don't
>change the subject from a old mail. Many people have mail-clients with
>the possibility to show threads.
>
>Secondly, can you explain your problem? My guess: you need a SRF:
>http://www.varlena.com/GeneralBits/26, chapter 'Returning Sets'.
>
>
>HTH, Andreas
>--
>Andreas Kretschmer (Kontakt: siehe Header)
>Heynitz: 035242/47215, D1: 0160/7141639
>GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
> === Schollglas Unternehmensgruppe ===
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: Don't 'kill -9' the postmaster


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: id from a field
Date: 2006-02-22 18:32:14
Message-ID: BAY18-F1162F54D047DE1DFF9ED92B5FD0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

I there!! I'm having a problem. I know that it's possible to know the exact
ID of a table or a column using OIDs but, is it possible to know the ID from
a field?. for example I have a table named "identities" with 3 columns:
name,address and age and 3 users in that table:
richard | spain | 22
joe | france | 23
carol | italy | 24

for example, does the field "france" as a unique id that I could save and
get that info only with that id?

thanks a lot Luis


From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: id from a field
Date: 2006-02-22 18:43:39
Message-ID: 20060222184339.GA16167@webserv.wug-glas.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

am 22.02.2006, um 18:32:14 +0000 mailte Luis Silva folgendes:
> I there!! I'm having a problem. I know that it's possible to know the exact
> ID of a table or a column using OIDs but, is it possible to know the ID
> from a field?. for example I have a table named "identities" with 3

If you create the table with oid, yes. And, you have the ctid.
http://www.postgresql.org/docs/faqs.FAQ.html -> 4.12 ctid

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: check problem
Date: 2006-02-23 18:54:49
Message-ID: BAY18-F13F50A447BDD0466400928B5F20@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


I there. I having a problem. I have a table with 3 columns, identity,
implicit_group(int) and private. if insert, for exemple, one identity with
an implicit_group with the value '1' and a private 'aaaa' i need to guaranty
that i can't insert another identity with an implicity_group '1' and a
different private. How can I do this? tks a lot.

ps - Tks Andreas for responding to my other problem


From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Luis Silva <lfs12(at)hotmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: check problem
Date: 2006-02-23 22:45:23
Message-ID: 20060223224523.GA54616@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Thu, Feb 23, 2006 at 06:54:49PM +0000, Luis Silva wrote:
> I there. I having a problem. I have a table with 3 columns, identity,
> implicit_group(int) and private. if insert, for exemple, one identity with
> an implicit_group with the value '1' and a private 'aaaa' i need to
> guaranty that i can't insert another identity with an implicity_group '1'
> and a different private. How can I do this? tks a lot.

It's not clear exactly what you want to allow and prevent. Is it
acceptable to insert a different identity with the same implicit_group
and private as the first row? What about another row with the same
identity as the first row but with a different implicit_group and/or
private? It might be helpful if you could indicate whether each
of the following rows, inserted in the given order, should be
accepted or rejected and why:

1) 'ident1', 1, 'aaaa' -- first row, assumed to be accepted
2) 'ident1', 1, 'aaaa' -- duplicate of (1)
3) 'ident1', 1, 'bbbb' -- same ident and group as (1) but different private
4) 'ident1', 2, 'aaaa' -- same ident and private as (1) but different group
5) 'ident1', 2, 'bbbb' -- same ident as (1) but different group and private
6) 'ident2', 1, 'aaaa' -- different ident as (1) but same group and private
7) 'ident2', 1, 'bbbb' -- different ident and private as (1) but same group
8) 'ident2', 2, 'aaaa' -- different ident and group as (1) but same private
9) 'ident2', 2, 'bbbb' -- different ident, group, and private from (1)

It might also be helpful if you gave an abstract explanation of the
problem you're trying to solve. Sometimes that can suggest a schema
redesign.

--
Michael Fuhr


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: mike(at)fuhr(dot)org
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: check problem
Date: 2006-02-23 23:52:31
Message-ID: BAY18-F162825DC903A65E2AA62E6B5F20@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


tks for answering.
Identity is the private key from the table. using your examples you could
have :
1) ident1,1,'aaaa'
2) ident2,1,'aaaa'
3) ident3,2,'aaaa'
4) ident4,3,'bbbb'

but not

5)identi5,1,'bbbb'

-->same implicit_group for different privates.
is it possible? tks again

>From: Michael Fuhr <mike(at)fuhr(dot)org>
>To: Luis Silva <lfs12(at)hotmail(dot)com>
>CC: pgsql-novice(at)postgresql(dot)org
>Subject: Re: [NOVICE] check problem
>Date: Thu, 23 Feb 2006 15:45:23 -0700
>
>On Thu, Feb 23, 2006 at 06:54:49PM +0000, Luis Silva wrote:
> > I there. I having a problem. I have a table with 3 columns, identity,
> > implicit_group(int) and private. if insert, for exemple, one identity
>with
> > an implicit_group with the value '1' and a private 'aaaa' i need to
> > guaranty that i can't insert another identity with an implicity_group
>'1'
> > and a different private. How can I do this? tks a lot.
>
>It's not clear exactly what you want to allow and prevent. Is it
>acceptable to insert a different identity with the same implicit_group
>and private as the first row? What about another row with the same
>identity as the first row but with a different implicit_group and/or
>private? It might be helpful if you could indicate whether each
>of the following rows, inserted in the given order, should be
>accepted or rejected and why:
>
>1) 'ident1', 1, 'aaaa' -- first row, assumed to be accepted
>2) 'ident1', 1, 'aaaa' -- duplicate of (1)
>3) 'ident1', 1, 'bbbb' -- same ident and group as (1) but different
>private
>4) 'ident1', 2, 'aaaa' -- same ident and private as (1) but different
>group
>5) 'ident1', 2, 'bbbb' -- same ident as (1) but different group and
>private
>6) 'ident2', 1, 'aaaa' -- different ident as (1) but same group and
>private
>7) 'ident2', 1, 'bbbb' -- different ident and private as (1) but same
>group
>8) 'ident2', 2, 'aaaa' -- different ident and group as (1) but same
>private
>9) 'ident2', 2, 'bbbb' -- different ident, group, and private from (1)
>
>It might also be helpful if you gave an abstract explanation of the
>problem you're trying to solve. Sometimes that can suggest a schema
>redesign.
>
>--
>Michael Fuhr
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: Don't 'kill -9' the postmaster


From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Luis Silva <lfs12(at)hotmail(dot)com>
Cc: mike(at)fuhr(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: check problem
Date: 2006-02-24 00:52:32
Message-ID: 20060224005232.GA19136@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Thu, Feb 23, 2006 at 23:52:31 +0000,
Luis Silva <lfs12(at)hotmail(dot)com> wrote:
>
> tks for answering.
> Identity is the private key from the table. using your examples you could
> have :
> 1) ident1,1,'aaaa'
> 2) ident2,1,'aaaa'
> 3) ident3,2,'aaaa'
> 4) ident4,3,'bbbb'
>
> but not
>
> 5)identi5,1,'bbbb'
>
> -->same implicit_group for different privates.
> is it possible? tks again

The above table should only have the ident and the group number. The group
number should have a foreign key reference to another table of which the
group number is the primary key and another column for private.
This will allow only one private for each group number.


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: bruno(at)wolff(dot)to
Cc: mike(at)fuhr(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: check problem
Date: 2006-02-24 10:09:29
Message-ID: BAY18-F3354D4C91484CDBB7AB81B5F30@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


is it possible to make a trigger that could evaluate all identities and
search for the implicit_group that we want to insert and match with that
private. if false return an error.

>From: Bruno Wolff III <bruno(at)wolff(dot)to>
>To: Luis Silva <lfs12(at)hotmail(dot)com>
>CC: mike(at)fuhr(dot)org, pgsql-novice(at)postgresql(dot)org
>Subject: Re: [NOVICE] check problem
>Date: Thu, 23 Feb 2006 18:52:32 -0600
>
>On Thu, Feb 23, 2006 at 23:52:31 +0000,
> Luis Silva <lfs12(at)hotmail(dot)com> wrote:
> >
> > tks for answering.
> > Identity is the private key from the table. using your examples you
>could
> > have :
> > 1) ident1,1,'aaaa'
> > 2) ident2,1,'aaaa'
> > 3) ident3,2,'aaaa'
> > 4) ident4,3,'bbbb'
> >
> > but not
> >
> > 5)identi5,1,'bbbb'
> >
> > -->same implicit_group for different privates.
> > is it possible? tks again
>
>The above table should only have the ident and the group number. The group
>number should have a foreign key reference to another table of which the
>group number is the primary key and another column for private.
>This will allow only one private for each group number.
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly


From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Luis Silva <lfs12(at)hotmail(dot)com>
Cc: mike(at)fuhr(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: check problem
Date: 2006-02-24 14:38:50
Message-ID: 20060224143850.GA24287@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Fri, Feb 24, 2006 at 10:09:29 +0000,
Luis Silva <lfs12(at)hotmail(dot)com> wrote:
>
> is it possible to make a trigger that could evaluate all identities and
> search for the implicit_group that we want to insert and match with that
> private. if false return an error.

Why do you want such a function? What are you really trying to do?

It is usually better to ask about how you might accomplish a high level task
than to ask about how to use some particular solution to that task, as you
may not have picked a very good way to do things.

>
> >From: Bruno Wolff III <bruno(at)wolff(dot)to>
> >To: Luis Silva <lfs12(at)hotmail(dot)com>
> >CC: mike(at)fuhr(dot)org, pgsql-novice(at)postgresql(dot)org
> >Subject: Re: [NOVICE] check problem
> >Date: Thu, 23 Feb 2006 18:52:32 -0600
> >
> >On Thu, Feb 23, 2006 at 23:52:31 +0000,
> > Luis Silva <lfs12(at)hotmail(dot)com> wrote:
> >>
> >> tks for answering.
> >> Identity is the private key from the table. using your examples you
> >could
> >> have :
> >> 1) ident1,1,'aaaa'
> >> 2) ident2,1,'aaaa'
> >> 3) ident3,2,'aaaa'
> >> 4) ident4,3,'bbbb'
> >>
> >> but not
> >>
> >> 5)identi5,1,'bbbb'
> >>
> >> -->same implicit_group for different privates.
> >> is it possible? tks again
> >
> >The above table should only have the ident and the group number. The group
> >number should have a foreign key reference to another table of which the
> >group number is the primary key and another column for private.
> >This will allow only one private for each group number.
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 1: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> > message can get through to the mailing list cleanly
>
>


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Trigger problem
Date: 2006-03-20 10:23:51
Message-ID: BAY115-F312462E926FB4F8055257AB5DB0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hi there, I'm having a problem, When I'm doing an update to one of the
fields of my table I need to know if it's changed.
For exemple I have the table with the columns
id,identity,registration_state.

Test:
id | identity | registration_state
1 | Joe | registered
2 | Tom | not_registered
3 | James | unregistered

when i do "update test set registration_state='registered'" I need to know
for which identities the registration_state was change (and then return it).
In this case, Tom and James.

I was thinking about using a trigger function for the updates, using
pl/pgsql (using before in the trigger). the problem is that I don't know how
to get the old registration_state when I have multiple rows affected. I
known that if I use OLD.registration_state it works for one rows. Can you
help for multiple? tks a lot in advance


From: Terry Lee Tucker <terry(at)esc1(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Trigger problem
Date: 2006-03-20 10:35:18
Message-ID: 200603200535.18218.terry@esc1.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Monday 20 March 2006 05:23 am, Luis Silva saith:
> Hi there, I'm having a problem, When I'm doing an update to one of the
> fields of my table I need to know if it's changed.
> For exemple I have the table with the columns
> id,identity,registration_state.
>
> Test:
> id | identity | registration_state
> 1 | Joe | registered
> 2 | Tom | not_registered
> 3 | James | unregistered
>
> when i do "update test set registration_state='registered'" I need to know
> for which identities the registration_state was change (and then return
> it). In this case, Tom and James.

I believe that all three will be updated with the above statement.

>
> I was thinking about using a trigger function for the updates, using
> pl/pgsql (using before in the trigger). the problem is that I don't know
> how to get the old registration_state when I have multiple rows affected. I
> known that if I use OLD.registration_state it works for one rows. Can you
> help for multiple? tks a lot in advance
>

Define the BEFORE trigger so that it fires for each row as in:
CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] }
ON table [ FOR [ EACH ] { ROW | STATEMENT } ]
EXECUTE PROCEDURE funcname ( arguments )

Pick the ROW option. This will cause the trigger to fire for each row updated
in your statement. You are going to need another table called audit or
something so that your trigger can insert information about the change into
that table.

>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: "Terry Lee Tucker" <terry(at)esc1(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Trigger problem
Date: 2006-03-21 15:26:38
Message-ID: BAY115-DAV4C0495DFCCC9851E24A2CB5D80@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hi, tks for answering. What you told is true, if I use the query "update
test set registration_state='registered'" all the rows will be affected.
That is the problem, I need to know only the rows that are different. So,
for that, I was thinking about using the trigger for each row. So according
to what you said, I could use a table to save the cases where the
Old.registration_state != New.registration_state. But that gives me another
problem, if multiple process access the same table that would be a problem.
Can you help me. tks

----- Original Message -----
From: "Terry Lee Tucker" <terry(at)esc1(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Sent: Monday, March 20, 2006 10:35 AM
Subject: Re: [NOVICE] Trigger problem

> On Monday 20 March 2006 05:23 am, Luis Silva saith:
>> Hi there, I'm having a problem, When I'm doing an update to one of the
>> fields of my table I need to know if it's changed.
>> For exemple I have the table with the columns
>> id,identity,registration_state.
>>
>> Test:
>> id | identity | registration_state
>> 1 | Joe | registered
>> 2 | Tom | not_registered
>> 3 | James | unregistered
>>
>> when i do "update test set registration_state='registered'" I need to
>> know
>> for which identities the registration_state was change (and then return
>> it). In this case, Tom and James.
>
> I believe that all three will be updated with the above statement.
>
>>
>> I was thinking about using a trigger function for the updates, using
>> pl/pgsql (using before in the trigger). the problem is that I don't know
>> how to get the old registration_state when I have multiple rows affected.
>> I
>> known that if I use OLD.registration_state it works for one rows. Can
>> you
>> help for multiple? tks a lot in advance
>>
>
> Define the BEFORE trigger so that it fires for each row as in:
> CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] }
> ON table [ FOR [ EACH ] { ROW | STATEMENT } ]
> EXECUTE PROCEDURE funcname ( arguments )
>
> Pick the ROW option. This will cause the trigger to fire for each row
> updated
> in your statement. You are going to need another table called audit or
> something so that your trigger can insert information about the change
> into
> that table.
>
>>
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 2: Don't 'kill -9' the postmaster
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: for loop help
Date: 2006-04-04 23:01:02
Message-ID: BAY117-DAV104D1A9250CB686ABAB6DDB5CA0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

Hi! Is it possible to know in a loop in pl/pgsql if the next element is de
last? exemple

DECLARE
asds Record;

BEGIN

FOR asds IN EXECUTE 'select id from user_table' LOOP

IF asds.id.next = last THEN
......
END IF;

END LOOP;

tks


From: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: for loop help
Date: 2006-04-05 09:24:49
Message-ID: 20060405092449.GD15606@webserv.wug-glas.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

am 05.04.2006, um 0:01:02 +0100 mailte Luis Silva folgendes:
> Hi! Is it possible to know in a loop in pl/pgsql if the next element is de
> last? exemple
>
> DECLARE
> asds Record;
>
> BEGIN
>
> FOR asds IN EXECUTE 'select id from user_table' LOOP
>
> IF asds.id.next = last THEN
> ......
> END IF;
>
> END LOOP;

You can use a cursor and walk with the cursor through the result.
(move last cursor_name -> you have the last id, then move first, then
your for ... loop and check the id if is it the last id)

Perhaps, there are better solutions...

HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: transaction identifier
Date: 2006-04-11 17:12:32
Message-ID: BAY117-F25BBC70049BA10EAD38E5DB5CD0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


I there, is it possible to identify the transaction running, when using a
pg/sql function?
Here is my problem:

I have a trigger in the database for one of my tables when I do an update. I
was trying, for all the rows affected when I'm doing an update, to send a
NOTIFY to my code. the problem is that I realize that if the NOTIFYs are
inside the same transaction, the database only sends one. What I'm doing is
having a auxiliar table where I insert the information that I consult when I
received a NOTIFY, and then after I read that information in my code I just
delete it. the problem is that I've Concurrency and I dont want to use
SELECT FOR UPDATE. If I had another row inside that auxiliar table
identifying the transaction I could distinguish the information and when I
delete it, according to the transaction id.

can you help ? Luis


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: returning from a trigger
Date: 2006-04-18 00:03:33
Message-ID: BAY117-F3058674785648E6F4E029DB5C40@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


Hi there! I'm having a big problem. I'm creating a pl/pgsql function and I
want my function to return one table that I've created, but that info is
created by me:

-->Table

CREATE TABLE returnfunc
(
error bool NOT NULL,
result text NOT NULL,
name text
)
WITHOUT OIDS;

-->Pl/pgsql func
CREATE OR REPLACE FUNCTION validate(pub text)
RETURNS returnfunc AS
$BODY$
DECLARE
answer returnfunc
val_pub text;
asds Record;

BEGIN
val_priv:=$1;

EXECUTE 'SELECT count(*) FROM public_data WHERE
identity='||quote_literal(val_pub) INTO asds;

IF asds.count=0 THEN
answer.error='1';
answer.result='DIAMETER_ERROR_USER_UNKNOWN';
RETURN answer;
END IF;

RETURN NULL;
END;
....

the problem is that this is returning " (t,DIAMETER_ERROR_USER_UNKNOWN,) "
and I want to return this information in different columns, like when i'm
doing a select to the returnfunc. Is that possible? is there another away of
doing this? tks in advance


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: returning from a trigger
Date: 2006-04-18 00:08:03
Message-ID: BAY117-F32B6BEEF9DAED29ABD0DF1B5C40@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


sorry, I was doing select validate('') and I need to do select * from
validate(''). sorry

>From: "Luis Silva" <lfs12(at)hotmail(dot)com>
>To: pgsql-novice(at)postgresql(dot)org
>Subject: [NOVICE] returning from a trigger
>Date: Tue, 18 Apr 2006 00:03:33 +0000
>
>
>Hi there! I'm having a big problem. I'm creating a pl/pgsql function and I
>want my function to return one table that I've created, but that info is
>created by me:
>
>-->Table
>
>CREATE TABLE returnfunc
>(
> error bool NOT NULL,
> result text NOT NULL,
> name text
>)
>WITHOUT OIDS;
>
>-->Pl/pgsql func
>CREATE OR REPLACE FUNCTION validate(pub text)
> RETURNS returnfunc AS
>$BODY$
>DECLARE
>answer returnfunc
>val_pub text;
>asds Record;
>
>BEGIN
> val_priv:=$1;
>
> EXECUTE 'SELECT count(*) FROM public_data WHERE
>identity='||quote_literal(val_pub) INTO asds;
>
> IF asds.count=0 THEN
> answer.error='1';
> answer.result='DIAMETER_ERROR_USER_UNKNOWN';
> RETURN answer;
> END IF;
>
>RETURN NULL;
>END;
>....
>
>the problem is that this is returning " (t,DIAMETER_ERROR_USER_UNKNOWN,) "
>and I want to return this information in different columns, like when i'm
>doing a select to the returnfunc. Is that possible? is there another away
>of doing this? tks in advance
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq


From: "Luis Silva" <lfs12(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: stress tests problems
Date: 2006-04-24 17:02:17
Message-ID: BAY117-F611EE56128165CD1590AFB5BE0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice


HI there! I'm doing some stress test in my db with 100.000 users (rows) in
one of my tables. I'm using indexes,vacuum, and other stuff but the db is
too slow. Is there any other mechanism to optimize the db? tks in advance


From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Luis Silva <lfs12(at)hotmail(dot)com>
Cc: Novice Postgresql-list <pgsql-novice(at)postgresql(dot)org>
Subject: Re: stress tests problems
Date: 2006-04-24 20:12:39
Message-ID: 20060424201239.36771.qmail@web31801.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

> HI there! I'm doing some stress test in my db with 100.000 users (rows) in
> one of my tables. I'm using indexes,vacuum, and other stuff but the db is
> too slow. Is there any other mechanism to optimize the db? tks in advance

This link should be a good resource for improving database preformance.
http://www.postgresql.org/docs/8.1/interactive/maintenance.html

Additional steps would be to "tune" your PostgreSQL configuration.
http://www.postgresql.org/docs/8.1/interactive/runtime-config-resource.html

There are additional links that describe what to do with these setting if you are interested.

Lastly, you could always upgrade your hardware. :-)

Regards,

Richard Broersma Jr.


From: Andrew Chambers <andychambers2002(at)yahoo(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: stress tests problems
Date: 2006-04-24 20:45:44
Message-ID: 20060424204544.GA28028@yapgi.hopto.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

* Luis Silva <lfs12(at)hotmail(dot)com> [2006-04-24 17:02:17 +0000]:

Hi Luis,

It seems that when you start a new topic, you reply to one of the
replies to your previous topic. My mail-reader threading has gone off
the right hand side for your last few posts.

Would you mind making sure the "In-Reply-To" header is blank when you
start a new topic.

Thanks,
Andy