Re: Select - SQL vs. SUM

From: Fred Taylor (ftaylor_at_mvps.org!REMOVE)
Date: 03/21/05

  • Next message: Paul Pedersen: "Re: buffering & transactions"
    Date: Mon, 21 Mar 2005 14:24:12 -0700
    
    

    If you have to use an earlier version of VFP earlier than 9, you can process
    the commands from the table in a SCAN loop and add them to a cursor and use
    the cursor as the control source for those fields.

    -- 
    Fred
    Microsoft Visual FoxPro MVP
    "Subhash Chopra" <s.chopra@rogers.com> wrote in message 
    news:5f2dneR2GKB1kqLfRVn-1w@rogers.com...
    > But I am using VFP 6.0. What are the options in this case.
    >
    > Subhash.
    >
    > "Anders Altberg" <x_pragma@telia.com> wrote in message
    > news:#dNIoxNLFHA.656@TK2MSFTNGP14.phx.gbl...
    >> SQL SELECT doesn't read the buffered data in the Grid, it reads direct
    > from
    >> disk. In VFP9 you can SET SQLBUFFERINFG ON to change this defaut. You can
    >> also force VFP to read from the buffer with a new clause in the SQL
    > SELECT
    >> command, SELECT <field> WITH BUFFERING=.T.  FROM Table.
    >> The SELECT command doesn't move the record pointer in the grid's record
    >> source. The3 SUM command does.
    >> -Anders
    >>
    >> "Subhash" <Subhash@discussions.microsoft.com> wrote in message
    >> news:38914C6F-DFD6-44D8-A038-98BE9564D721@microsoft.com...
    >> > I have a grid whose recordsource is a table named _payments. In this
    > table
    >> > there is a column in which user enters the amount of payment received
    > for
    >> the
    >> > respective invoice. This column is no. 8 in the grid and is the last
    >> column.
    >> > The table contains outstanding invoices for a particular customer.
    >> >
    >> > In the lostfocus event of the the column, I placed the following code:
    >> >
    >> > Thisform.txtUnused.refresh
    >> >
    >> > The txtUnused is a text box that displays the unused portion of the
    > total
    >> > payment received from that customer. The Text Box has its controlsource
    >> set
    >> > to nBalance. I place the following code in Refresh Event of txtUnused:
    >> >
    >> > Select _Payments
    >> > sum Thispmt to TotalPmt
    >> > nBalance=nPayment-TotalPmt && nPayment is the total payment received.
    >> > Select Customer
    >> >
    >> > This code works fine the  way it is. However, when I change the code to
    > a
    >> > SELECT-SQL statement, I run into a weird behaviour. The SQL code reads:
    >> >
    >> > Select sum(Thispmt) from _payments into array TotalPmt
    >> > nBalance=nPayment-TotalPmt
    >> >
    >> > With the SQL statement when I change the value in ThisPmt column for 
    >> > the
    >> > first time and hit Enter key, the value in txtUnused is updated and the
    >> focus
    >> > moves the 1st column in the grid which is a Checkbox control. Now, 
    >> > while
    >> > staying on the same row if I navigate to the last column and change the
    >> value
    >> > again, the txtUnused doesn't get updated. Except for the first time, no
    >> > matter how many times I change the value in the ThisPmt column, the
    >> txtUnused
    >> > stays the same as the first time value. When I press down arrow key and
    >> then
    >> > up arrow again, then the value gets updated.
    >> >
    >> > With the SUM statement, it works perfectly fine. As soon the value is
    >> > changed in that column and I press Enter Key, the value in txtUnused
    > gets
    >> > updated and focus moves to 2nd column in stead of 1st column as was the
    >> case
    >> > when I use Select SQL statement.
    >> >
    >> > Can someone please explain this to me why it is happening the way it 
    >> > is.
    > I
    >> > would prefer to use the SQL SELECT in stead of SUM statement.
    >> >
    >> > Thanks a lot in advance.
    >> >
    >> > --
    >> > Subhash Chopra
    >> > VFP 6.0, WIN XP PRO
    >> >
    >> >
    >> >
    >>
    >
    > 
    

  • Next message: Paul Pedersen: "Re: buffering & transactions"

    Relevant Pages

    • Re: Manuel for ODBC
      ... Are you creating a VFP view of the SQL data or a new view on your MySQL ... For a VFP view look at the Create SQL View command. ... your MySQL database you'll need to pass the Create View command through as ...
      (microsoft.public.fox.programmer.exchange)
    • Re: remote views index
      ... > a remote view is in the end nothing else than a sql SELECT command, ... > If the queried table has got some indexes, the backend database itself ... > Using VFP data as a backend for VFP remote views, ...
      (microsoft.public.fox.helpwanted)
    • Re: Total to ... is ok?
      ... recs using 99.5 as the appended value for that column. ... When I ran the total to command, VFP created a column defined as n ... Find out the objective of that program line and do it with SQL. ...
      (microsoft.public.fox.programmer.exchange)
    • Re: append command
      ... Using VFP 6, this is the command line I used: ... >You can use SQL to do what you want: ... >Eric den Doop ...
      (microsoft.public.fox.helpwanted)
    • Re: COBOL stored procedure for DB2
      ... Regarding how you precompile the app, you must specify target mfcob to db2 prep, rather than target ibmcob. ... Have you also confirmed that, prior to executing the CALL statement, the host variables specified within the client app have the appropriate values? ... MODIFIES SQL DATA ... confirm the cob command used for creating the SP module. ...
      (comp.lang.cobol)