1_autoincrement_create.prg
上传用户:szlqfpcb
上传日期:2020-05-18
资源大小:5k
文件大小:1k
源码类别:

数据库系统

开发平台:

VFP

  1. ********************************************************************************
  2. * 1_AutoIncrement_Create.prg
  3. * Description: This program will show how to create a table that contains an
  4. * auto increment field.
  5. * Tip: You can use the Table Designer to create the sturucture of your tables.
  6. * There is a new data type choice in the drop-down called 
  7. * 'Integer(AutoInc)'.  You can also set the starting value and the 
  8. * increment value.
  9. ********************************************************************************
  10. #DEFINE CRLF CHR(13)+CHR(10)
  11. LOCAL lcStr as String
  12. LOCAL lnSelect as Integer
  13. * Save environment and erase auto increment table.
  14. lnSelect = SELECT()
  15. SELECT 0
  16. ERASE _AI_Table.dbf
  17. * Create Auto Increment table setting the 'iID' column as an auto increment field
  18. * with the starting value set to 1 and the increment value set to 1.
  19. CREATE TABLE _AI_Table FREE ;
  20. ( iID i AUTOINC NEXTVALUE 1 STEP 1, ;
  21.   CustName c(30))
  22. * Insert three records into the table.  You do not assign any values to the auto
  23. * increment field.
  24. INSERT INTO _AI_Table (CustName) VALUES ("Jane Smith")
  25. INSERT INTO _AI_Table (CustName) VALUES ("John Doe")
  26. INSERT INTO _AI_Table (CustName) VALUES ("Greg Jones")
  27. GO TOP
  28. * Browse the table.
  29. BROWSE NOWAIT
  30. lcStr = "Auto Increment Table created with the starting value set to 1 and" + ;
  31. " the increment set to 1"
  32. MESSAGEBOX(lcStr)
  33. * Restore environment.
  34. USE
  35. SELECT (lnSelect)
  36. RETURN