Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create table.

Status
Not open for further replies.

cmstforr

Technical User
Sep 8, 2004
20
GB
Hi I want to create a table within a method called MySetupStuff(). Can anyone help with the syntax.
Please let me know if i'm right or wrong on this occasion.

Table = setup.dbf
Field = xtra_text -> 50 Characters long

CREATE TABLE setup ;
(xtra_text c(50))

How would I index this?

Thanks and kind regards,

Tom
 
If you look at your VFP Help file you will confirm that your CREATE TABLE syntax is correct.

You index this table in the same manner as you would any other table.

After the CREATE TABLE, your new table is left Open Exclusively so you can merely SELECT it and perform your INDEX command. Again your VFP Help file can give you guidelines.

Good Luck,
JRB-Bldr
 
Hi, thanks for the feedback,

I have been looking on VFP help but just wanted some confirmation that I was going down the correct path.

I am a little confused however with indexing.

"SELECT it and perform your INDEX command" can you explain this idea a little more please.

Cheers,

Tom
 
In the VFP help file under "INDEX command" there are the following examples:

VFP said:
* Example 1
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE Customer && Open customer table
[highlight]INDEX ON company TO complist[/highlight]
CLEAR
DISPLAY STATUS

* Example 2
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE Customer && Open customer table
[highlight]INDEX ON SUBSTR(city,1,5) + SUBSTR(company,1,6) TO citycomp[/highlight]
CLEAR
DISPLAY STATUS

* Example 3
CLOSE DATABASES
OPEN DATABASE (HOME(2) + 'Data\testdata')
USE Customer && Open customer table
[highlight]INDEX ON address TAG address
INDEX ON company TAG company OF custcdx[/highlight]
CLEAR
DISPLAY STATUS

boyd.gif

[sub]craig1442@mchsi.com[/sub][sup]
"Whom computers would destroy, they must first drive mad." - Anon​
[/sup]
 
I will therefore use the following code within my method:

CREATE TABLE setup ; && Does the ";" have to be here?
(xtra_text c(50)) && Do I need a ";" hear?
INDEX ON setup TO xtra_text && && Do I need a ";" hear?

Cheers,

Tom
 
Tom,

If I may jump in ....

The semi-colons shown in the example are line continuation markers. You put the semi-colon at the end of the line to show that the command is continued on the next physical line. If you prefer, you are free to write the entire command on one line, without the semi-colons, but it is easier to read if you split it up.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thanks for the tip Mike. Have a good weekend

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top