Re: [SQL] Debet-Credit-Balance Calculation

2005-04-19 Thread Christopher Browne
Oops! [EMAIL PROTECTED] ("Muhyiddin A.M Hayat") was seen spray-painting on a wall: > everything is ok, but when record > 100 that query eat all my > cpu process and take a long time, i have wait for 3 mimutes > but query doesn't finish. (pgsql-8.0-1 running on Dual Xeon 2.8 and > 2GB of RAM)

Re: [SQL] Debet-Credit-Balance Calculation

2005-04-19 Thread Mihail Nasedkin
I think you forget FOREIGN KEY: transactions.trx_type_id -> trx_type.id MAMH> Dear All, MAMH> I have problem to calculation MAMH> balance from debet and credit. MAMH> my transaction table: ... MAMH> CREATE TABLE "public"."transactions" ( MAMH>   MAMH> "id" SERIAL, MAMH>   "trx_timestamptz" TI

Re: [SQL] trying to do an update a bit confused.

2005-04-19 Thread Jaime Casanova
On 4/19/05, Joel Fradkin <[EMAIL PROTECTED]> wrote: > > > > update tblcase set merchandisetotal = > > ( > > COALESCE(( SELECT sum(m.quantity::numeric * m.amount) AS merchandiseamount > >FROM tblmerchandise m > > WHERE m.caseid = tblcase.caseid AND m.clientnum::te

Re: [SQL] tsearch2

2005-04-19 Thread Oleg Bartunov
On Tue, 19 Apr 2005, Dan Feiveson wrote: Thanks Oleg! Did as you recommended: set_curcfg('default'); got new error running query containing: to_tsquery('advanced|tech'); rank(avectors,a2); ERROR: ExecMakeTableFunctionResult: expression is not a function call Past message board suggests this is a p

Re: [SQL] trying to do an update a bit confused.

2005-04-19 Thread Joel Fradkin
I am not updating 1 record. I have : WHERE m.caseid = tblcase.caseid AND m.clientnum::text = tblcase.clientnum::text) Which should do the aggregate on the record that is being updated (least as I understood it). It should update all record in case with either 0 if there are no merchandi

[SQL] Debet-Credit-Balance Calculation

2005-04-19 Thread Muhyiddin A.M Hayat
Dear All,I have problem to calculation balance from debet and credit.my transaction table:    id |    trx_timestamptz | account  | trx_type_id |   amount++--+-+-  3 | 2005-04-14 17:16:49+08 | 01.2010100.2 |

Re: [SQL] trying to do an update a bit confused.

2005-04-19 Thread KÖPFERL Robert
You're most probably missing a Where clause after the parentensis. see: -Original Message-From: Joel Fradkin [mailto:[EMAIL PROTECTED]Sent: Dienstag, 19. April 2005 16:06To: pgsql-sql@postgresql.orgSubject: [SQL] trying to do an update a bit confused. update tblcase  s

Re: [SQL] DateAdd function ?

2005-04-19 Thread Tom Lane
"Jeff Eckermann" <[EMAIL PROTECTED]> writes: > There is no "dateadd" function in PostgreSQL, but you can write your own > easily enough. The following should give you an idea of the logic you can > use: > jeck=# select current_date + cast('1 day' as interval); Alternatively, maybe you want to

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Jeff Eckermann
Forget that message. I need another cup of coffee! "Jeff Eckermann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Muhammad Nadeem Ashraf" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Hi, >> I am new user of PostGreSQL 8.0.1. While using it i faced following

Re: [SQL] DateAdd function ?

2005-04-19 Thread Jeff Eckermann
"Zlatko Matiæ" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I am currently migrating from MSDE to PostgreSQL and have to rewrite the >function that is calculating next date of sampling... > In MSDE there is a DateAdd function. I can't find the appropriate function > in postgre.

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Jeff Eckermann
"Muhammad Nadeem Ashraf" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > I am new user of PostGreSQL 8.0.1. While using it i faced following issue. > As SQL is Case insensetive Language So the Uper or Lower cases are not > significant. But while using the database there is pr

[SQL] trying to do an update a bit confused.

2005-04-19 Thread Joel Fradkin
update tblcase  set merchandisetotal = ( COALESCE(( SELECT sum(m.quantity::numeric * m.amount) AS merchandiseamount    FROM tblmerchandise m   WHERE m.caseid = tblcase.caseid AND m.clientnum::text = tblcase.clientnum::text), 0.0) )   I tried running the above and it

Re: [SQL] "Money" Data Type Problem

2005-04-19 Thread Stephan Szabo
On Tue, 19 Apr 2005, sreejith s wrote: > Hai friends, > I have a field with data type 'Money' with my table. I select this > field a select query and displays the same in a textbox. While doing > this a dollar ($) is prefixed to the actual table value. How to avoid > this symbol so as to display

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Andrew Sullivan
On Tue, Apr 19, 2005 at 11:59:58AM +0200, KÖPFERL Robert wrote: > Postgres has the weird behavour to compare identifies case sensitive BUT to > downcast any non-quoted identifier inside an SQL statement. > So it is reccomended to just use lower case (for readability) Or never double-quote identi

Re: [SQL] can a function return a virtual table?

2005-04-19 Thread Bruno Wolff III
On Tue, Apr 19, 2005 at 09:34:43 +0200, KÖPFERL Robert <[EMAIL PROTECTED]> wrote: > That was a nice answer - rather compleete. > > However at least I am questioning myself for a long time about what happens > if one does a select from a SRF. The function may return millions of records > (i.e. se

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Reinoud van Leeuwen
On Tue, Apr 19, 2005 at 02:48:46AM -0700, Muhammad Nadeem Ashraf wrote: > Hi, > I am new user of PostGreSQL 8.0.1. While using it i faced following > issue. As SQL is Case insensetive Language So the Uper or Lower cases > are not significant. But while using the database there is problem. > If i

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Richard Huxton
Muhammad Nadeem Ashraf wrote: Hi, I am new user of PostGreSQL 8.0.1. While using it i faced following issue. As SQL is Case insensetive Language So the Uper or Lower cases are not significant. But while using the database there is problem. If i Create new Table with name (tblstudent) then upon SQ

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Sean Davis
On Apr 19, 2005, at 5:48 AM, Muhammad Nadeem Ashraf wrote: Hi, I am new user of PostGreSQL 8.0.1. While using it i faced following issue. As SQL is Case insensetive Language So the Uper or Lower cases are not significant. But while using the database there is problem. If i Create new Table with n

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Thomas Kellerer
On 19.04.2005 11:48 Muhammad Nadeem Ashraf wrote: > Hi, > I am new user of PostGreSQL 8.0.1. While using it i faced following > issue. As SQL is Case insensetive Language So the Uper or Lower cases > are not significant. But while using the database there is problem. > If i Create new Table with

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread KÖPFERL Robert
Postgres has the weird behavour to compare identifies case sensitive BUT to downcast any non-quoted identifier inside an SQL statement. So it is reccomended to just use lower case (for readability) -Original Message-From: Muhammad Nadeem Ashraf [mailto:[EMAIL PROTECTED]Sent: D

[SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Muhammad Nadeem Ashraf
Hi, I am new user of PostGreSQL 8.0.1. While using it i faced following issue. As SQL is Case insensetive Language So the Uper or Lower cases are not significant. But while using the database there is problem. If i Create new Table with name (tblstudent) then upon SQL queries it is fine to use Sele

Re: [SQL] Getting the output of a function used in a where clause

2005-04-19 Thread PFC
Thanks Tom and Rod. There are indeed several additional conditions on the "real" query which prune the search space (I formulate a quick search box and filter on Lat/Lon's within the box). Since my user interface limits the search to a 30 mile radius, there are at most 81 results (in New York ci

Re: [SQL] can a function return a virtual table?

2005-04-19 Thread KÖPFERL Robert
That was a nice answer - rather compleete. However at least I am questioning myself for a long time about what happens if one does a select from a SRF. The function may return millions of records (i.e. select * from x where a>1). Is this data streamed through the query process or does postgres cre

[SQL] "Money" Data Type Problem

2005-04-19 Thread sreejith s
Hai friends, I have a field with data type 'Money' with my table. I select this field a select query and displays the same in a textbox. While doing this a dollar ($) is prefixed to the actual table value. How to avoid this symbol so as to display the actual value only. Any format change needed in

Re: [SQL] User Defined Functions Errors

2005-04-19 Thread KÖPFERL Robert
Have a try with RAISE NOTE or RAISE EXCEPTION keep in mind that exceptions should be exceptional. So a good idea of whether to use them is to ask 'Do I expect such error' or 'is an explicit error useful for the caller'. I'ts often better to just return an empty relation |-Original Message-