ORDS REST: Getting Bind Variables Right

June 20, 2017 at 3:38 pm | Posted in Oracle Developement | Leave a comment

It seems every time I create a REST GET module I have to re-learn how to handle bind variables. So I decided to create a little cheat sheet.

When creating a REST module with a GET handler, you can pass variables wither through the URI or through header variables:

URI Variables:


The URI template needs to have the bind variables in curly brackets (comma separated if multiple binds):


Create a query:

select * 
  from emp
 where empno = :id
   and ename = :ename

Create a parameter for each bind variable:

I don’t think whether if the Source Type matters. HTTP Header has worked for me. I typically set the parameter name and bind variable name to upper case to avoid any problems.


Click the Set Bind Variables button to test the handler. Make sure to add a value to all parameters. If you leave a parameter empty, you’ll get an error.


Header Variables:

Create the URI without a trailing forward slash:


Create the query and parameters as before.


You’ll have to test this with a REST client like POSTman or CURL:

$ curl -H "id:7788" -H "ename:SCOTT" http://myserver:8080/ords/cmr/hr/testheader

Note when using header variables, you can leave some out without getting an error.

Happy RESTing!





Leave a Comment »

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Entries and comments feeds.

%d bloggers like this: