WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on March 06, 2019, 10:35:15 AM

Title: Powershell to CLR question(s)
Post by: stanl 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
Title: Re: Powershell to CLR question(s)
Post by: td on March 06, 2019, 11:10:47 AM
Code (winbatch) Select
;; 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)
Title: Re: Powershell to CLR question(s)
Post by: stanl on March 06, 2019, 05:20:23 PM
Better than I would have guessed? I'll let you know.
Title: Re: Powershell to CLR question(s)
Post by: stanl 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.