Demo :
cmd /c "odbcconf.exe /a {configdsn ""Oracle in OraClient11g_home1"" ""DSN=helloworld|SERVER=DB01""}"
Create a helloworld data source connecting to your DB01 tns alias in your OraClient11g_home1 Oracle Home.
It is easy to get the Oracle Home name with
Get-itemproperty HKLM:\SOFTWARE\ORACLE\*| Select-Object ORACLE_HOME,ORACLE_HOME_NAME
ORACLE_HOME ORACLE_HOME_KEY
----------- ---------------
C:\oracle\product\11.1.0\client_1 OraClient11g_home1
C:\oracle\product\11.2.0\client_1 OraClient11g_home2
Then we create the connection (as we did in ADO or ODP) :
$conn = New-Object Data.Odbc.OdbcConnection
$conn.ConnectionString= "dsn=helloworld;uid=scott;pwd=tiger;"
$conn.open()
(new-Object Data.Odbc.OdbcCommand("select 'Hello World' from dual",$conn)).ExecuteScalar()
$conn.close()
Note: odbcconf will be removed in future release, prefer Add-OdbcDsn
Pingback: ODBC 32bits for Windows 64bits | Laurent Schneider
Hi Kaurent,
Kudos !! For ur excellent knowledge in oracle.
I m facing a problem with sql plus.
I have a requirement to create a stored procedure so that whenever a call to storedprocedure is made, the data from the table should be populated into a xlsb file which is having some macros. And even in that it should go into the 1st worksheet.
So I cannot create a new xlsb file instead I hav to use already existing one.
Please post me any ideas how to do this?
I wrote on editting excel files there :
https://laurentschneider.com/2013/04/generate-microsoft-office-documents-from-command-line.html
Otherwise you will need to use the windows framework (Visual Studio) to edit your file and then you could use the code above or the one in ADO or ODP
https://laurentschneider.com/2012/03/to-ado-or-to-odp.html
Pingback: powershell odbc sybase | Laurent Schneider