Sign in to follow this  
Followers 0
stockboy

edit oracle database

8 posts in this topic

This script connects to an oracle database, gets the version of the program 'CI' and writes it in version.log.

My question: what do I have to change, in the script, to PUT data in the database instead of GET data.

For example: "update mnbarm set MNBARMART60MAXSOCECONEUR = 21356.63 where mnbarmmaand >= '01-JAN-07'"

instaed of "select upgrade_version ||''||upgrade_build from ci_toepassing where kode like 'CI'"

I know... I don't know much 'bout databases, shame on me ;o)

------------------------------------------------------------------------------

Dim $oMyError

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$ado = ObjCreate( "ADODB.Connection" )

With $ado

.ConnectionString =("Provider='OraOLEDB.Oracle';Data Source='mig2';User Id='cipal';Password='xxxx';")

.Open

EndWith

$adors = ObjCreate( "ADODB.RecordSet" )

With $adors

.ActiveConnection = $ado

.Source = "select upgrade_version ||''||upgrade_build from ci_toepassing where kode like 'CI'"

.Open

EndWith

While not $adors.EOF

For $i = 0 To $adors.Fields.Count - 1

FileWriteLogOracle("c:\version.log",$adors.Fields( $i ).Value & @TAB)

Next

$adors.MoveNext

WEnd

Func MyErrFunc()

Endfunc

Func FileWriteLogOracle($sLogPath, $sLogMsg)

EndFunc

Share this post


Link to post
Share on other sites



@ptrex

I mean: 'edit' the database (insert, update, etc...)

If I use: "select upgrade_version ||''||upgrade_build from ci_toepassing where kode like 'CI'" the script works.

If I use: "update mnbarm set MNBARMART60MAXSOCECONEUR = 21356.63 where mnbarmmaand >= '01-JAN-07'"

it gives this error: "operation is not allowed when the object is closed"

Share this post


Link to post
Share on other sites

CODE
$ado = ObjCreate( "ADODB.Connection" )

With $ado

.ConnectionString =("Provider='OraOLEDB.Oracle';Data Source=" & $SID & ";User Id='xxxx';Password='xxxx';")

.Open

EndWith

$adors = ObjCreate( "ADODB.RecordSet" )

With $adors

.ActiveConnection = $ado

.Execute ("UPDATE PRN_SYSTEEM SET WAARDE = '060204' WHERE CODE = 'PROGRAMVERSIE+'")

.Open

EndWith

While not $adors.EOF

For $i = 0 To $adors.Fields.Count - 1

FileWriteLogOracle($pad6 &"Parn_060204.log",$adors.Fields( $i ).Value & @TAB)

Next

$adors.MoveNext

WEnd

@Ptrex (or other experts ;o)

Something like this?

What am I doing wrong?

It still gives an error

TNX

Stockboy

Share this post


Link to post
Share on other sites

@stockboy

Run this again, added some error checking routine

; Initialize COM error handler 
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

$ado = ObjCreate( "ADODB.Connection" )             With $ado       .ConnectionString =("Provider='OraOLEDB.Oracle';Data Source=" & $SID & ";User Id='xxxx';Password='xxxx';")       .OpenEndWith$adors = ObjCreate( "ADODB.RecordSet" )            With $adors        .ActiveConnection = $ado        .Execute ("UPDATE PRN_SYSTEEM SET WAARDE = '060204' WHERE CODE = 'PROGRAMVERSIE+'")        .OpenEndWithWhile not $adors.EOF    For $i = 0 To $adors.Fields.Count - 1      FileWriteLogOracle($pad6 &"Parn_060204.log",$adors.Fields( $i ).Value & @TAB)    Next    $adors.MoveNext                                               WEnd

Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
Endfunc

Let me know which errors come out into SciTe and COM error routine.

regards,

ptrex

Share this post


Link to post
Share on other sites

@ptrex

It gives the following error's:

1) Posted Image

2) Posted Image

3) Posted Image

What's wrong ?

Tnx

Stockboy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0