I have never used Foxpro before until now. I am able to create a set of stored procedures to create two new tables from existing tables for reporting purposes in a DBC. I am using Visual FoxPro 9.0 for working.
What I am trying to achieve: I want the client to execute a stored procedure which will create the two new tables in the same directory (or path where this database currently resides).
Issue: The tables are generated successfully but the physical files reside in the wrong path. For example: there is a DBC in Z:\DATA\ABC\ and all the tables are in this path. I want to create the two new tables for this database and make sure the physical files are created under the same folder.
Attempted: I have been able to get the client to select the path and capture it in local variable within the stored procedure. I have tried SET DEFAULT TO, SET PATH TO, CD commands but I always geth INVALID PATH OR FILENAME.
Please help me. I have spent hours on this but no leads so far.
Thanks

Create New tables in existing DBC in specified directory or path
Steven McCarty
>> Attempted: I have been able to get the client to select the path and capture it in local variable within the stored procedure. I have tried SET DEFAULT TO, SET PATH TO, CD commands but I always geth INVALID PATH OR FILENAME.
If there are spaces in the path, or file names, then you must surround the path with quotes:
SET DEFAULT TO
C:\DOCUMENTS AND SETTINGS\ && Invalid Path or file nameSET DEFAULT TO
"C:\DOCUMENTS AND SETTINGS\" && Changes default directorySET DEFAULT TO "'" + GETDIR() + "'" && Gets the directory and sets it as default
lcDir = GETDIR()
SET DEFAULT TO ([']+lcDir+[']) && Changes to default directory
GlenAtMotorola
Andy -
Never mind - I figured it out. This syntax below worked for me.
SET DEFAULT TO (variablename)
Thanks
Hugo Sanchez
First, unless you want to persist the information, there is no reason to create a table a report will function just as well against a VIEW or even just a Cursor.
Have the stored procedure create a cursor and populate it and then there is no issue - VFP cleans up cursors (which are always local to the user and opened exclusive - so that you can index them) when it closes down.
Alternatively look up "Local Views" in the help file - they provide an even simpler way of getting data than a stored procedure...
Michael_Giagnocavo
If drive and folders exists the command:
SET DEFAULT TO Z:\DATA\ABC
works...
Oleg Krupnov
You do NOT need to change your default/path etc to create a table in a specific folder. Just fully qualify the table name:
create table ("z:\data\abc\myTable") ( ... )
misexpert
Andy -
Thanks for your responses. I am able to run this command (highlight selection in the Stored Procedures window) successfully.
SET DEFAULT TO ("'"+pathname+"'")
But the same syntax fails when I run the stored procedure as a whole. I dont understand whats wrong. Do you have any ideas
Thanks