Zero-Code REST APIs
ORDS AutoREST is the fastest way to expose database tables and views as REST endpoints. With a single PL/SQL call, ORDS generates a complete CRUD API with GET (list and single item), POST (create), PUT (update), and DELETE operations. No REST module definitions, no handler code, no URL template configuration required.
Enabling AutoREST on a Table
-- Enable AutoREST for the PRODUCTS table
BEGIN
ORDS.ENABLE_OBJECT(
p_enabled => TRUE,
p_schema => 'HR',
p_object => 'PRODUCTS',
p_object_type => 'TABLE',
p_object_alias => 'products'
);
COMMIT;
END;
/
This immediately creates these endpoints:
GET /ords/hr/products/ -- List all products (paginated)
GET /ords/hr/products/{id} -- Get single product by primary key
POST /ords/hr/products/ -- Create a new product
PUT /ords/hr/products/{id} -- Update an existing product
DELETE /ords/hr/products/{id} -- Delete a product
Filtering and Pagination
AutoREST endpoints support query parameters for filtering, sorting, and pagination out of the box:
GET /ords/hr/products/?q={"category":"Electronics"}
GET /ords/hr/products/?q={"unit_price":{"$gt":100}}
GET /ords/hr/products/?limit=25&offset=50
GET /ords/hr/products/?orderby=product_name:asc
The filter syntax supports equality, comparison operators ($gt, $lt, $gte, $lte), LIKE patterns with $like, IN lists with $in, and NULL checks with $null. This gives API consumers powerful query capabilities without any server-side code.
AutoREST on Views
For read-only APIs or when you want to control which columns are exposed, create a database view and enable AutoREST on it. The view can join multiple tables, exclude sensitive columns, and compute derived values. AutoREST on views only supports GET operations since views may not be directly updatable:
CREATE OR REPLACE VIEW product_catalog AS
SELECT product_id, product_name, category, unit_price,
CASE WHEN in_stock = 'Y' THEN 'Available' ELSE 'Out of Stock' END AS availability
FROM products WHERE status = 'ACTIVE';
BEGIN
ORDS.ENABLE_OBJECT(TRUE, 'HR', 'PRODUCT_CATALOG', 'VIEW', 'catalog');
COMMIT;
END;
Security
AutoREST endpoints inherit ORDS’s authentication and authorization settings. By default, they are unprotected. For production use, define ORDS roles and privileges to restrict access. You can protect AutoREST endpoints with OAuth2 or custom authentication just like manually defined REST modules. Consider creating a view with limited columns rather than exposing the entire table if the table contains sensitive data.