Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Code for Cursor Readwrite
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01057981
Message ID:
01057987
Views:
15
>Looking for ways to make my code more efficient or at least not as embarressing.
>
>1) have a VFP free table1.dbf. Want to select records from table1.dbf and then end up with a readwriteable cursor called table1.dbf. Currently I have the following sloppy lines of code.
>
>
>IF used("QM_cond")
>   USE IN qm_cond
>ENDIF
>USE qm_cond IN 0
>SELECT * FROM qm_cond into CURSOR temp READWRITE ;
>   WHERE f_query_id like qm_list.f_query_id+'%'
>USE IN qm_cond
>SELECT * FROM temp INTO CURSOR qm_cond readwrite
>USE IN temp
>SELECT qm_cond
>INDEX ON F_QUERY_ID TAG F_QUERY_ID
>SET ORDER TO TAG F_QUERY_ID
>
>
>

You don't have to use intermediate cursor here. You can do select from qm_cond into qm_cond. However, since qm_cond is a table, you better use a different name for your cursor to avoid confusion. Use c_gm_Cond as your name for the cursor. Then you can select from cursor to the same cursor if you don't need to use that table anymore.

>2) do some processing, then want to then update table1.dbf with the records from cursor table1. currently I am co
>
>SELECT * FROM qm_cond INTO CURSOR temp
>USE IN qm_cond
>USE c:\rt50vss\data\qm_data\qm_cond IN 0
>DELETE FROM qm_cond WHERE f_query_id like qm_list.f_query_id+'%'
>SELECT qm_cond
>APPEND FROM DBF('temp')
>USE IN temp
>
>
>
>Any suggestions are appreciated
>
>Brenda

You can use UPDATE command if you have the same amount of records and you just changed the records. If you did delete some records and added new records in your cursor, then you would have to delete and re-add, as you currently do.

Also you can use local views. However, the table must be a part of database.

Make sure your form works with the different name for your cursor than your table. If you do so, then all code will become easier to manage. Right now since you're using the same name for your table and your cursor you have to do all these compilcated steps...
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform