oracle - How to catch a plsql output value -
i'm new vb , wondering how catch output value oracle command.
i got code:
dim paramret dim output sub function() sql = "declare variable := varchar(10); variable := 'test'; begin :=output := variable; end; " connect2oracle executesqlstatement sql set paramret = adocmd.createparameter("output",202,2,"20") adocmd.parameters.append paramret //print paramret..
but don't return value paramret. missing?
edit: noticed i've no reference query "sql" in createparameter observation correct?
you missing several things. first , foremost, anonymous procedures don't have return value or out parameter. so, return value need create function in oracle database.
example:
pl/sql:
function add5 (num in number) return number begin return (num + 5); end add5;
vb:
dim cmd new adodb.command dim inputparam new adodb.parameter dim returnparam new adodb.parameter cmd.activeconnection = myconnection cmd.commandtext = "add5" cmd.commandtype = adcmdstoredproc set inputparam = cmd.createparameter("prm1", adsmallint, adparaminput, , 30) 'using adparamoutput instead of adparamreturnvalue result in 'following error: 'ora-24334 - no descriptor position 'set prm2 = cmd.createparameter("prm2", adsmallint, adparamoutput) ' how use out parameter set returnparam = cmd.createparameter("prm2", adsmallint, adparamreturnvalue) 'you ora-24334 error if don't append parameters 'in correct order. make sure bind returning parameter first. cmd.parameters.append returnparam cmd.parameters.append inputparam cmd.execute msgbox "input value = " & cmd.parameters(1) msgbox "return value = " & cmd.parameters(0)
Comments
Post a Comment