Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Clipper Visual-Objects > Re: Question fo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 11292 of 11795
Post > Topic >>

Re: Question for Willie

by Ian <ithomson@[EMAIL PROTECTED] > Apr 9, 2008 at 01:32 AM

On 9 Apr, 03:44, "Willie Moore" <will...@[EMAIL PROTECTED]
> wrote:
> Ian,
>
> You should wrap your delete in a transaction. That way if something does
w=
ork, you will be able to recover from it and rollback the statement
>
> Regards,
>
> Willie
>
> oDataConn:BeginTrans()
> oCommand =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=A0:=
=3DAdoCommand{}
> oCommand:ActiveConnection =A0 =A0 :=3DoDataConn
> oCommand:CommandText =A0 =A0 =A0 =A0 =A0:=3DcSql
> oCommand:CommandType =A0 =A0 =A0 =A0 :=3DadCmdText
> =A0oCommand:CommandTimeout =A0 :=3D0
> oRS =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 =A0 :=3DoCommand:Execute(@[EMAIL PROTECTED]
)
> oDataConn:CommitTrans()
> oRS =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 =A0 :=3Dnull_object
> oCommand =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
:=
=3Dnull_object
> lResult =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
=
=A0 =A0 =A0 :=3Dtrue
> ErrorBlock(cbErr)
> RECOVER USING uError
> =A0 =A0 =A0 =A0 oDataConn:RollBackTrans()
> =A0 =A0 =A0 =A0 ErrorBlock(cbErr)
> =A0 =A0 =A0 =A0 IF IsObject(uError)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0cErrMsg :=3D "SQLConnection:ExecCommand
Stateme=
nt Error : " +
> =A0 =A0 =A0 =A0 =A0 =A0 uError:Description +
> =A0 =A0 =A0 =A0 =A0 =A0 =A0CRLF + "Delete Instruction Failed"
> =A0 =A0 =A0 =A0 ELSEIF IsString(uError)
> =A0 =A0 =A0 =A0 =A0 =A0 cErrMsg :=3D uError + CRLF + "Delete Instruction
F=
ailed"
> =A0 =A0 =A0 =A0 ENDIF
> =A0 =A0 =A0 =A0 ErrorBox{,cErrMsg}:show()
> END SEQUENCE
> return nRecords
>
>
>
> "Ian" <ithom...@[EMAIL PROTECTED]
> wrote in
messagenews:9c3ed7e5-c8ba-4f4d-93=
5b-dd62b98db5be@[EMAIL PROTECTED]
> > Hi Willie,
>
> > I took your advice about cascading deletes and set up my tables
> > accordingly. Having tested this it works a treat but can you clarify
> > one thing for me.
>
> > The code I use is below
>
> > lOCAL nRecords =A0 =A0 =A0 =A0 as LONG
> > lOCAL oRS =A0 =A0 =A0 =A0 =A0 =A0 =A0as ADORecordset
> > lOCAL oCommand =A0 =A0 =A0 =A0 as ADOCommand
> > lOCAL cbErr =A0 =A0 =A0 =A0 =A0 =A0as CODEBLOCK
> > local lResult :=3Dfalse =A0as logic
> > locAL uError =A0 =A0 =A0 =A0 =A0 as USUAL
> > local cErrMsg =A0 =A0 =A0 =A0 =A0as string
>
> > cbErr =A0 :=3D ErrorBlock({|oErr|_Break(oErr)})
>
> > BEGIN SEQUENCE
> > =A0 oCommand =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0:=3DAdoCommand{}
> > =A0 oCommand:ActiveConnection :=3DoDataConn
> > =A0 oCommand:CommandText =A0 =A0 =A0:=3DcSql
> > =A0 oCommand:CommandType =A0 =A0 =A0:=3DadCmdText
> > =A0 oCommand:CommandTimeout =A0 :=3D0
> > =A0 oRS =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0
:=3DoCommand:Execute=
(@[EMAIL PROTECTED]
)
> > =A0 oRS =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :=3Dnull_object
> > =A0 oCommand =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0:=3Dnull_object
> > lResult =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 :=3Dtrue
> > =A0 ErrorBlock(cbErr)
> > =A0 RECOVER USING uError
> > =A0 ErrorBlock(cbErr)
> > =A0 IF IsObject(uError)
> > =A0 =A0cErrMsg :=3D "SQLConnection:ExecCommand Statement Error : " +
> > uError:Description +
> > =A0 =A0CRLF + "Delete Instruction Failed"
> > =A0ELSEIF IsString(uError)
> > =A0 cErrMsg :=3D uError + CRLF + "Delete Instruction Failed"
> > =A0ENDIF
> > =A0ErrorBox{,cErrMsg}:show()
> > END SEQUENCE
> > return nRecords
>
> > If there are twenty records in the details file but only ten can be
> > deleted for whatever reason, will this leave all twenty records intact
> > or do I have to do some kind of rollback to recover the ten that were
> > deleted.
>
> > ie If it can not delete all twenty detail records it should not delete
> > any.
>
> > Regards,
> > Ian- Hide quoted text -
>
> - Show quoted text -

Hi Willie,

Thank you for your response. I very much appreciate your assistance.

Many Thanks,
Ian
 




 3 Posts in Topic:
Question for Willie
Ian <ithomson@[EMAIL P  2008-04-07 04:01:38 
Re: Question for Willie
"Willie Moore"   2008-04-08 21:44:58 
Re: Question for Willie
Ian <ithomson@[EMAIL P  2008-04-09 01:32:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 7:07:04 CST 2008.