Skip to Main Content

Portuguese

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!

how to solve this error

Aravind Kumar SekarSep 24 2015 — edited Oct 24 2015

TABLE

EMP

TableColumnData TypeLengthPrecisionScalePrimary KeyNullableDefaultComment
EMPEMPNONUMBER-401---
ENAMEVARCHAR210---nullable--
JOBVARCHAR29---nullable--
MGRNUMBER-40-nullable--
HIREDATEDATE7---nullable--
SALNUMBER-372-nullable--
COMMNUMBER-72-nullable--
DEPTNONUMBER-20-nullable-

the program i am executing is

DECLARE

E_NAME EMP.ENAME%TYPE;

E_MGR EMP.MGR%TYPE;

E_SAL EMP.SAL%TYPE;

CURSOR E_CUR IS

SELECT ENAME,MGR,SAL FROM EMP;

BEGIN

OPEN E_CUR;

DBMS_OUTPUT.PUT_LINE(E_NAME||' '|| E_MGR||' '||E_SAL);

LOOP

FETCH E_CUR INTO E_NAME,E_SAL,E_MGR;

IF E_SAL> 2000 THEN

UPDATE EMP SET SAL=SAL/1000 ;

DBMS_OUTPUT.PUT_LINE(E_NAME||' | '|| E_MGR||' | '||E_SAL);

EXIT  WHEN E_CUR%NOTFOUND;

END IF;

END LOOP;

END

EMPNOENAMEJOBMGRHIREDATESALCOMMDEPTNO
7839KINGPRESIDENT-11/17/198121500-10
7698BLAKEMANAGER783905/01/198119350-30
7782CLARKMANAGER783906/09/198118950-10
7566JONESMANAGER783904/02/198119475-20
7788SCOTTANALYST756612/09/198219500-20
7902FORDANALYST756612/03/198119500-20
7369SMITHMANAGER790212/17/198016501-20
7499ALLENSALESMAN769802/20/19811810030030
7521WARDSALESMAN769802/22/19811775050030
7654MARTINSALESMAN769809/28/198117750140030
7844TURNERSALESMAN769809/08/198118000030
7876ADAMSCLERK778801/12/198317600-20
7900JAMESCLERK769812/03/198117450-30
7934MILLERCLERK778201/23/198217800-10

the error i was getting is

ORA-06502: PL/SQL: numeric or value error: number precision too large

This post has been answered by Alex.Zaballa on Oct 24 2015
Jump to Answer

Comments

Birthe Gebhardt

Hi Shubham,
depend if you have APEX installed on your database or not.
If APEX is installed, you can use APEX.WEB_SERVICE.make_request. Otherwise you can use UTL_HTTP.
Further you need access to the URL from inside the database. Please check your ACE/L configuration. For this check you need the PLS/SQL packages DBMS_NETWORK_ACL_ADMIN.

For you REST call you need to clarify which kind of authentification is used. Befoer I transfer the REST call into the database I ceck the connection and the calls using POSTMAN.
To post a working snippet is difficulty, because of the missing information:
Database Version
APEX Installation
REST authentification
Wallets
Here is an example for an REST call: https://apex.oracle.com/pls/apex/germancommunities/apexcommunity/tipp/6121/index-en.html

Bye,
Birthe

Bilal

Hi Shubham,
Try out the following PLSQL code. Pls, note it is for calling HTTP request to make it simple but not HTTPS which will require you to do some extra work. Also to call the URL you need to register it DBMS_NETWORK_ACL_ADMIN as suggested above.

procedure call_rest_from_plsql_with_params(p$company_name varchar2) as
 l$request utl_http.req;
 l$response utl_http.resp;
 l$crawler_url varchar2(4000) := 'http://localhost:5000/get_company_data'; --Change to suit yours
 l$buffer varchar2(4000); 
 l$response_text varchar2(4000);
 l$params varchar2(4000) := '{"companyname":"'||p$company_name||'"}'; -- Pass your parameter here  as JSON
 begin
 -- Setting up the request and response objects
  l$request := utl_http.begin_request(l$crawler_url, 'GET',' HTTP/1.1');
  utl_http.set_header(l$request, 'user-agent', 'mozilla/4.0'); 
  utl_http.set_header(l$request, 'Content-Type', 'application/json'); 
  utl_http.set_header(l$request, 'Content-Length', length(l$params));
     -- Passing parameteres to GET call
  utl_http.write_text(l$request, l$params);
  -- Getting the response object
  l$response := utl_http.get_response(l$request);
  -- Reading the data from response object
  begin
    loop
     utl_http.read_line(l$response, l$buffer);  
     l$response_text := l$response_text || l$buffer;
    end loop;
    utl_http.end_response(l$response);

  exception
    when utl_http.end_of_body then
     utl_http.end_response(l$response);
  end;
  -- Print the l$response or do whatever you want to using Oracle SQL JSON functions
end;

I hope this will be useful for what you seek.
Wish you the best of luck.
Take care and best Regards
Bilal

User_A8XLF

Thanks you for the response. I have to use utl_http package. Is it possible to use utl_http in case some user authentication is required. If yes how we do that?

Billy Verreynne

UTL_HTTP supports Basic Authentication.
Other types of authentication like NTLM needs to be implemented by the developer.

Bilal
Answer

You can find basic authentication examples on this link: https://oracle-base.com/articles/misc/utl_http-and-ssl

Marked as Answer by User_A8XLF · Feb 4 2021
1 - 5

Post Details

Added on Sep 24 2015
1 comment
773 views