Oracle ODBC hello world with powershell

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


----------- ---------------
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;"
(new-Object Data.Odbc.OdbcCommand("select 'Hello World' from dual",$conn)).ExecuteScalar()

Note: odbcconf will be removed in future release, prefer Add-OdbcDsn

4 thoughts on “Oracle ODBC hello world with powershell

  1. Pingback: ODBC 32bits for Windows 64bits | Laurent Schneider

  2. saketh

    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?

  3. Pingback: powershell odbc sybase | Laurent Schneider

Comments are closed.