Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 10 of 10 total |
Updating account balance from transactions |
Fri, Mar 23 2007 1:05 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | I can get this far and generate the balances
select _fkAccounts , sum(_income) - sum(_expenditure) AS BAL from transactions join accounts on accounts._ID = transactions._fkaccounts where accounts._adjustor = 1 group by _fkaccounts but how do I put the result into the accounts table? In DBISAM I'd have probably used a script with a temporary memory table and then joined that to do the update. In ElevateDB I'm lost. Roy Lambert |
Fri, Mar 23 2007 1:36 PM | Permanent Link |
Dave M | I haven't done this in EDB but, wouldn't you do CREATE TABLE AS <queryexpression>, page 62
EDB sql manual? dave m >Roy Lambert wrote: >but how do I put the result into the accounts table? >In DBISAM I'd have probably used a script with a temporary memory table and then joined that to do the update. In ElevateDB I'm lost. |
Fri, Mar 23 2007 1:39 PM | Permanent Link |
Dave M | Or INSERT INTO <TableName> VALUES <QueryExpression>, page 91 EDB sql manual.
dave m |
Fri, Mar 23 2007 1:46 PM | Permanent Link |
Dave M | Oh, you are trying to update.
Maybe I should stop posting while I am behind. Looks like a CREATE PROCEDURE some variables may be needed. Dave M >Dave M wrote >Or INSERT INTO <TableName> VALUES <QueryExpression>, page 91 EDB sql manual. |
Fri, Mar 23 2007 2:01 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Dave
That was interesting Your final guess is right - I should have said I'm trying to UPDATE. Roy Lambert |
Fri, Mar 23 2007 3:10 PM | Permanent Link |
Dave M | >Roy Lambert wrote:
>That was interesting That was written in a hurry before going out. Basically, I hate reading other people's code, so mostly I ignore it, if possible. I only see an UPDATE using values in the manual so, it looks like an update with SELECT won't work. Besides a procedure with variables, why can't you do a "script" by reloading a query with each statement individually? That's why I suggested CREATE AS, for making a temp table. dave m |
Fri, Mar 23 2007 7:20 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< In DBISAM I'd have probably used a script with a temporary memory table and then joined that to do the update. In ElevateDB I'm lost. >> Something like this should work: UPDATE accounts SET Balance= (select sum(_income) - sum(_expenditure) AS BAL from transactions where transactions._fkaccounts=accounts._ID) WHERE accounts._adjustor = 1 -- Tim Young Elevate Software www.elevatesoft.com |
Sat, Mar 24 2007 6:09 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Dave
At this point ElevateDB doesn't support scripts I could do it with several lines of code but then I might as well do it mix'n'match with a combo of sql and navigational code. Roy Lambert |
Sat, Mar 24 2007 6:09 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
Interesting. I don't think it works because it nulls the _Balance column, and I don't think that's right Roy Lambert |
Mon, Mar 26 2007 10:42 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< Interesting. I don't think it works because it nulls the _Balance column, and I don't think that's right >> It's a bug. Essentially EDB is not setting up the linked columns properly when the sub-select isn't live. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, May 3, 2024 at 08:07 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |