Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best way to move data to history.
Message
 
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00796896
Message ID:
00797494
Views:
24
Lynda,

Here's one code fragment:
? datetime(), "inserting " + pcTable
glZapOk = glZapOk and ;
   ( oSystem.RunSQL( "insert into " + pcTable + " select * from imptemp.." + pcTable ) > 0 )

? datetime(), "deleting " + pcTable
glZapOk = glZapOk and ;
   ( oSystem.RunSQL( "delete from imptemp.."  + pcTable ) > 0 )
the imptemp tables are BCP'd into we basically don't give a rip about the logs on that database. then the above insert/delete is run to move the data from the imptemp database to the prod db.

More surgical moves like what you are wanting to do gets done like this:
lcWhere = " where callno in ( select callno from #Loadable )" && enforce the same where clause for the next several SQLs

llDeleteOk = llDeleteOk and ( this.RunSQL( ;
   "insert into intcall" +;
      " select * from impintcall" + lcWhere ) > 0 )

llDeleteOk = llDeleteOk and ( this.RunSQL( ;
   "insert into response" +;
      " select * " + ;
      "    from impresponse" + lcWhere ) > 0 )

if ( llDeleteOk )
   this.RunSQL( "delete from impintcall" + lcWhere )
   this.RunSQL( "delete from impresponse" + lcWhere )
endif
#Loadable contains the PK vaules for the rows that are being moved by the process.

>Thanks David. This is very useful information. I'm not happy about non-logged activity so will move BCP to the bottom of the list of options
>
>I'm curions about the method described in your second paragraph. Could you elaborate please. Specifically, how do you do the inserts? What command do you use to truncate? In this case, a set of business rules are used to determine which orders are ready to archive. They won't be consecutive so I'm not sure that truncate, as I understand it, will work. I insert the PK for the "completed" records into a SQL table with a single field. This is used to drive the monthly close process so that the parent, all children and data from all tables referenced as a FK are copied as well.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform