Here is a code snippet showing how you can test if a file exists on a web site (that you have access, of course).
It uses the UTL_HTTP database package.
DECLARE
url VARCHAR2(256) := 'http://sheikyerbouti.developpez.com/tmp/f6_menus/menudef.mmb';
username VARCHAR2(256);
password VARCHAR2(256);
req UTL_HTTP.REQ;
resp UTL_HTTP.RESP;
BEGIN
req := UTL_HTTP.BEGIN_REQUEST(url);
IF (username IS NOT NULL) THEN
UTL_HTTP.SET_AUTHENTICATION(req, username, password);
END IF;
resp := UTL_HTTP.GET_RESPONSE(req);
DBMS_OUTPUT.PUT_LINE('response -->' || resp.status_code);
END;
If the file exists, you get a 200 (also known as UTL_HTTP.HTTP_OK) return code. If it does not exist, you get the famous 404 (also known as UTL_HTTP.HTTP_NOT_FOUND) return code.
Voir tous les articles
Aucun commentaire pour cet article
Trackbacks
Aucun trackback pour cet article