Solved

Does anyone know the PLSQL code for Retrieve Positions ?

  • 31 January 2023
  • 4 replies
  • 174 views

Badge +2

Hello All,

I would like to create a script for Retrieve Positions button available on Retrieve Object Map Positions screen.

Regards

Avinash

 

 

icon

Best answer by Mathias Dahl 13 February 2023, 21:35

View original

4 replies

Userlevel 4
Badge +8

Hi @TieAvinaK 

Refer to this response on the same topic.  The solution is in the client alone to retrieve and will show the  locations.  

Request @Mathias Dahl to help you further , if you need some other info for the Map information stored .

 

 

Badge +2

Hi,
I am aware about the solution, I was thinking to automate the process using some PLSQL scripts. As of now the user has to go Retrieve Object Map Positions screen and click on Retrieve Positions. Is there any PLSQL script available to know what code is actually called when we click on  Retrieve Positions button.?

Regards
Avinash 

Userlevel 7
Badge +30

In Apps 10 we do the geocoding using Bing Maps' geocoding API directly from the client. It should be possible to do the same call from PL/SQL using the UTL_HTTP package, but that's something you probably have to experiment with on your own. If you pull it off, I'm sure others would be interested in the solution, so don't hesitate to share.

To get you started I asked Chat GPT to create a first version for you:

CREATE OR REPLACE PROCEDURE geocode_address (p_address IN VARCHAR2, p_latitude OUT NUMBER, p_longitude OUT NUMBER)
AS
l_http_request UTL_HTTP.req;
l_http_response UTL_HTTP.resp;
l_response_text VARCHAR2(32767);
l_latitude NUMBER;
l_longitude NUMBER;
BEGIN
-- Construct the URL for the Bing Maps geocoding API request
l_http_request := UTL_HTTP.begin_request('https://dev.virtualearth.net/REST/v1/Locations?q=' || p_address || '&key=YOUR_API_KEY', 'GET', 'HTTP/1.1');

-- Send the request to the API
l_http_response := UTL_HTTP.get_response(l_http_request);

-- Read the response text
BEGIN
UTL_HTTP.read_text(l_http_response, l_response_text);
EXCEPTION
WHEN UTL_HTTP.end_of_body THEN
UTL_HTTP.end_response(l_http_response);
END;

-- Extract the latitude and longitude from the response text
-- (Note: this is a simplified example and assumes that the response is in a specific format)
l_latitude := REGEXP_SUBSTR(l_response_text, '"latitude":"([^"]+)"', 1, 1, NULL, 1);
l_longitude := REGEXP_SUBSTR(l_response_text, '"longitude":"([^"]+)"', 1, 1, NULL, 1);

-- Set the output parameters
p_latitude := l_latitude;
p_longitude := l_longitude;
END;

It also said this:

This procedure uses the UTL_HTTP package to send an HTTP GET request to the Bing Maps geocoding API, and it uses REGEXP_SUBSTR to extract the latitude and longitude values from the response.

Note that you'll need to replace YOUR_API_KEY with your own Bing Maps API key in the l_http_request line. Also, this code is just a simplified example, and you'll need to adapt it to handle the specifics of the API response, error handling, and so on.

 

Good luck!

 

Badge +2

@Mathias Dahl  Thank you for your response.
 

 

Regards

Avinash

Reply