Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004

    Question Unanswered: [ V FoxPro] Sql Cursor problem

    I'm just beginning with Visual FoxPro my training course so i would like a little help about those lines.

    I've got a table named "table1" which contains my primarykey :
    idclient and some fields which contains strings : nomclient, departement.

    I would like to make a cursor so as to select the max idclient, increment it by 1 and then add a new line to table1 with this number as primarykey.

    It's not the quickest way to do but as i'm training myself before developping my application, i would like to accustom myself with a maximum of solutions for the future.

    Here is the code i got when i press my button:

    Create Cursor ident (idclient I(4))
    Append Blank

    &&this one is not accepted so i tried an other one bellow
    Insert into ident (idclient) values (Select max(idclient) from table1)

    && Here cant find ident when executing O_o neither if i replace ident with ident.idclient
    Insert into table1 (idclient) Values (ident)

    Edit: I've just tried this and it works as well

    Select (max(idclient)+1) from table1 into array res
    Insert into table1 (idclient,activite,nom) Values (res,"","")

    Question 2 : My views are not up to date while executing when i refresh it ... Why?
    Last edited by jeoff; 04-08-04 at 04:32.

  2. #2
    Join Date
    Mar 2004
    Insert into ident (idclient) values (Select max(idclient) from table1)
    pay attention, this form is avaible only on vfp8+

    I found out that the quickest way is to use the array (I normaly use vfp6),for example I should use:

    dimension aRes(3)


    select max(idclient)+1,"","" from table1 into array aRes

    insert into table1 from array aRes

    the init fase is necesary because if the table is empty it give you only a empty array...
    this way is usefull even when you have to insert more lines...

  3. #3
    Join Date
    Apr 2004


    thanks a lot

    I hope not to spend 1 hour finding documentation each time i need to write a querry .

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts