Author Topic: Powershell to CLR question(s)  (Read 171 times)

stanl

  • Pundit
  • *****
  • Posts: 889
Powershell to CLR question(s)
« on: March 06, 2019, 10:35:15 am »
Before I go down the path to error is

Add-Type -Path "C:\reports\tns\Oracle.ManagedDataAccess.dll"  in Powershell

equivalent to
ObjectClrOption("AppBase", "C:\reports\tns\Oracle.ManagedDataAccess.dll") in WB CLR

and if so, assuming a connect string and sql statement are coded

is
OracleDataAdapter = New-Object -TypeName Oracle.ManagedDataAccess.Client.OracleDataAdapter($sql,$Conn) in Powershell

equivalent to
ObjectClrNew("Oracle.ManagedDataAccess.Client.OracleDataAdapter",cSQL,cConn) in WB CLR

td

  • Tech Support
  • *****
  • Posts: 2849
    • WinBatch
Re: Powershell to CLR question(s)
« Reply #1 on: March 06, 2019, 11:10:47 am »
Code: Winbatch
;; Untested rough guess.
ObjectClrOption("AppBase", "C:\reports\tns")
ObjectClrOption("useany", "Oracle.ManagedDataAccess.dll")

;; If the class has multiple constructors you may need to cast the  2
;; constuctor parameters using ObjectClrType.
objWhatever = ObjectClrNew("Oracle.ManagedDataAccess.Client.OracleDataAdapter",cSQL,cConn)
 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

stanl

  • Pundit
  • *****
  • Posts: 889
Re: Powershell to CLR question(s)
« Reply #2 on: March 06, 2019, 05:20:23 pm »
Better than I would have guessed? I'll let you know.

stanl

  • Pundit
  • *****
  • Posts: 889
Re: Powershell to CLR question(s)
« Reply #3 on: March 07, 2019, 12:20:14 pm »
It is working but now I am in the Oracle universe of managed/unmanaged drivers.  My appbase can be either Oracle.ManagedDataAccess.dll, or Oracle.DataAccess.dll - with the corresponding adapters Oracle.ManagedDataAccess.Client.OracleDataAdapter  or Oracle.DataAccess.Client.OracleDataAdapter.

I need to query against 2 Oracle sources.  One errors if I use managed, the other doesn't seem to care, but if using the unmanaged appbase throws an exception if using the unmanaged adapter; so I can use an unmanaged dll with a managed adapter. Luckily StackOverflow and other sites are full of WTF's from users trying to figure out the difference and when to apply.

This is not a WB problem and of course Oracle says it's not their problem if you know the difference and when to apply. Can't wait for Game of Thrones.