[SQL] handling money type

2005-10-26 Thread padmanabha konkodi
hello developers, i have facing one major problem handling sql money dataType in the java i have tried many permutation and combination but still i dint got correct data type to use in java to pass money data

Re: [SQL] why vacuum

2005-10-26 Thread Igor Shevchenko
On Wednesday 26 October 2005 17:44, Scott Marlowe wrote: > On Tue, 2005-10-25 at 23:45, Kenneth Gonsalves wrote: > > hi, > > i was in a minor flame war with a mysql guy - his major grouse was that > > 'I wouldnt commit mission critical data to a database that needs to be > > vacuumed once a week'.

Re: Yes, pg does triggers first before asserting check constraints! Was Re: [SQL] why vacuum

2005-10-26 Thread Tom Lane
"Bath, David" <[EMAIL PROTECTED]> writes: > you wrote (2005-10-26 17:00) >>> Sybase/MS-SQL's check constraint model asserts the constraint >>> BEFORE the trigger, which discourages you from attempting to> >>> check and handle meaning of data! >> Er, doesn't PG do it that way too? > Well, it work

Yes, pg does triggers first before asserting check constraints! Was Re: [SQL] why vacuum

2005-10-26 Thread Bath, David
Tom, After I wrote > > Sybase/MS-SQL's check constraint model asserts the constraint > > BEFORE the trigger, which discourages you from attempting to> > > check and handle meaning of data! you wrote (2005-10-26 17:00) > Er, doesn't PG do it that way too? Well, it works for me! In this case (wit

Re: [SQL] SQL Functions

2005-10-26 Thread Thomas F. O'Connell
On Oct 21, 2005, at 9:19 AM, [EMAIL PROTECTED] wrote: I have been trying to find a way to return more than one but different types of variables. How do I return more than one but mix types of variables. Any help is appriaciated. Thanks; In PostgreSQL 8.1, you'll have output parameters avail

Re: [SQL] SUM not matching up on a JOIN

2005-10-26 Thread Tom Lane
Tyler Kellen <[EMAIL PROTECTED]> writes: > Why is my discount total different when I > left join the trans table to the totals? Are you sure that trans_item.trans_id is unique and accounts for all the existing values of trans.id? I don't see any unique index or foreign key constraints in your \d

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Mario Splivalo
On Wed, 2005-10-26 at 15:45 -0400, Tom Lane wrote: > Mario Splivalo <[EMAIL PROTECTED]> writes: > > Wo-ha, makes perfect sense. So, I'd go by with declaring the rec as > > varchar, instead as of a record. Wich is what I should do in the first > > place. > > Or just return the correct field out of

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Tom Lane
Mario Splivalo <[EMAIL PROTECTED]> writes: > Wo-ha, makes perfect sense. So, I'd go by with declaring the rec as > varchar, instead as of a record. Wich is what I should do in the first > place. Or just return the correct field out of it. RETURN NEXT returnValue.fieldname; I think you ma

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Mario Splivalo
On Wed, 2005-10-26 at 10:40 -0400, Tom Lane wrote: > Mario Splivalo <[EMAIL PROTECTED]> writes: > > biblio3=# select * from php_get_subfield_data_repeating(1,'606a'); > > php_get_subfield_data_repeating1 > > -- > > (Anđeli) > > (ofsajd) > > (2 rows) > > > I have

Re: [SQL] select best price

2005-10-26 Thread Bruno Wolff III
On Wed, Oct 26, 2005 at 16:38:48 +0100, Gary Stainburn <[EMAIL PROTECTED]> wrote: > On Wednesday 26 October 2005 4:21 pm, Gary Stainburn wrote: > > Hi folks > > > > I've got a table holding item code(cs_id), supplier a/c (co_id) , and > > price (cs_price). > > > > How can I select the rows contai

Re: [SQL] Combining two SELECTs by same filters

2005-10-26 Thread Bruno Wolff III
On Wed, Oct 26, 2005 at 18:16:13 +0300, Volkan YAZICI <[EMAIL PROTECTED]> wrote: > And I want to collect the count of sales at hour = 21 and hour = 22. > For this purpose, I'm using below SELECT query: > > => SELECT > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND

Re: [SQL] broken join optimization? (8.0)

2005-10-26 Thread chester c young
> Tom Lane <[EMAIL PROTECTED]> wrote: > chester c young <[EMAIL PROTECTED]> writes: > > i think i misled: the goal is to retrieve _one_ row where the value > of each attribute is null. > > Er, what for? There's no data content in that, by definition. Why > not retrieve zero rows and look at the

[SQL] SUM not matching up on a JOIN

2005-10-26 Thread Tyler Kellen
The trans table contains the stub for each transaction and the trans_item table contains all the items belonging to the transaction. I need to be able to pull categorized reports for items and have all of the totals less the discounts match up with the total from the stubs for a given period. Why

Re: [SQL] broken join optimization? (8.0)

2005-10-26 Thread Tom Lane
chester c young <[EMAIL PROTECTED]> writes: > i think i misled: the goal is to retrieve _one_ row where the value of > each attribute is null. Er, what for? There's no data content in that, by definition. Why not retrieve zero rows and look at the metadata anyway? regard

Re: [SQL] why vacuum

2005-10-26 Thread Scott Marlowe
On Wed, 2005-10-26 at 11:12, Tom Lane wrote: > Scott Marlowe <[EMAIL PROTECTED]> writes: > > On Tue, 2005-10-25 at 23:45, Kenneth Gonsalves wrote: > >> i was in a minor flame war with a mysql guy - his major grouse was that > >> 'I wouldnt commit mission critical data to a database that needs to b

Re: [SQL] Combining two SELECTs by same filters

2005-10-26 Thread Michael Fuhr
On Wed, Oct 26, 2005 at 06:16:13PM +0300, Volkan YAZICI wrote: > => SELECT > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND date_trunc('hour', dt) = '2005-10-25 21:00:00'), > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND date_trunc('h

Re: [SQL] broken join optimization? (8.0)

2005-10-26 Thread chester c young
> Tom Lane <[EMAIL PROTECTED]> wrote: >> Michael Fuhr <[EMAIL PROTECTED]> writes: > > On Tue, Oct 25, 2005 at 04:56:11PM -0700, chester c young wrote: > >> in php (for example) it's frequently nice to get the structure of > >> table without any data, > > > Have you considered "SELECT * FROM mytabl

Re: [SQL] why vacuum

2005-10-26 Thread Tom Lane
Scott Marlowe <[EMAIL PROTECTED]> writes: > On Tue, 2005-10-25 at 23:45, Kenneth Gonsalves wrote: >> i was in a minor flame war with a mysql guy - his major grouse was that >> 'I wouldnt commit mission critical data to a database that needs to be >> vacuumed once a week'. So why does pg need vacu

Re: [SQL] why vacuum

2005-10-26 Thread Jan Wieck
On 10/26/2005 11:19 AM, Scott Marlowe wrote: On Tue, 2005-10-25 at 23:45, Kenneth Gonsalves wrote: hi, i was in a minor flame war with a mysql guy - his major grouse was that 'I wouldnt commit mission critical data to a database that needs to be vacuumed once a week'. So why does pg need vacu

Re: [SQL] why vacuum

2005-10-26 Thread Scott Marlowe
On Wed, 2005-10-26 at 11:09, Jan Wieck wrote: > On 10/26/2005 11:19 AM, Scott Marlowe wrote: > > > On Tue, 2005-10-25 at 23:45, Kenneth Gonsalves wrote: > >> hi, > >> i was in a minor flame war with a mysql guy - his major grouse was that > >> 'I wouldnt commit mission critical data to a database

Re: [SQL] Combining two SELECTs by same filters

2005-10-26 Thread Scott Marlowe
On Wed, 2005-10-26 at 10:16, Volkan YAZICI wrote: > => SELECT > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND date_trunc('hour', dt) = '2005-10-25 21:00:00'), > -> (SELECT count(id) FROM sales > -> WHERE id = 2 > -> AND date_trunc('hour', dt) =

Re: [SQL] select best price

2005-10-26 Thread Gary Stainburn
On Wednesday 26 October 2005 4:21 pm, Gary Stainburn wrote: > Hi folks > > I've got a table holding item code(cs_id), supplier a/c (co_id) , and > price (cs_price). > > How can I select the rows containing the lowest price for each item > code? > > I've tried various forms of min() etc and know it

Re: [SQL] why vacuum

2005-10-26 Thread Scott Marlowe
On Tue, 2005-10-25 at 23:45, Kenneth Gonsalves wrote: > hi, > i was in a minor flame war with a mysql guy - his major grouse was that > 'I wouldnt commit mission critical data to a database that needs to be > vacuumed once a week'. So why does pg need vacuum? Oh man oh man. After reading the ar

[SQL] Combining two SELECTs by same filters

2005-10-26 Thread Volkan YAZICI
Hi, I've a table like: => SELECT dt FROM sales WHERE id = 2; dt 2005-10-25 21:43:35.870049 2005-10-25 21:43:36.254122 2005-10-25 21:43:36.591196 2005-10-25 21:43:36.893331 2005-10-25 21:43:37.265671 2005-10-25 21:43:37.688186 2005-10-25 22:25:35.2131

[SQL] select best price

2005-10-26 Thread Gary Stainburn
Hi folks I've got a table holding item code(cs_id), supplier a/c (co_id) , and price (cs_price). How can I select the rows containing the lowest price for each item code? I've tried various forms of min() etc and know it must be simple but I'm stumped. Gary -- Gary Stainburn This email do

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Stephan Szabo
On Wed, 26 Oct 2005, Mario Splivalo wrote: > Consider this function: > > CREATE OR REPLACE FUNCTION php_get_subfield_data_repeating(int4, > "varchar") > RETURNS SETOF "varchar" AS > $BODY$ > DECLARE > aRecordID ALIAS FOR $1; > aSubFieldId ALIAS FOR $2; > > returnValue record; >

Re: [SQL] why vacuum

2005-10-26 Thread Scott Marlowe
On Tue, 2005-10-25 at 23:45, Kenneth Gonsalves wrote: > hi, > i was in a minor flame war with a mysql guy - his major grouse was that > 'I wouldnt commit mission critical data to a database that needs to be > vacuumed once a week'. So why does pg need vacuum? The absolutely funniest thing about

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Tom Lane
Mario Splivalo <[EMAIL PROTECTED]> writes: > biblio3=# select * from php_get_subfield_data_repeating(1,'606a'); > php_get_subfield_data_repeating1 > -- > (Anđeli) > (ofsajd) > (2 rows) > I have return values in parentheses. You're getting bit by plpgsql's perha

Re: [SQL] pl/* overhead ...

2005-10-26 Thread Jan Wieck
PL/pgSQL is as *internal* as for example PL/Tcl. The two are actually pretty similar and I would expect them to perform similar, if one knows what and how he does. PL/pgSQL is an external shared object, loaded on call of the first func per backend. Same for PL/Tcl. PL/pgSQL takes pg_proc.pro

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Mario Splivalo
On Wed, 2005-10-26 at 08:54 -0400, Sean Davis wrote: > > Now, when I do this: > > > > biblio3=# select * from php_get_subfield_data_repeating(1,'606a'); > > php_get_subfield_data_repeating1 > > -- > > (Anđeli) > > (ofsajd) > > (2 rows) > > Does: > > select * from

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Sean Davis
On 10/26/05 8:38 AM, "Mario Splivalo" <[EMAIL PROTECTED]> wrote: > Consider this function: > > CREATE OR REPLACE FUNCTION php_get_subfield_data_repeating(int4, > "varchar") > RETURNS SETOF "varchar" AS > $BODY$ > DECLARE > aRecordID ALIAS FOR $1; > aSubFieldId ALIAS FOR $2; > > returnValue recor

[SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Mario Splivalo
Consider this function: CREATE OR REPLACE FUNCTION php_get_subfield_data_repeating(int4, "varchar") RETURNS SETOF "varchar" AS $BODY$ DECLARE aRecordID ALIAS FOR $1; aSubFieldId ALIAS FOR $2; returnValue record; subFieldNumber char(3); subFieldLetter char

Re: [SQL] SETOF RECORD RETURN VALUE

2005-10-26 Thread Sean Davis
On 10/26/05 6:34 AM, "Christian Paul B. Cosinas" <[EMAIL PROTECTED]> wrote: > Hi I am having some problem with function that returns SETOF RECORD > > Here is my function: > > CREATE OR REPLACE FUNCTION test_record(text) > RETURNS SETOF RECORD AS > $BODY$ > > > DECLARE > p_table_name ALIAS FOR

[SQL] SETOF RECORD RETURN VALUE

2005-10-26 Thread Christian Paul B. Cosinas
Hi I am having some problem with function that returns SETOF RECORD Here is my function: CREATE OR REPLACE FUNCTION test_record(text) RETURNS SETOF RECORD AS $BODY$ DECLARE p_table_name ALIAS FOR $1; temp_rec RECORD; v_query text; BEGIN v_query = 'SELECT * FROM ' || p_table_name; FOR temp_

Re: [SQL] pl/* overhead ...

2005-10-26 Thread Marc G. Fournier
On Wed, 26 Oct 2005, Michael Fuhr wrote: On Wed, Oct 26, 2005 at 12:58:13AM -0300, Marc G. Fournier wrote: Does anyone know of, or have, any comparisions of the overhead going with something like pl/perl or pl/php vs using pl/pgsql? Benchmark results will probably depend on the type of proces

Re: [SQL] converting epoch to timestamp

2005-10-26 Thread Stef
Rajesh Kumar Mallah mentioned : => Can anyone tell me how to convert epoch to timestamp ? => => ie reverse of : => => SELECT EXTRACT( epoch FROM now() ); => +--+ => |date_part | => +--+ => | 1130317518.61997 | => +--+ Here is one way (In m

Re: [SQL] converting epoch to timestamp

2005-10-26 Thread A. Kretschmer
am 26.10.2005, um 14:35:51 +0530 mailte Rajesh Kumar Mallah folgendes: > Hi, > > Can anyone tell me how to convert epoch to timestamp ? > > ie reverse of : > > SELECT EXTRACT( epoch FROM now() ); > +--+ > |date_part | > +--+ > | 1130317518.61997 | > +---

Re: [SQL] converting epoch to timestamp

2005-10-26 Thread Richard Huxton
Rajesh Kumar Mallah wrote: Hi, Can anyone tell me how to convert epoch to timestamp ? ie reverse of : SELECT EXTRACT( epoch FROM now() ); I'd start with either Google or the manuals. http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html Scroll down to the section on "epoc

[SQL] converting epoch to timestamp

2005-10-26 Thread Rajesh Kumar Mallah
Hi, Can anyone tell me how to convert epoch to timestamp ? ie reverse of : SELECT EXTRACT( epoch FROM now() ); +--+ |date_part | +--+ | 1130317518.61997 | +--+ (1 row) Regds mallah. ---(end of broadcast)--

Re: [SQL] broken join optimization? (8.0)

2005-10-26 Thread Richard Huxton
chester c young wrote: in php (for example) it's frequently nice to get the structure of a table without any data, ie, pull a single row with each attribute's value is null. I use the query (dual is a table of one row ala Oracle): select m.* from dual left join mytable m on( false ); Out of c

Re: [SQL] automatic update or insert

2005-10-26 Thread Patrick JACQUOT
tobbe wrote: Hi. I have a little problem. In a system of mine i need to insert records into table [tbStat], and if the records exist i need to update them instead and increase a column [cQuantity] for every update. I.e. the first insert sets cQuantity to 1, and for every other run cQuantity i

Re: [SQL] why vacuum

2005-10-26 Thread Kenneth Gonsalves
On Wednesday 26 Oct 2005 11:52 am, Bath, David wrote: >   > This guy is not worth arguing with. > D'Accord! thanks all for the clarification. in case anyone is interested in the original conversation it is here: http://ebergen.net/wordpress/?p=83 -- regards kg http://www.livejournal.com/users/

Re: [SQL] why vacuum

2005-10-26 Thread Tom Lane
"Bath, David" <[EMAIL PROTECTED]> writes: > ... Note that Sybase/MS-SQL's > check constraint model asserts the constraint BEFORE the trigger, which > discourages you from attempting to check and handle meaning of data! Er, doesn't PG do it that way too? regards, tom lane

Re: [SQL] pl/* overhead ...

2005-10-26 Thread Michael Fuhr
On Wed, Oct 26, 2005 at 12:58:13AM -0300, Marc G. Fournier wrote: > Does anyone know of, or have, any comparisions of the overhead going with > something like pl/perl or pl/php vs using pl/pgsql? Benchmark results will probably depend on the type of processing you're doing. I'd expect PL/pgSQL t