Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Seeking a brilliant idea to replace NextID() function
Message
From
21/01/2008 14:36:08
Suhas Hegde
Dental Surgeon
Sirsi, India
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Miscellaneous
Thread ID:
01283680
Message ID:
01283770
Views:
19
>>hi,
>>You didnt understand what i was saying,
>>
>>SQLSETPROP(oApp.oVar.sqlHandler,"Transactions",DB_TRANSMANUAL)
>>Would need SQlcommit() and sqlrollback() to be effictive
>>
>>Would SQLEXEC(handle,"Commit Transaction") alone be more than sufficient ?
>>
>>Try it with the codes i posted.
>>
>>thanx,
>>Suhashegde
>>
>>P.S.: Just saw that you were using both. Both start at the same place and end at the smae place. No updates are sent to server in between them. So sqlsetprop would be a unnecessary call. And Also would increment @@Trancount unnecessarily
>
>No updates, ha?
>:-)
>Sorry, I can't resist.
>You didn't use Buffering. So By Deafult the cursor uses RowBuffering. When you chnage Record pointer the record IS updated.Try this:
>
>lccon = [DRIVER=SQL Server Native Client 10.0;Server=nagaveni\sql2008;Trusted_Connection=Yes]
>han = SQLSTRINGCONNECT(lccon)
>
>SQLEXEC(han,"create table #foo (f1 int,f2 char(20))")
>SQLEXEC(han,"select * from #foo ",'foo')
>CURSORSETPROP([Buffering], 5, [Foo])
>
>CURSORSETPROP("Tables","#foo","foo")
>CURSORSETPROP("UpdateNameList", "f1 #foo.f1, f2 #foo.f2")
>CURSORSETPROP("KeyFieldList", "F1")
>CURSORSETPROP("UpdatableFieldList", "f1,f2")
>CURSORSETPROP("SendUpdates", .T.)
>
>FOR m.xi = 65 TO 90
>   INSERT INTO foo VALUES (m.xi,REPLICATE(CHR(m.xi),10))
>ENDFOR
>
>SQLSETPROP(han,"Transactions",2)
>SQLEXEC(han,"BEGIN TRANSACTION")
>
>IF TABLEUPDATE(.t.,.t.,"foo",fooerror)
>   Messagebox("records with Begin transaction and SQLSETprop transaction")
>   SQLEXEC(han,"select * from #foo ",'foo1')
>   brow
>
>   SQLSETPROP(han,"Transactions",1)
>   Messagebox("records with Begin transaction ")
>   SQLEXEC(han,"select * from #foo ",'foo1')
>   brow
>
>   SQLEXEC(han,"ROLLBACK TRANSACTION")
>   Messagebox("records with ROLLBACK TRANSACTION")
>   SQLEXEC(han,"select * from #foo ",'foo1') && EMPTY result
>   brow
>ELSE
>   DISPLAY MEMORY LIKE fooerror
>ENDIF
>
I have bufferring set to 5 default and didnt post that hoped you will understand.

Ya, Thats what i am saying no updates.SQLSETPROP(han,"Transactions") has no effect. Then why use ? It will be effective only with SQlcommit() or Sqlrollback()

try this
lccon = [DRIVER=SQL Server Native Client 10.0;Server=nagaveni\sql2008;Trusted_Connection=Yes]
han = SQLSTRINGCONNECT(lccon)

SQLEXEC(han,"create table #foo (f1 int,f2 char(20))")
SQLEXEC(han,"select * from #foo ",'foo')
CURSORSETPROP([Buffering], 5, [Foo])

CURSORSETPROP("Tables","#foo","foo")
CURSORSETPROP("UpdateNameList", "f1 #foo.f1, f2 #foo.f2")
CURSORSETPROP("KeyFieldList", "F1")
CURSORSETPROP("UpdatableFieldList", "f1,f2")
CURSORSETPROP("SendUpdates", .T.)

FOR m.xi = 65 TO 90
   INSERT INTO foo VALUES (m.xi,REPLICATE(CHR(m.xi),10))
ENDFOR

SQLSETPROP(han,"Transactions",2)
SQLEXEC(han,"BEGIN TRANSACTION")


IF TABLEUPDATE(.t.,.t.,"foo",fooerror)

   Messagebox("records with Begin transaction and SQLSETprop transaction")
   SQLEXEC(han,"select * from #foo ",'foo1')
   brow
   
   SQLCOMMIT(han)                                 && encountered commit here
   Messagebox("records after SQL commit ")
   SQLEXEC(han,"select * from #foo ",'foo1') 
   brow

   SQLSETPROP(han,"Transactions",1) 
   Messagebox("records after SQlsetprop to automatic ")
   SQLEXEC(han,"select * from #foo ",'foo1') 
   brow

* now will this be rolled back ? No
   SQLEXEC(han,"ROLLBACK TRANSACTION")
   Messagebox("records  after ROLLBACK TRANSACTION")
   SQLEXEC(han,"select * from #foo ",'foo1')
   brow

ELSE
   DISPLAY MEMORY LIKE fooerror
ENDIF
suhashegde
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform