Jump to content
Robert Gilland

Passing an SQL into a REST Request, and returning Result in JSON Dataset?

Recommended Posts

Can I passing an SQL (select Statement )into a REST Request to a Rest Server , and receive a result in a JSON Dataset?

Can I pass an INSERT/UPDATE/DELETE Statement into a Rest Request?

Share this post


Link to post
7 hours ago, Robert Gilland said:

Can I passing an SQL (select Statement )into a REST Request to a Rest Server , and receive a result in a JSON Dataset?

Can I pass an INSERT/UPDATE/DELETE Statement into a Rest Request?

Short answer:

Yes

 

Long answer:

Yes, but don't! It would put your SQL database at risk.

 

Instead, build a proper REST API as

- it hides the underlying database

- it allows you to change the underlying database operations without changing the client

A REST API done right is far more secure and robust.

  • Like 6

Share this post


Link to post

It's not recommended, but it's entirely possible.

I use this concept myself in a project.

My configuration looks like this:

- Rest server, with an endpoint that receives a SQL statement and parameters to execute or return data.

- Client application that contains a “REST Query” component that implements all the SQL execution logic via calls to the REST API. I created this client component by inheriting from a TFDMemTable where I add the returned result and implement the dataset events for searching and inserting.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×