vendredi 20 mars 2015

rails executing stored procedure error

I have a oracle stored procedure.


When I try to run the following in sql developer it works fine:



declare
vPan varchar2(32);
ErrorMsg varchar2(32);
ErrorCode varchar2(32);
SpErrorMsg varchar2(32);

begin


DBO_MYDB.PKG_LTD.GET_PAN('8042049440330819','32', 'TEST', '0',vPan, ErrorMsg, ErrorCode, SpErrorMsg);
DBMS_OUTPUT.PUT_LINE(vPan);

end;


But when I try to run the above code in rails 3 as follows:



def number
errormsg = nil
errorcode = nil
sperrormsg = nil
vpan = nil

sql =
"BEGIN #{Pkgltd::PKG_LTD}.GET_PAN('
8042049440330819','32', 'TEST', '0',vpan, errormsg, errorcode, sperrormsg);
END;"

connection = self.connection.raw_connection
cursor = connection.parse(sql)

cursor.bind_param(:errormsg, nil, String, 1000)
cursor.bind_param(:errorcode, nil, String, 1000)
cursor.bind_param(:sperrormsg, nil, String, 1000
cursor.bind_param(:vpan, nil, String, 1000)

cursor.exec

vpan, errormsg, errorcode, sperrormsg, vpan = cursor[:vpan], cursor[:errormsg], cursor[:errorcode], cursor[:sperrormsg]
cursor.close
vpan
end


I get the following error:



syntax error, unexpected tIDENTIFIER, expecting ')' cursor.bind_param(:vpan, nil, String, 1000)



Any ideas?


I even tried:



cursor.bind_param(:vpan, nil, varchar2, 1000);


Not sure if the above is valid.


Aucun commentaire:

Enregistrer un commentaire