[SQL] my rules wont execute

2008-10-20 Thread aldy
hai all,

please help me, i've made a view named bpbkain

CREATE OR REPLACE VIEW gmt.bpbkain AS 
 SELECT bpb.tanggal AS tgl_bukti, n.supplier, bpb.nobukti, n.no_po, 
n.jenis_kain, n.gramasi, n.warna, n.lebar, n.no_inv, n.harga, n.sat_harga, 
COALESCE(sum(netto2.netto), 0::double precision)::numeric(15,2) AS ncqty, 
n.qty, n.bruto, n.order_no, n.style
   FROM gmt.netto n
   LEFT JOIN ( SELECT netto_child.id_netto, sum(netto_child.kg) AS netto
   FROM gmt.netto_child
  GROUP BY netto_child.id_netto
  ORDER BY netto_child.id_netto) netto2 USING (id_netto)
   JOIN gmt.bpb USING (id_bpb)
  GROUP BY bpb.tanggal, n.supplier, bpb.nobukti, n.no_po, n.jenis_kain, 
n.gramasi, n.warna, n.lebar, n.no_inv, n.harga, n.sat_harga, n.order_no, 
n.style, n.qty, n.bruto
  ORDER BY bpb.tanggal, n.supplier, bpb.nobukti, n.no_po, n.jenis_kain, 
n.gramasi, n.warna, n.lebar, n.no_inv, n.harga, n.sat_harga;

ALTER TABLE gmt.bpbkain OWNER TO teoadm;
GRANT SELECT, UPDATE, INSERT, DELETE, REFERENCES, TRIGGER ON TABLE gmt.bpbkain 
TO teoadm;
GRANT SELECT ON TABLE gmt.bpbkain TO pm;
GRANT SELECT, UPDATE, INSERT, TRIGGER ON TABLE gmt.bpbkain TO acct;

i've made the rule too, to update a table while the view changes

CREATE OR REPLACE RULE upd_nett AS
ON UPDATE TO gmt.bpbkain DO INSTEAD  UPDATE gmt.netto SET harga = 
new.harga, sat_harga = new.sat_harga, no_inv = new.no_inv
  WHERE netto.supplier::text = new.supplier::text AND netto.no_po::text = 
new.no_po::text AND netto.jenis_kain::text = new.jenis_kain::text AND 
netto.gramasi::text = new.gramasi::text AND netto.warna::text = new.warna::text 
AND netto.lebar::text = new.lebar::text AND netto.harga = old.harga AND 
netto.sat_harga::text = old.sat_harga::text AND netto.order_no::text = 
new.order_no::text AND netto.no_inv::text = old.no_inv::text;

but when i made some changes to that view it doesn't make any change for my 
table...any body help m

[SQL] generating date sequences

2008-10-20 Thread Patrick Scharrenberg
Hi!
Is there a simple way to generate sequences of dates like the following?
"2008-07-03 00:00:00"
"2008-07-04 00:00:00"
"2008-07-05 00:00:00"
"2008-07-06 00:00:00"


I'd like to join a table to aggregate the number of items for each day
(each item has a timestamp).
For some days however there are no items, resulting in no row instead of
a row with zero items.
I'd like to fill these empty rows.

I hope I could make my problem clear?!

Best regards
Patrick

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] generating date sequences

2008-10-20 Thread A. Kretschmer
am  Mon, dem 20.10.2008, um 15:24:38 +0200 mailte Patrick Scharrenberg 
folgendes:
> Hi!
> Is there a simple way to generate sequences of dates like the following?
>   "2008-07-03 00:00:00"
>   "2008-07-04 00:00:00"
>   "2008-07-05 00:00:00"
>   "2008-07-06 00:00:00"
> 

Sure:

test=# select '2008-07-03'::date + s * '1day'::interval from
generate_Series(1,10) s;
  ?column?
-
 2008-07-04 00:00:00
 2008-07-05 00:00:00
 2008-07-06 00:00:00
 2008-07-07 00:00:00
 2008-07-08 00:00:00
 2008-07-09 00:00:00
 2008-07-10 00:00:00
 2008-07-11 00:00:00
 2008-07-12 00:00:00
 2008-07-13 00:00:00
(10 rows)


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


Re: [SQL] generating date sequences

2008-10-20 Thread Patrick Scharrenberg
Hi!

>> Is there a simple way to generate sequences of dates like the following?
> Sure:
> test=# select '2008-07-03'::date + s * '1day'::interval from
> generate_Series(1,10) s;


Thanks! Thats what I was searching for.

You saved my day from manually adding missing dates in a huge excel sheet!

So thank you again!

P. Scharrenberg

-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql


[SQL] Full Text Index Stats

2008-10-20 Thread Ryan Hansen
Greetings,

 

I couldn't find anything about this in the documentation or the mailing list
archives, so forgive me if this has already been addressed.  

 

I'm trying to determine if the full text indexing has any built-in
capability for providing information about word occurrence, i.e. the number
of times a given word is used.  I read about the ts_stat function, but
either I don't understand the syntax well enough or I don't think this is
what I'm looking for.  I know it can be used for determining the most used
words in the index (although this is very slow), but I want to be able to
get the number of occurrences on a given word.Is that kind of thing
built in somewhere or do I need to write it myself?

 

Thanks!