Re: [SQL] Help to simplify sample query

2004-03-09 Thread Daniel Henrique Alves Lima
Tomasz Myrta wrote:

Can you try this query ? :

select cd_area from area a1
 join teacher_course c2 using (cd_course)
where (cd_teacher,cd_course) in (select 1,2 union select 98,45 union 
select 11,0);
   Tomasz, the "in" in the query above will work like an "or" 
((cd_teacher=1,cd_course=2) or (cd_teacher=98,cd_course=45) or 
(cd_teacher=11,cd_course=0)) but i need an "and" behaviour (because of 
this i was using some exists/ands)...

Thanks for your reply.



---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] Help to simplify sample query

2004-03-09 Thread Daniel Henrique Alves Lima
   How about this:

select cd_area from area a1 where
  not exists ((select 1,2 union select 98,45 union select 11,0) except
  select c2.cd_teacher,c2.cd_course from teacher_course c2 where 
c2.cd_course=a1.course)

?

Tom Lane wrote:

Daniel Henrique Alves Lima <[EMAIL PROTECTED]> writes:
 

   I don't think this is possible, but: Is there a efficient way to 
compare if the result of a query is a superset of the result of another ?
   

Perhaps do "SELECT foo EXCEPT SELECT bar" and see if you get anything?

			regards, tom lane

 



---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [SQL] Trying to make efficient "all vendors who can provide all items"

2004-03-09 Thread terry
Of all the proposed solutions, this appears to run the fastest, and not
require the creation of an additional table.

Thanks!

Terry Fielder
Manager Software Development and Deployment
Great Gulf Homes / Ashton Woods Homes
[EMAIL PROTECTED]
Fax: (416) 441-9085


> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Matt Chatterley
> Sent: Monday, March 08, 2004 3:41 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [SQL] Trying to make efficient "all vendors who
> can provide
> all items"
>
>
> Hmm. My PGSQL knowledge is rusty, so this may be slightly
> microsoftified..
>
> How about just:
>
> SELECT V.VendorID, V.VendorName, COUNT(IV.ItemID)
> FROM Vendor V
> INNER JOIN Item_Vendor IV ON IV.VendorID = V.VendorID AND
> IV.ItemID IN (1,
> 2, 3, 4, 5)
> GROUP BY V.VendorID, V.VendorName
> HAVING COUNT(IV.ItemID) = 5
>


---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


[SQL] currval() without specifying the sequence name

2004-03-09 Thread ow
Hi,

Is there a way to retrieve the current value (i.e. the last used value) of the
last used sequence without specifying the sequence name? Something like the
following:

create table ( id serial, value varchar(10));
insert into someOthertest (value) values ('100');
insert into test (value) values ('10');
insert into test (value) values ('20');

select currval() should returns 2 (the last value of the test table sequence)

Thanks




__
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread Achilleus Mantzios
O kyrios ow egrapse stis Mar 9, 2004 :

> Hi,
> 
> Is there a way to retrieve the current value (i.e. the last used value) of the
> last used sequence without specifying the sequence name? Something like the
> following:
> 
> create table ( id serial, value varchar(10));
> insert into someOthertest (value) values ('100');
> insert into test (value) values ('10');
> insert into test (value) values ('20');
> 
> select currval() should returns 2 (the last value of the test table sequence)

You could use the same sequence in many tables.

> 
> Thanks
> 
> 
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Search - Find what you’re looking for faster
> http://search.yahoo.com
> 
> ---(end of broadcast)---
> TIP 5: Have you checked our extensive FAQ?
> 
>http://www.postgresql.org/docs/faqs/FAQ.html
> 

-- 
-Achilleus


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread ow

--- Achilleus Mantzios <[EMAIL PROTECTED]> wrote:
> 
> You could use the same sequence in many tables.
> 

I guess I could but then:

1) I'd still have to know the sequence name. When integrating pgSql with 3party
frameworks I'd either have to pass it there (could be a very difficult task) or
make some assumptions (also not very good).

2) There may be a need to have different sequences being used in an app.

3) If one sequence is used, in many cases it'll have to be of type int8 and
pgSql does not handle searches with int8 very nicely.

Thanks




__
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

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


Re: [SQL] Trying to make efficient "all vendors who can provide all items"

2004-03-09 Thread Michael Glaesemann
Just one more to add to the pile. Got it from Celko's "SQL for 
Smarties", under the relational division section.

I'd make a temporary table for the items on the list.

CREATE TEMP TABLE select_items (
item_id foo NOT NULL UNIQUE
REFERENCES items(item_id)
);
SELECT DISTINCT vi1.vendor_id FROM vendors_items vi1
WHERE NOT EXISTS (
SELECT item_id FROM select_items
EXCEPT
SELECT items FROM vendors_items vi2
WHERE vi1.vendor_id = vi2.vendor_id
)
);
Michael Glaesemann
grzm myrealbox com
On Mar 9, 2004, at 10:37 PM, <[EMAIL PROTECTED]> wrote:

Of all the proposed solutions, this appears to run the fastest, and not
require the creation of an additional table.
Thanks!

Terry Fielder
Manager Software Development and Deployment
Great Gulf Homes / Ashton Woods Homes
[EMAIL PROTECTED]
Fax: (416) 441-9085

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Matt Chatterley
Sent: Monday, March 08, 2004 3:41 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [SQL] Trying to make efficient "all vendors who
can provide
all items"
Hmm. My PGSQL knowledge is rusty, so this may be slightly
microsoftified..
How about just:

SELECT V.VendorID, V.VendorName, COUNT(IV.ItemID)
FROM Vendor V
INNER JOIN Item_Vendor IV ON IV.VendorID = V.VendorID AND
IV.ItemID IN (1,
2, 3, 4, 5)
GROUP BY V.VendorID, V.VendorName
HAVING COUNT(IV.ItemID) = 5


---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread Achilleus Mantzios
O kyrios ow egrapse stis Mar 9, 2004 :

> 
> --- Achilleus Mantzios <[EMAIL PROTECTED]> wrote:
> > 
> > You could use the same sequence in many tables.
> > 
> 
> I guess I could but then:
> 
> 1) I'd still have to know the sequence name. When integrating pgSql with 3party
> frameworks I'd either have to pass it there (could be a very difficult task) or
> make some assumptions (also not very good).
> 
> 2) There may be a need to have different sequences being used in an app.
> 
> 3) If one sequence is used, in many cases it'll have to be of type int8 and
> pgSql does not handle searches with int8 very nicely.
> 
> Thanks
> 
>

I dont think you have given solid reasons as to why somebody whould
want to do that (in order to be more specific and help you better),
but in any case:

foodb=# SELECT relname from pg_class where relkind = 'S';
relname
---
 footbl_id_seq
 footbl2_id_seq
(1 row)

gives you a list of sequences of your current schema.

Then you can loop thru those to:

select last_value from ;
and get the maximum, but again what exaclty are you trying to do?
 
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Search - Find what you’re looking for faster
> http://search.yahoo.com
> 
> ---(end of broadcast)---
> TIP 4: Don't 'kill -9' the postmaster
> 

-- 
-Achilleus


---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread Richard Huxton
On Tuesday 09 March 2004 13:50, ow wrote:
> Hi,
>
> Is there a way to retrieve the current value (i.e. the last used value) of
> the last used sequence without specifying the sequence name? Something like
> the following:
>
> create table ( id serial, value varchar(10));
> insert into someOthertest (value) values ('100');
> insert into test (value) values ('10');
> insert into test (value) values ('20');
>
> select currval() should returns 2 (the last value of the test table
> sequence)

Not really - what if two sequences had been used?

-- 
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [SQL] Dramatic slowdown of sql when placed in a function

2004-03-09 Thread Jeff Boes
At some point in time, [EMAIL PROTECTED] (Mike Moran) wrote:

>Hi. I currently have a fairly large query which I have been optimizing
>for later use in a function. There are things in the query which I
>have been keeping constant whilst optimizing, but which are variables
>in the function. When I run this query as sql, with the `variables'
>constant, I get a runtime of about 3 or 4 seconds. However, when I
>place this same sql in an sql function, and then pass my constants
>from before in as arguments, I get a runtime of about 215 seconds.
>
>I am trying to understand how this could be. How does putting the sql
>in a function affect the query optimiser? Would putting it in as a
>plpsql function help? How else can I retain the original speed?

My first guess would be that the indexes being used in the query are
mis-matching on data type compared to your function arguments. For instance,


create function foobar(text) as
'begin
 select * from foobar_table where col_a=$1;
 end' ...

I may have some syntax wrong up there, but the idea is that you are passing in a
parameter of some datatype (text here) and then using it in a select statement
against a column which we will assume is of some datatype other than "text". If
the index your query uses is not picking up the datatype conversion properly,
then you may have a sequential scan instead.

To verify this, you might do these:

EXPLAIN
select * from foobar_table where
col_a=;

vs.

EXPLAIN
select * from foobar_table where
col_a=::;



--
| Genius may have its limitations, but stupidity is not
Jeff Boes   | thus handicapped.
[EMAIL PROTECTED]   |--Elbert Hubbard (1856-1915), American author



---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread Tom Lane
ow <[EMAIL PROTECTED]> writes:
> I guess I could but then:

> 1) I'd still have to know the sequence name. When integrating pgSql
> with 3party frameworks I'd either have to pass it there (could be a
> very difficult task) or make some assumptions (also not very good).

This scenario is really entirely ridiculous.  You want your code to be
integrated with other code and not make any assumptions, but you are
willing to assume that only one sequence will be touched in any command,
or that the last one that's touched is the one you want?

It seems to me that this idea will render your code more fragile, not
less so.

> 3) If one sequence is used, in many cases it'll have to be of type int8 and
> pgSql does not handle searches with int8 very nicely.

Quote or cast and you're fine.  But what does that have to do with
knowing a sequence name?

regards, tom lane

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [SQL] currval() without specifying the sequence name

2004-03-09 Thread ow
--- Tom Lane <[EMAIL PROTECTED]> wrote:
> or that the last one that's touched is the one you want?

Correct.



__
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com

---(end of broadcast)---
TIP 6: Have you searched our list archives?

   http://archives.postgresql.org


Re: [SQL] Help to simplify sample query

2004-03-09 Thread Daniel Henrique Alves Lima
   Where can i find the documentation about "except" or "textcat" ?
I've looked at html docs in my machine (i've a 7.34 copy) and i 
couldn't found information/sample of them.

   Thanks.

---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [SQL] Help to simplify sample query

2004-03-09 Thread Bruno Wolff III
On Tue, Mar 09, 2004 at 17:13:37 -0300,
  Daniel Henrique Alves Lima <[EMAIL PROTECTED]> wrote:
>Where can i find the documentation about "except" or "textcat" ?
> I've looked at html docs in my machine (i've a 7.34 copy) and i 
> couldn't found information/sample of them.

except should be under the select command.
I don't think there is much on textcat as such as people are expected to
use the concatenation operator normally.

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] bytea or blobs?

2004-03-09 Thread Richard Huxton
On Tuesday 09 March 2004 18:33, you wrote:
> Hi.  If it wouldn't be too much of a bother could you send me sample code
> that used SQL commands to insert a bytea as well as retrieve, that includes
> the encode / decode stuff?  I have been struggling to figure out how to get
> this to work.  I am using SQL embedded in C.

Michael, I'm cc-ing this to the sql list since I don't use embedded SQL 
myself.

> For instance if I have data stored in something called (char *pData), how
> would I put that into a bytea field and then retrieve it?
>
> Say, the table was something like:
> create table testit ( id integer, thedata bytea, primary key ( id ) );
>
> Then, inside the C with embedded SQL code:
>
> char *pData;
> -- Read something into pData..
> exec sql insert into testit ( id, thedata ) values ( 10, :pData );

Well, AFAIK the main thing to remember with bytea is that it can contain 
characters that need escaping (in particular ascii 0). What worries me about 
the above is that there is no obvious way for pData to contain a \0.

Now, the encode/decode functions work simply enough and using the 'escape' 
encoding will convert back/fore quite neatly. Alternatively, you might prefer 
'base64' - on average a less compact format I'd guess.

I don't know whether the ECPG interface lets you pass "raw" binary back and 
fore or not, but hopefully someone else will.

-- 
  Richard Huxton
  Archonet Ltd

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


[SQL] correlated multi-set update?

2004-03-09 Thread Marty Scholes
Hello,

My company recently deployed Pg 7.4.1. on Solaris for an experimental 
project and is using the experience to evaluate its viability for 
migration from Oracle 7.0.

While I like a lot of the features of Pg, one thing I noticed that 
"seems" to be missing is the ability to set multiple fields in an update 
using a correlated subquery.

For example, I have a statement that copies fields from a template (bar) 
into another table (foo) based on a list of keys in a third table (keylist):

UPDATE foo f
SET (f1, f2, f3, f4, f5) = (
  SELECT f1, f2, f3, f4, f5
  FROM bar b
  WHERE f.fk = b.pk
  )
WHERE f.pk IN (
  SELECT l.pk
  FROM keylist l
  );
In Oracle this works wonders, but it seems to fail under Pg because Pg 
wants single field updates and does not allow subqueries.

Next I tried:

UPDATE foo f
SET f1 = (
  SELECT f1
  FROM bar b
  WHERE f.fk = b.pk
  ),
f2 = (
  SELECT f2
  FROM bar b
  WHERE f.fk = b.pk
  ),
f3 = (
  SELECT f3
  FROM bar b
  WHERE f.fk = b.pk
  ),
f4 = (
  SELECT f4
  FROM bar b
  WHERE f.fk = b.pk
  ),
f5 = (
  SELECT f5
  FROM bar b
  WHERE f.fk = b.pk
  )
WHERE f.pk IN (
  SELECT l.pk
  FROM keylist l
  );
That seemed to get closer, but still barfed (apparently) because of a 
lack of table aliasing and correlated subqueries.  This makes the 
process become an iterative one.

Am I missing something here?

Thanks in advance.

Sincerely,
Marty
---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
   (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] Dramatic slowdown of sql when placed in a function

2004-03-09 Thread Mike Moran
Jeff Boes <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> At some point in time, [EMAIL PROTECTED] (Mike Moran) wrote:
> 
> >Hi. I currently have a fairly large query which I have been optimizing
> >for later use in a function. There are things in the query which I
> >have been keeping constant whilst optimizing, but which are variables
> >in the function. When I run this query as sql, with the `variables'
> >constant, I get a runtime of about 3 or 4 seconds. However, when I
> >place this same sql in an sql function, and then pass my constants
> >from before in as arguments, I get a runtime of about 215 seconds.
> >
[ ... ]
> 
> My first guess would be that the indexes being used in the query are
> mis-matching on data type compared to your function arguments. For instance,
[ ... ]

Hi. I think it is something like this that is going on. A couple of
the variables are dates which are
specified in the table as 'timestamp without time zone', whilst the
function was using 'timestamp with time zone'. I confirmed the
slowdown by casting the types to the 'slow' type in the original
query.

However, when I change the signature of the function and do a cast of
the variable within the function body I still get the same speed. I
even cast the arguments to the function given at the psql prompt and
still I get the same speed.

I will have to sanity-check this again tomorrow (posting from home)
but I couldn't see anywhere else that I could force the type to be the
same as that specified on the table.

Many thanks,

-- 
Mike

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] correlated multi-set update?

2004-03-09 Thread Stephan Szabo

On Tue, 9 Mar 2004, Marty Scholes wrote:

> Hello,
>
> My company recently deployed Pg 7.4.1. on Solaris for an experimental
> project and is using the experience to evaluate its viability for
> migration from Oracle 7.0.
>
> While I like a lot of the features of Pg, one thing I noticed that
> "seems" to be missing is the ability to set multiple fields in an update
> using a correlated subquery.
>
> For example, I have a statement that copies fields from a template (bar)
> into another table (foo) based on a list of keys in a third table (keylist):
>
> UPDATE foo f
> SET (f1, f2, f3, f4, f5) = (
>SELECT f1, f2, f3, f4, f5
>FROM bar b
>WHERE f.fk = b.pk
>)
> WHERE f.pk IN (
>SELECT l.pk
>FROM keylist l
>);
>
> In Oracle this works wonders, but it seems to fail under Pg because Pg
> wants single field updates and does not allow subqueries.
>
> Next I tried:
>
> UPDATE foo f
> SET f1 = (
>SELECT f1
>FROM bar b
>WHERE f.fk = b.pk
>),
> f2 = (
>SELECT f2
>FROM bar b
>WHERE f.fk = b.pk
>),
> f3 = (
>SELECT f3
>FROM bar b
>WHERE f.fk = b.pk
>),
> f4 = (
>SELECT f4
>FROM bar b
>WHERE f.fk = b.pk
>),
> f5 = (
>SELECT f5
>FROM bar b
>WHERE f.fk = b.pk
>)
> WHERE f.pk IN (
>SELECT l.pk
>FROM keylist l
>);
>
> That seemed to get closer, but still barfed (apparently) because of a
> lack of table aliasing and correlated subqueries.  This makes the
> process become an iterative one.
>
> Am I missing something here?

You're not allowed to alias the update target table, so I think you'd need
to remove the f alias and refer to foo anywhere you're currently referring
to f.


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


[SQL] Converting query to view - duplicate fields

2004-03-09 Thread Richard Grosse
Hello,

Trying to convert the query below to a view. The problem is
despite it working as a query when trying to save it as a
view  the database returns the error that the field tablealias.cmpname
is duplicated. (Which it is and has to be)
So how to a refer to the same table more than once and
get the data without getting the above error. (Basically it
is looking up different addresses depending on the codes
stored in mhdespatch table). Can I do this with a view, or
do I have to create several views and link them together.
Thanks

Richard
Postgresql 7.4.1,SuSE 8.1
Query Begins ==>

CREATE OR REPLACE VIEW public.test AS
SELECT mhdespatch.gdn, mhdespatch.date, mhdespatch.remarks, 
mhdespatch.sp_instruct1,
mhdespatch.sp_instruct2, mhdespatch.sp_instruct3, tbldelivery.cmpname,
tbldelivery.adds1, tbldelivery.adds2, tbldelivery.adds3, tbldelivery.town,
tbldelivery.county, tbldelivery.pcode, tbldelivery.country, tbldelivery.tel1,
mhdespatch.del_ref, tblsender.cmpname, mhdespatch.send_ref, 
tblhaulier.cmpname,
mhdespatch.haul_reg, mhdespatch.cov, tblhaulier.tel1
FROM mhdespatch
INNER JOIN tblfmna AS tblhaulier ON mhdespatch.haul_code = tblhaulier.code
INNER JOIN tblfmna AS tblsender ON mhdespatch.send_code = tblsender.code
INNER JOIN tblfmna AS tbldelivery ON mhdespatch.del_code = tbldelivery.code;

<=== Query Ends 

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


Re: [SQL] Converting query to view - duplicate fields

2004-03-09 Thread Stephan Szabo
On Tue, 9 Mar 2004, Richard Grosse wrote:

> Trying to convert the query below to a view. The problem is
> despite it working as a query when trying to save it as a
> view  the database returns the error that the field tablealias.cmpname
> is duplicated. (Which it is and has to be)

You're going to need to use column aliases to alias (for example)
tbldeliver.cmpname, tblsender.cmpname, tblhaulier.cmpname to different
aliases in the view, perhaps
"tbldeliver.cmpname" "tblsender.cmpname" and "tblhaulier.cmpname"
(note the double quotes).

> CREATE OR REPLACE VIEW public.test AS
> SELECT mhdespatch.gdn, mhdespatch.date, mhdespatch.remarks,
> mhdespatch.sp_instruct1,
> mhdespatch.sp_instruct2, mhdespatch.sp_instruct3, tbldelivery.cmpname,
> tbldelivery.adds1, tbldelivery.adds2, tbldelivery.adds3, tbldelivery.town,
> tbldelivery.county, tbldelivery.pcode, tbldelivery.country, tbldelivery.tel1,
> mhdespatch.del_ref, tblsender.cmpname, mhdespatch.send_ref,
> tblhaulier.cmpname,
> mhdespatch.haul_reg, mhdespatch.cov, tblhaulier.tel1
> FROM mhdespatch
> INNER JOIN tblfmna AS tblhaulier ON mhdespatch.haul_code = tblhaulier.code
> INNER JOIN tblfmna AS tblsender ON mhdespatch.send_code = tblsender.code
> INNER JOIN tblfmna AS tbldelivery ON mhdespatch.del_code = tbldelivery.code;

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


[SQL] pg_hba.conf

2004-03-09 Thread azwa

Hi,

  i try to connect to my database as $ psql dwnc biosadm  but got the error
   "psql: FATAL:  No pg_hba.conf entry for host localhost, user
biosadm, database dwnc"
Below are the detail in pg_hba.conf

   # TYPE  DATABASEUSERIP-ADDRESSIP-MASK
METHOD

  local  all   all
trust
  host  all   all   127.0.0.1
255.255.255.255 trust
  host allall  192.168.1.45
255.255.255.0  trust
  host  dwncbiosadm 192.168.1.45
255.255.255.0trust



the line in bold has been deleted before i connect to database . then i
shutdown the database using following command :
pg_ctl -D /usr/local/pgsql/data stop -m fast

followed by startup database :

postmaster -D /usr/local/pgsql/data > logg 2>&1  &

Does anybody know why does the above error  occur when trying to connect
database and try connect through client using pgadmin??? thanks in advance





---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] correlated multi-set update?

2004-03-09 Thread Bruno Wolff III
On Tue, Mar 09, 2004 at 14:48:57 -0700,
  Marty Scholes <[EMAIL PROTECTED]> wrote:
> 
> While I like a lot of the features of Pg, one thing I noticed that 
> "seems" to be missing is the ability to set multiple fields in an update 
> using a correlated subquery.

You can't set more than one column in one phrase, so you need to use
something like you tried next.
> 
> Next I tried:
> 
> UPDATE foo f

I don't believe you can use an alias on the update table. If you change
this and use foo instead of f in the subselects, then the update should
do what you want.

However it may be more efficient to use a FROM clause and do something
like:

UPDATE foo
  SET f1 = b.f1,
f2 = b.f2,
f3 = b.f3,
f4 = b.f4,
f5 = b.f5
  FROM bar as b
  WHERE
foo.pk = b.pk AND
f.pk IN (
  SELECT l.pk
  FROM keylist l
);

---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


Re: [SQL] pg_hba.conf

2004-03-09 Thread azwa


Hi,

   by the way i've settle my connection problem between client application and server itself . this is happen because of editing the parameter in pg_hba.conf
while the environment(database was running) was active.  tq 







[EMAIL PROTECTED]

Sent by: [EMAIL PROTECTED]

12:12 PM Today


        To:        [EMAIL PROTECTED]
        cc:        
        Subject:        [SQL] pg_hba.conf



Hi,

  i try to connect to my database as $ psql dwnc biosadm  but got the error
               "psql: FATAL:  No pg_hba.conf entry for host localhost, user
biosadm, database dwnc"
Below are the detail in pg_hba.conf

   # TYPE  DATABASE    USER        IP-ADDRESS        IP-MASK
METHOD

      local                  all           all
trust
      host                  all           all                   127.0.0.1
255.255.255.255     trust
      host                 all            all              192.168.1.45
255.255.255.0      trust
      host              dwnc        biosadm     192.168.1.45
255.255.255.0        trust



the line in bold has been deleted before i connect to database . then i
shutdown the database using following command :
pg_ctl -D /usr/local/pgsql/data stop -m fast

followed by startup database :

    postmaster -D /usr/local/pgsql/data > logg 2>&1  &

Does anybody know why does the above error  occur when trying to connect
database and try connect through client using pgadmin??? thanks in advance





---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])



[SQL] Database reporting tool

2004-03-09 Thread azwa



Hi,

  i'm using PostgreSQL as my database and now i'm looking for a good reporting tools(can do ad-hoc queries & ease of use) 
 that can connect to several database instead of PostgreSQL.
thanks in advance

Re: [SQL] Database reporting tool

2004-03-09 Thread Jerome Alet
On Wed, Mar 10, 2004 at 02:17:31PM +0800, [EMAIL PROTECTED] wrote:
> 
>   i'm using PostgreSQL as my database and now i'm looking for a good 
> reporting tools(can do ad-hoc queries & ease of use) 
>  that can connect to several database instead of PostgreSQL.
> thanks in advance

see : http://www.openoffice.org

bye

Jerome Alet

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]