Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Google currency converter

JitendraNov 19 2013 — edited Dec 10 2013

Hi Experts,

I am using Google API for the currency conversion. below is the code

create or replace

FUNCTION xxget_google_rate (p_from_currency varchar2,

                                              p_to_currency varchar2)

  RETURN varchar IS

  -- Variable declarations.

  t_page_table    utl_http.html_pieces;

  l_url           varchar2(1000);

  l_fx_rate       number;

BEGIN

  -- Build the URL to the Google API.

  l_url := 'http://www.google.com/ig/calculator?hl=en&q=1' ||p_from_currency || '=?' || p_to_currency;

  -- Make a HTTP call to the API       

  t_page_table := utl_http.request_pieces(l_url);

  -- The rate is returned on the first line, so scrape out the rate. There is

  -- no HTML returned. The following is an example of the text returned:

  -- {lhs: "1 British pound",rhs: "1.5625 U.S. dollars",error: "",icc: true}

-- dbms_output.put_line(t_page_table);

  l_fx_rate := to_number(substr(t_page_table(1),

                 instr(t_page_table(1), 'rhs: "')+6,

                 instr(substr(t_page_table(1),

                 instr(t_page_table(1), 'rhs: "')+6), ' ', 1, 1)-1));

  -- Return the rate.

  dbms_output.put_line(l_fx_rate);

  RETURN l_fx_rate;

EXCEPTION WHEN others THEN

  -- Return -999 to indicate that a rate could not be determined.

  RETURN sqlerrm;

END xxget_google_rate;

above code giving me following error

ORA-29273: HTTP request failed

ORA-06512: at “SYS.UTL_HTTP”, line 1130

ORA-29024: Certificate validation failure

to resolve the above error i have created wallet in the database using the information from below link

Accessing SSL encrypted websites using UTL_HTTP and Oracle Wallet Manager | iAdvise blog

After creating the wallet. i am getting different error.

ORA-29273: HTTP request failed

ORA-06512: at "SYS.UTL_HTTP", line 1130

ORA-28756: callback failure to allocate memory

please help me to resolve this issue.

Apex Version - 4.1

DB version - 11gR2

Thanks and regards,

Jitendra

This post has been answered by Jitendra on Dec 10 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2014
Added on Nov 19 2013
7 comments
1,415 views