Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need 2 distinct cursors using same view...HOW?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00170395
Message ID:
00170420
Views:
36
>Hello all, Happy Holidays.
>
>I am trying to do something very simple. I wish to clone a set of records from one table back into that same table, merely changing an ID (I am copying security rights from one user to another). I thought it would be simple, but with views it seems to be tougher than I thought. Here is how I would like to do it:
>
>Step 1. I already have a view up containing the rights for the current user on the screen.
>Step 2. Open a second cursor containing all the rights for a different user (the user I wish to copy from).
>Step 3. Check the second cursor to see if I even have to bother with a copy (there may not be any rights for the second user).
>Step 4. If there are rights to copy, delete all the rights forthe current user by selecting the original view and doing a DELETE ALL. Do a TABLEUPDATE() to commit the changes.
>Step 5. Go through the second cursor, SCATTER MEMVAR, select original cursor, APPEND BLANK, and then GATHER MEMVAR (I change the staff ID I want to be different in between the SCATTER and GATHER).
>Step 6. Commit theese new changes in the original cursor back to the database.
>
>The problem happens right off in Step 2. If my orginal cursor is called ResourceRights_View, and I do a
>
>USE ResourceRights_View AGAIN IN 0 ALIAS cCopy
>
>That works OK. I now essentially have the exact same data in two separate work areas. Great. I then set my view parameter appropriately (with the new staff ID), and do a:
>
>REQUERY('cCopy')
>
>Because I obviously need the cCopy cursor to contain the new data I want to copy. But curse it all, when cCopy gets requeried, so does my original ResourceRights_View. I don't want that?! How can I have two distinct cursors that both use the same view, and have different parameters? I cannot use a SELECT statement from the original view, as then I have no way of requerying it to get the new rights information. I suppose I could do a SELECT from the original cursor and scan through that to accomplish deletes, but that sure seems like a kludge, considering I already have a view with all the information I want to delete rigt that already.
>
>Any help or new ideas would be warmly appreciated...
>
>Later,
>Joe Kaufman
>jkaufman@encompas.com

I like the way you have described the problem. Both views will get requeried if you requery one of them. Simplest suggestion is to have two different views.
- Jayesh
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform