Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Rob Vleeschhouwer
  Where is Rob Vleeschhouwer?
 Leeuwarden
 Netherlands
 Rob Vleeschhouwer
 To: Borislav Borissov
  Where is Borislav Borissov?
 Sofia
 Bulgaria
 Borislav Borissov
 Tags
Subject: RE: Append blank in SQL View
Thread ID: 104590 Message ID: 104593 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Thursday, August 17, 2006 11:54:47 PM         
   


> > Hi,
> >
> > The problem has changed. I will follow the advice from Boris and Marcia and make
> > a view with an identity column. But.... in that SQL view
> >
> > 1. The user must be able to make new, empty records in that view. For each
> > orderline at least one record.
> > 2. In each new record the identity column must filled with a, lets say numeric,
> > string. Increased by 1 for each new record.
> >
> > Also in case of changing an order it must be possible for the user to make new records.
> >
> >
> > Is that possible? I don't think so, but who knows.
> >
> >
> > Rob.

>
> Yes it is.
> First APPEND as many records as you want BEFORE TableUpdate the view. DO NOT touch IDENTITY field. When you want to send updates back to SQL Server do something like:
>
> IF NOT TABLEUPDATE(1, .t., [ViewAlias])
>    AERROR(laError)
>    MessageBox([Update is not successful ] +laError[1,2])
> ENDIF
> ** To get all new Identity values
> ** If you want to speed this up check if you have some new records
> ** and then requery. if you don't have new records you don't need this line
> REQUERY([ViewAlias])
> 

>
>
Hi Boris,

You are very active! But you have given me the right idea. I have done it a little different but it works fine now! The keyword was "REQUERY"

I have done this:

**procedure test

PARAMETERS id_nr && cust_id
nmax=0
USE orderreg!orderform ALIAS orderform
COUNT TO a
IF A>0
replace ALL cust_id WITH id_nr && for an existing order
GO top
ENDIF

ON KEY LABEL ctrl+ins do new_rec && Will be a commandbutton on a form

BROWSE && only for test

=tableupdate(.t.)


PROCEDURE new_rec && This proc comes in the click event from button

SELECT order && base table
nmax=MAX(nmax,key)
APPEND BLANK
replace key WITH nmax+1
replace cust_id WITH id_nr
REQUERY("orderform")
**************************
Of course I will implement your error handling

Thanks a lot Boris,

Rob


> Borislav Borissov
>
>


ENTIRE THREAD

Append blank in SQL View Posted by Rob @ 8/17/2006 11:03:42 PM
RE: Append blank in SQL View Posted by Borislav Borissov @ 8/17/2006 11:22:56 PM
RE: Append blank in SQL View Posted by Rob @ 8/17/2006 11:54:47 PM