stockboy Posted December 21, 2006 Share Posted December 21, 2006 (edited) I connect to the Oracle database as follows, works fine:Dim $oMyError$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initializes COM handler$SID = $var1[1][1]$ado = ObjCreate( "ADODB.Connection" ) ; Create a COM ADODB Object with the Beta versionWith $ado.ConnectionString =("Provider='OraOLEDB.Oracle';Data Source=" & $SID & ";User Id='xxxxx';Password='xxxxx';").OpenEndWith$adors = ObjCreate( "ADODB.RecordSet" ) ; Create a Record Set to handles SQL RecordsWith $adors .ActiveConnection = $ado .Source = "select waarde from parnassus.prn_systeem where code = 'DATABASEVERSIE'" .OpenEndWithWhile not $adors.EOF For $i = 0 To $adors.Fields.Count - 1 FileWriteLogOracle($pad6 &"parnassus.log",$adors.Fields( $i ).Value & @TAB) Next $adors.MoveNext ; Go to the next recordWEnd$ado.CloseMy question: instead of this function (select waarde from parnassus.prn_systeem where code = 'DATABASEVERSIE')I want to run an external sql-file (parnassus.sql) and log the result...Anyone can help me?TNX a lot The external sql-file (parnassus.sql) contains for example: DROP TRIGGER PRN_TRG_TEKSTEN_COMMENTAAR; DROP SEQUENCE PRN_SEQ_TEKSTEN_COMMENTAAR; DROP TABLE PRN_TEKSTEN_COMMENTAAR; ALTER TABLE PRN_TEKST_COMMENTAAR ADD ( CONSTRAINT PRN_TEKST_C_PRN_LID_FK FOREIGN KEY (LID_NRQ) REFERENCES PRN_LEDEN (NRQ)); ALTER TABLE PRN_TEKST_COMMENTAAR ADD ( CONSTRAINT PRN_TEKST_C_PRN_BIJLAGE_FK FOREIGN KEY (TEKST_NRQ) REFERENCES PRN_TEKST (NRQ)); Edited December 21, 2006 by stockboy Link to comment Share on other sites More sharing options...
ptrex Posted December 21, 2006 Share Posted December 21, 2006 @stockboyIn AutoIt you have to user the RUN command see help file.But before you make .BAT file the calls the SQLPLUS cmd.In order to test if you have sqlplus installed, go to the CMD and type SQLPLUS, and see what happenes.If the SQLPLUS is ok. Go here to see how to run a SQLcommand from the SQLPLUS.http://www.techonthenet.com/oracle/questions/script.phpEnjoy,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
stockboy Posted December 21, 2006 Author Share Posted December 21, 2006 @ptrex I understand what you mean but I want to execute the sql-script with oledb (so without starting sqlplus). But I'm not sure if its possible... Link to comment Share on other sites More sharing options...
ptrex Posted December 21, 2006 Share Posted December 21, 2006 Hi It is not possible to run as script through the OLEDB. The objectove of OLEDB is run SQL commands against a DB. So you run each command in a OLEDB statement, so you don't need the script. An way around you problem is that you write these command in a kind of TXT file. Than user AUTOIT to read that file use FILEOPEN and FILECLOSE. And assign each line to a Variable in your AU3 SCript. This way each command in the text file is read by the script before it is executed. Than make your script this way thet it executes the SQL lines (in the Variable) by the OLEDB commands. This way it should definitely work. Regards/Groeten, ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New Link to comment Share on other sites More sharing options...
stockboy Posted December 21, 2006 Author Share Posted December 21, 2006 (edited) That's all I needed to know. I'm going to try it the way you described above. I'm also pretty sure it should work. You rule :-) TNX A LOT !! Edited December 21, 2006 by stockboy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now