Skip to Content
Menu
This question has been flagged
2 Replies
9063 Views

I want to connect  OpenErp with Oracle database. I am tried base_external_dbsource module. But i am getting an error:ImportError: "libclntsh.so.10.1: cannot open shared object file: No such file or directory"

Please give me solution.. 

Avatar
Discard

Isn't XML-RPC an option? Odoo has it and supports it and so does Oracle. I'm sure there is a way to connect both through XML-RPC or by sending it to a webinterface.

Author

Thank You,Yenthe. I am try to Connect Oracle Database through XML-RPC

Best Answer

Following function on plsql will work. You can communicate with jsonrpc with this way. you can do whatever you want

You  can  parameterize  username  db  password  and   db name fields.

Also you can use and json parser package according to your oracle version. I simply get uid.



FUNCTION Odoo_Login RETURN varchar2

IS

http_req utl_http.req;

http_resp utl_http.resp;

json_request VARCHAR2(4000);

v_len number;

v_txt Varchar2(32767);

json_response CLOB;

a_ varchar2(2000);

result_ varchar2(2000);

result_id_ number;

rand number;

uid_ varchar2(200);

BEGIN

select dbms_random.value(1,1000000000) into rand from dual;

rand := round(rand,0);

dbms_output.put_line(rand);

json_request := '{"id":'||rand||',"jsonrpc":"2.0","method":"call","params":{"service":"common","method":"login","args":["DBNAME",mail@mail.com","yourpassword"]}}'; 


http_req:= utl_http.begin_request

(

'http://xxx.xxx.xxx.xxx:8069/jsonrpc'

, 'POST'

, 'HTTP/1.2'

);

UTL_HTTP.SET_BODY_CHARSET('UTF-8');


UTL_HTTP.set_header(http_req, 'Connection', 'close');

UTL_HTTP.set_header(http_req, 'Content-Type', 'application/json');

UTL_HTTP.set_header(http_req, 'Content-Length', LENGTHB(json_request));

UTL_HTTP.write_raw(http_req,UTL_RAW.CAST_TO_RAW(json_request));

http_resp := UTL_HTTP.get_response(http_req);

DBMS_OUTPUT.put_line('Response> status_code: "' || http_resp.status_code || '"');

DBMS_OUTPUT.put_line('Response> reason_phrase: "' ||http_resp.reason_phrase || '"');

DBMS_OUTPUT.put_line('Response> http_version: "' ||http_resp.http_version || '"');

DBMS_OUTPUT.put_line('Response> private_hndl: "' ||http_resp.private_hndl || '"');

utl_http.get_header_by_name(http_resp, 'Content-Length', v_len, 1); -- Obtain the length of the response

json_response := null;

FOR i in 1..CEIL(v_len/32767) -- obtain response in 32K blocks just in case it is greater than 32K

LOOP

utl_http.read_text(http_resp, v_txt, case when i < CEIL(v_len/32767) then 32767 else mod(v_len,32767) end);

dbms_output.put_line(v_txt);

json_response := json_response || v_txt; -- build up CLOB

END LOOP;

utl_http.end_response(http_resp);

--you can use a json parser here  package to parse result. below statement simply gets resulted user id.
SELECT substr(json_response, INSTR(JSON_RESPONSE, '"result": ')+10, INSTR(JSON_RESPONSE, '"result": ')+10 - (length(json_response)-2)) INTO uid_ from dual;

dbms_output.put_line(uid_);

return uid_;

END Odoo_Login;

Avatar
Discard
Best Answer

If you mean to use the Oracle as a substitute for Postgres then I'm afraid you are out of luck. Odoo currently only works with Postgres.

If you are trying to connect externally to Oracle, then I would suggest looking into XML-RPC, like Yenthe mentioned before. You should develop something on the side that requires the data. Luckily, Odoo is very integrated with XML-RPC, so connecting from Odoo to Oracle should be as easy as the other way around.

Avatar
Discard

can you give some example for oracle 10g and postgresql connection via XMP-RPC