#3 ORDS.DEFINE_SERVICE Format

To create REST service , you do have two choices using SQL developer, PLSQL .

We'll create REST services using PLSQL (ORACLE SQL Developer later).

REST Service has four major methods :
  1. GET:  Fetch data  [SELECT * FROM EMP_TABLE]
  2. POST: Insert data [INSERT INTO EMP_TABLE (Id, Name) VALUES (1,'Omar')]
  3. PUT: Updates data [UPDATE EMP_TABLE SET Name='Samar' WHERE Id=1)]
  4. DELETE: Deletes data [DELETE FROM EMP_TABLE WHERE Id=1]

ORDS.DEFINE_SERVICE Format :
ORDS.DEFINE_SERVICE(
   p_module_name        IN ords_modules.name%type, 
   p_base_path          IN ords_modules.uri_prefix%type,
   p_pattern            IN ords_templates.uri_template%type,
   p_method             IN ords_handlers.method%type DEFAULT 'GET',
   p_source_type        IN ords_handlers.source_type%type 
                             DEFAULT ords.source_type_collection_feed,
   p_source             IN ords_handlers.source%type,
   p_items_per_page     IN ords_modules.items_per_page%type DEFAULT 25,
   p_status             IN ords_modules.status%type DEFAULT 'PUBLISHED',
   p_etag_type          IN ords_templates.etag_type%type DEFAULT 'HASH',
   p_etag_query         IN ords_templates.etag_query%type DEFAULT NULL,
   p_mimes_allowed      IN ords_handlers.mimes_allowed%type DEFAULT NULL,
   p_module_comments    IN ords_modules.comments%type DEFAULT NULL,
   p_template_comments  IN ords_modules.comments%type DEFAULT NULL,
   p_handler_comments   IN ords_modules.comments%type DEFAULT NULL);

NOTE: The first seven Parameters (colored in blue) are the most used when creating REST service.
  • P_Module_Name: RESTful service name, CASE sensitive and Unique
  • P_Base_Path : RESTful api  URI 
  • P_Pattern:  RESTful Parameters, SELECT * FROM HR_TABLE WHERE Id=101, To send Parameter using REST API, you send :id (:id is P_Pattern )
  • P_Method: REST Method (GET,POST,PUT,DELETE)
  • P_Source_Type: Define RESTful service Data Type OUTPUT , how many rows are fetched
  • P_Source: Select statement 
  • P_Items_Per_Page: How many records are fetched, default is NULL
  • P_Status: Define whether REST is PUBLISHED or NOT_PUBLISHED

No comments:

Post a Comment

Remove unused Layouts in Oracle Apex

 Tables used : APEX_XXXXXXX.WWV_FLOW_REPORT_LAYOUTS APEX_XXXXXXX.WWV_FLOW_SHARED_QUERIES use the following query to delete unused Layouts. ...