Help with registeroutparameter to return resultset

Good Morning,

I have the following code:

Dim oraCon As Object

Sub Main
	openOracle("DB_LOC")	
	stmt  = oraCon.prepareCall("VARIABLE x REFCURSOR DECLARE V_Sqlstatement Varchar2(2000); BEGIN V_Sqlstatement:= 'SELECT * FROM DUAL'; OPEN x for v_Sqlstatement; ?:=x End;")
REM Whate do i put here?
    stmt.registerOutParameter(1, ????,????)
	rs=stmt.executeQuery()
End Sub

Public Sub openOracle(sURL As String)
	oraCon = makeOracleJDBCConnection(sURL)
	executeDDLOracle("alter session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS'")	
End Sub

PRIVATE Function makeOracleJDBCConnection(src$) As com.sun.star.sdbc.XConnection
Dim sURL$
Dim myDict As Variant
	myDict= getScriptForgeDictionary()
	With myDict
		.Add("user", "username")
		.Add("password", "password")
		.Add("JavaDriverClass", "oracle.jdbc.driver.OracleDriver")
		oParms = .ConvertToPropertyValues()
		.Dispose()
	End With
	src=getUrl(src)
	sURL$ = "jdbc:oracle:thin:@" & src
	makeOracleJDBCConnection = getConnectionWithUserInfo(sURL, oParms)
End Function


Function getScriptForgeDictionary() As Variant
	if not GlobalScope.BasicLibraries.isLibraryLoaded("ScriptForge") Then
		GlobalScope.BasicLibraries.loadLibrary("ScriptForge")
	End If
	getScriptForgeDictionary= CreateScriptService("Dictionary")
End Function

Thank you for your assistance.

See my answer at libreoffice basic - libeoffice conected to oracle registeroutparameter to return resultset - Stack Overflow.

The answer is derived from Apache OpenOffice Community Forum - Database procedures and callable Statements - (View topic).

1 Like

I will accept that the suggestions given from the above links are solutions. So far I do not see a way to register a cursor as an outparamter.

libreoffice basic - libeoffice conected to oracle registeroutparameter to return resultset - Stack Overflow

openOracle("TEST_DB")
stmt  = oraCon.prepareCall("begin insert into TABLE1(NAME1) values (?)  returning id1, name1 into ?,?;  end;")
stmt.setString(1, "FREDO")
stmt.registerOutParameter(2, com.sun.star.sdbc.DataType.INTEGER, 0)
stmt.registerOutParameter(3, com.sun.star.sdbc.DataType.VARCHAR, "0")
stmt.execute()
print stmt.getInt(2)
print stmt.getString(3)