Overblog Suivre ce blog
Editer l'article Administration Créer mon blog

Search

Free tool

Look and Feel Project

25 mars 2008 2 25 /03 /mars /2008 12:09
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.

Partager cet article

Repost 0
Francois Degrelle - dans Oracle PL-SQL
commenter cet article

commentaires