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

trying to extract data from 2 db files and insert into another 1

Status
Not open for further replies.

joetrogdon

Technical User
Joined
Feb 20, 2004
Messages
4
Location
US
OK this is probably so basic it's laughable but here goes:

I have 2 databases that are indexed and have 1 field that is the same (orderno). I am trying to compare the field orderno in the databases and extract all the fields where the orderno values match. The SEEK function is giving me fits so I thought I would ask here. My code is as follows, no laughing please...

USE e:\ceonline\testdata\shipdata.dbf in 2
USE e:\ceonline\testdata\ordmastr.dbf in 1
select 1
set order to 1
torderno = orderno
SEEK(torderno[ ,2])
IF FOUND( )
DISPLAY FIELDS orderno
ENDIF

The help system in Foxpro showed the SEEK function syntax as it's written above, but it gives me an error "Missing )". If I understand correctly the SEEK function will look in another work area if it's specified, which is where the 2 comes from in the [ ].

Anyway, if anything I've said is unclear post a question and I'll try to word it better. Thanks in advance.
 
I think this is what you need:

SELECT * FROM ordmastr a, shipdata b WHERE a.orderno = b.orderno

 
The square brackets found in help items are optional parameters you can use in the function.
What the help is saying in its example:
SEEK(<expr>[,<expN> | <expC>])

Is that you can use a character expression - <expr> for your seek, like you are using: torderno.
But the rest of the statement SEEK(<expr>[,<expN> | <expC>]), means you can tell Fox to perform the seek in a work area other than the currently selected one, specified either by the other work area IF SEEK( torderno, 2), or the other work area's alias, for instance 'ordmastr'.
In that case, the line would read IF SEEK(torderno, 'ordmastr') for example, if you were SEEKing torderno in the 'ordmastr' table.

Since you're doing the seek in the current work area, you don't need the optional parameter, so you can just use SEEK(torderno).

However, one other thing to point out is there is a SEEK() function, and a SEEK command. The difference being the parenthesis. The SEEK() function returns .T. or .F. so you don't need to use FOUND() after it.
The correct syntax for each is as follows:
Code:
    SEEK torderno
    IF FOUND( )
        DISPLAY FIELDS orderno
    ENDIF
-or-
Code:
    IF SEEK(torderno)
        DISPLAY FIELDS orderno
    ENDIF

Try those out and see how it behaves.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top