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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to execute SQL commands in dBase V

Status
Not open for further replies.

jeffronsave

IS-IT--Management
Nov 27, 2002
2
SG
Hi All,
I'm a beginner in Dbase. I would to execute some SQL commands with my program.

Method Tried:
SET SQL ON
USE MYDATA.dbf
SELECT * FRMO MyDATA.DBF
***ERROR MSG PROMPTS SQL SYNTAX ERROR***

i understand from manuals that i hav to turn my dbf files into table before i could execute SQL commands which i'm unable to.

Lastly, i hope someone out there would guide me through out the steps...My situation is that I only have DBF files.

Thanx.
 
SELECT * FRMO ..... is going to get you an SQL error on any platform. Try SELECT * FROM ......

If this is typo doesn't actually exist in your code then I'm wondering if you have to describe an output in your SELECT statement (I'm not a DBase IV/V user). for example SELECT * FROM MyDATA.DBF INTO TABLE <tablename> (or CURSOR or ARRAY or ??)

 
HI 1oldfoxman,

Thanks for your advise. But its still not working..Btw &quot;frmo&quot; is my typo mistake.

Code Tried.
set sql on
use mydata.dbf
select * from mydata into table mydata1
**Error Message : SQL Syntax error***
Should the table mydata1 be existing table with the same structure with my mydata.dbf or it is temporary table generated out after the code has been executed?
In my case, there's no existing mydata1 table in my directory?
Is there any way to import my information from mydata.dbf into mydata1 table?


Thanks.
Sorry for all the trouble.
 
I'm hoping a dBAseV user will spot your post and help us out, as I'm basing my comments on other platforms (Foxpro, Visual FoxPro specifically) although the SQL syntax should be very, very similar.

Here's my next suggestion: leave out the USE statement. SQL SElECTs in FoxPro don't require the USE to open the table. Although doing so and executing a SELECT doesn't result in an SQL error, I'm wondering if dBaseV locks the table with the USE thus preventing the SELECT from happening (I don't think this is the problem, but it's the next logical troubleshooting step.) Also I'm not familiar with the SET SQL ON command ..... this may be causing a problem with the USE. Try eliminating the USE and see what happens.

Dennis
 
Sorry I forgot to answer you question about the pre-existence of the new table. The table created by the SELECT should not already exist. If it does you should get a dialog box asking if you want to overwrite the existing table.

dennis
 
One more time. (I've got to learn to think more before I start typing.)

If you just need to make a duplicate of the MYDATA there is an easy way to do this.

USE MYDATA
COPY TO MYDATA1

This will create an exact replica of MYDATA in a new table MYDATA1. Understand that the mydata.dbf file IS the MYDATA table. Whether you do a SELECT * FROM MYDATA INTO TABLE MYDATA1, or use COPY, you get a new .dbf/table.

Dennis
 
Jeff,
what are you attempting to do with SQL in dBase (beyond queries)? There may be better ways to accomplish this task than using SQL from the prompt.
BKtechie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top