Registersql: Difference between revisions

From Data Islands
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
We can register a sql with using registersql command.
We can register a sql query using registersql command.  
 
Why do this?
 
Well this allows you to dictate secure access to your data on data islands when consumed by an application.
 
We call this our REST2 API


(Syntax : registersql "sqlname" "description" "sql statement" <ENTER>)
(Syntax : registersql "sqlname" "description" "sql statement" <ENTER>)
Line 5: Line 11:
Example
Example


>registersql "getBerlinCustomers" "return only customers from Berlin" "select \"CustomerID\", \"CompanyName\", \"City\", \"Phone\" from customers where City='Berlin'"
>registersql "getBerlinCustomers" "return only customers from Berlin" "select "CustomerID", "CompanyName", "City", "Phone" from customers where City='Berlin'"
 
=== Permissions ===
To only give access to these statements use
 
REST2readwrite
 
Users with this only on a region cannot see the region in the console. cannot access REST1  but can access REST2 api in full


=== Sage 100 Example ===
=== Sage 100 Example ===
Line 23: Line 36:


SQL Statement: select * from arcustomers where 150=150 and idfield='02_ALLENAP'
SQL Statement: select * from arcustomers where 150=150 and idfield='02_ALLENAP'
Then from here you can call thsis via a REST API


---
---
Line 40: Line 50:


SQL Statement: select "IDCUST","IDBILLCYCL" from testarcus where "IDBILLCYCL" like '%BILLMT%' OR "IDBILLCYCL"='"abc"'
SQL Statement: select "IDCUST","IDBILLCYCL" from testarcus where "IDBILLCYCL" like '%BILLMT%' OR "IDBILLCYCL"='"abc"'
---
'''Delete a SQL statement'''
removesql "NAME"
=== REST2 API ===
Once we have any sql statement which we register with using registersql, then we can perform the API calls as:
(GET) => To get the sql data/records based on sql statement (eg. sql select statement) with passing parameters.
Url: https://apidev.crmtogether.com/rest2/mastersqlstatements/{{regionid}}/{{sqlname}}/{{islandname}}
{{regionid}} => This region id means under which region the islandname is available.
{{sqlname}} => This is the sql statement name which we given while performing registersql command (or while calling Add_SQL_STATEMENT Api call)
{{islandname}} => This is the parameter as in sql statement we given "select * from {0}"
'''As per the Sage 100 Example'''
the test
>test_registersql "getEntityData" "arcustomers,idfield,'02_ALLENAP'"
done via REST is
[https://apidev.crmtogether.com/rest2/mastersqlstatements/5ccb3342-3047-4065-afaf-1effc6e7d870/getEntityData/arcustomers/idfield/'02_ALLENAP' https://apius.crmtogether.com/rest2/mastersqlstatements/5ccb3123-3047-4065-afaf-1effc6e7d870/getEntityData/arcustomers/idfield/'02_ALLENAP']
---
WIP
SQL_Row_Insert (POST) => To insert data/records with using sql statement (eg. sql insert statement) with passing parameters.
Url: https://apidev.crmtogether.com/rest2/mastersqlstatements/{{regionid}}/{{sqlname}}
SQL_Row_Update (PUT) => To update data/record(s) with using sql statement (eg. sql update statement) with passing parameters.
Url: https://apidev.crmtogether.com/rest2/mastersqlstatements/{{regionid}}/{{sqlname}}

Latest revision as of 15:02, 26 November 2024

We can register a sql query using registersql command.

Why do this?

Well this allows you to dictate secure access to your data on data islands when consumed by an application.

We call this our REST2 API

(Syntax : registersql "sqlname" "description" "sql statement" <ENTER>)

Example

>registersql "getBerlinCustomers" "return only customers from Berlin" "select "CustomerID", "CompanyName", "City", "Phone" from customers where City='Berlin'"

Permissions

To only give access to these statements use

REST2readwrite

Users with this only on a region cannot see the region in the console. cannot access REST1  but can access REST2 api in full

Sage 100 Example

We register the SQL

>registersql "getEntityData" "Get island data" "select * from {0} where 150=150 and {1}={2}"

And from the console we can test this

>test_registersql "getEntityData" "arcustomers,idfield,'02_ALLENAP'"

and then this returns the SQL and whether it is valid or not

EG

Fetched data with rows#1

SQL Statement: select * from arcustomers where 150=150 and idfield='02_ALLENAP'

---

Here is how we can register a sql statement with double quote vaules:

>registersql "sqltest38" "get 38 2" "select "IDCUST","IDBILLCYCL" from testarcus where "IDBILLCYCL" like '%{0}%' OR "IDBILLCYCL"='"abc"'"

And we can see the result as:

>test_registersql "sqltest38" "BILLMT"

Fetched data with rows#20

SQL Statement: select "IDCUST","IDBILLCYCL" from testarcus where "IDBILLCYCL" like '%BILLMT%' OR "IDBILLCYCL"='"abc"'

---

Delete a SQL statement

removesql "NAME"

REST2 API

Once we have any sql statement which we register with using registersql, then we can perform the API calls as:

(GET) => To get the sql data/records based on sql statement (eg. sql select statement) with passing parameters.

Url: https://apidev.crmtogether.com/rest2/mastersqlstatements/Template:Regionid/Template:Sqlname/Template:Islandname

Template:Regionid => This region id means under which region the islandname is available.

Template:Sqlname => This is the sql statement name which we given while performing registersql command (or while calling Add_SQL_STATEMENT Api call)

Template:Islandname => This is the parameter as in sql statement we given "select * from {0}"

As per the Sage 100 Example

the test

>test_registersql "getEntityData" "arcustomers,idfield,'02_ALLENAP'"

done via REST is

https://apius.crmtogether.com/rest2/mastersqlstatements/5ccb3123-3047-4065-afaf-1effc6e7d870/getEntityData/arcustomers/idfield/'02_ALLENAP'




---

WIP

SQL_Row_Insert (POST) => To insert data/records with using sql statement (eg. sql insert statement) with passing parameters.

Url: https://apidev.crmtogether.com/rest2/mastersqlstatements/Template:Regionid/Template:Sqlname

SQL_Row_Update (PUT) => To update data/record(s) with using sql statement (eg. sql update statement) with passing parameters.

Url: https://apidev.crmtogether.com/rest2/mastersqlstatements/Template:Regionid/Template:Sqlname