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 2 of 3 Topic 11292 of 11795
Post > Topic >>

Re: Question for Willie

by "Willie Moore" <williem@[EMAIL PROTECTED] > Apr 8, 2008 at 09:44 PM

Ian,

You should wrap your delete in a transaction. That way if something does =
work, you will be able to recover from it and rollback the statement

Regards,

Willie

oDataConn:BeginTrans()
oCommand                                :=3DAdoCommand{}
oCommand:ActiveConnection     :=3DoDataConn
oCommand:CommandText          :=3DcSql
oCommand:CommandType         :=3DadCmdText
 oCommand:CommandTimeout   :=3D0
oRS                                           =
:=3DoCommand:Execute(@[EMAIL PROTECTED]
)
oDataConn:CommitTrans()
oRS                                           :=3Dnull_object
oCommand                                 :=3Dnull_object
lResult                                       :=3Dtrue
ErrorBlock(cbErr)
RECOVER USING uError
        oDataConn:RollBackTrans()
        ErrorBlock(cbErr)
        IF IsObject(uError)
             cErrMsg :=3D "SQLConnection:ExecCommand Statement Error : " =
+
            uError:Description +
             CRLF + "Delete Instruction Failed"
        ELSEIF IsString(uError)
            cErrMsg :=3D uError + CRLF + "Delete Instruction Failed"
        ENDIF
        ErrorBox{,cErrMsg}:show()
END SEQUENCE
return nRecords





"Ian" <ithomson@[EMAIL PROTECTED]
> wrote in message =
news:9c3ed7e5-c8ba-4f4d-935b-dd62b98db5be@[EMAIL PROTECTED]
> Hi Willie,
>=20
> 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.
>=20
> The code I use is below
>=20
> lOCAL nRecords         as LONG
> lOCAL oRS              as ADORecordset
> lOCAL oCommand         as ADOCommand
> lOCAL cbErr            as CODEBLOCK
> local lResult :=3Dfalse  as logic
> locAL uError           as USUAL
> local cErrMsg          as string
>=20
> cbErr   :=3D ErrorBlock({|oErr|_Break(oErr)})
>=20
> BEGIN SEQUENCE
>   oCommand                  :=3DAdoCommand{}
>   oCommand:ActiveConnection :=3DoDataConn
>   oCommand:CommandText      :=3DcSql
>   oCommand:CommandType      :=3DadCmdText
>   oCommand:CommandTimeout   :=3D0
>   oRS                       :=3DoCommand:Execute(@[EMAIL PROTECTED]
)
>   oRS                       :=3Dnull_object
>   oCommand                  :=3Dnull_object
> lResult                   :=3Dtrue
>   ErrorBlock(cbErr)
>   RECOVER USING uError
>   ErrorBlock(cbErr)
>   IF IsObject(uError)
>    cErrMsg :=3D "SQLConnection:ExecCommand Statement Error : " +
> uError:Description +
>    CRLF + "Delete Instruction Failed"
>  ELSEIF IsString(uError)
>   cErrMsg :=3D uError + CRLF + "Delete Instruction Failed"
>  ENDIF
>  ErrorBox{,cErrMsg}:show()
> END SEQUENCE
> return nRecords
>=20
> 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.
>=20
> ie If it can not delete all twenty detail records it should not delete
> any.
>=20
> Regards,
> 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:19:26 CST 2008.