You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an ObjectScript function to convert any sql query into a dynamic object. This returned object will have a key/value pair based on the fieldname and value from the query's result set. The function also has helpful optional parameters to let you switch namespaces on a per-query basis, and change the mode and dialect.
8
8
9
-
###Features
9
+
## Features
10
10
11
11
This function aims to be a one-stop shop for your sql needs, and is especially useful if you need the output eventually converted into json, as shown in the examples section. There are four parameters to the Build function that should be understood before using this code:
12
12
@@ -15,14 +15,14 @@ This function aims to be a one-stop shop for your sql needs, and is especially u
15
15
***Mode (Optional String)**: Default Value = "0" - Determines which mode the query will be run on
16
16
***Dialect (Optional String)**: Default Value = "IRIS" - Determines which dialect the query will use
17
17
18
-
## Mode
18
+
###Mode
19
19
20
20
Mode values are as follows:
21
21
***0**: Logical
22
22
***1**: ODBC
23
23
***2**: Display
24
24
25
-
## Dialect
25
+
###Dialect
26
26
27
27
For more information on these different dialect options, see [this article](https://irisdocs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=GSQL_dynsql#GSQL_dynsql_dialect).
28
28
***Sybase**
@@ -31,15 +31,16 @@ For more information on these different dialect options, see [this article](http
31
31
***IRIS**
32
32
***CACHE** (If using older versions)
33
33
34
-
###Example
34
+
## Example Usage
35
35
```sh
36
36
USER> write ##class(SQLtoObject.SQLtoObject).Build("SELECT AircraftCategory FROM Aviation.Aircraft","SAMPLES")
37
37
27@%Library.DynamicArray
38
+
38
39
USER> write ##class(SQLtoObject.SQLtoObject).Build("SELECT AircraftCategory FROM Aviation.Aircraft","SAMPLES").%ToJSON()
39
40
[{"AircraftCategory":"Airplane"},{"AircraftCategory":"Airplane"},{"AircraftCategory":"Airplane"}... etc.
40
41
```
41
42
42
43
SQL errors will be written out immediately, and logic errors will be returned in the return object
43
44
44
-
### Version history
45
+
## Version history
45
46
2019-07-18 - v1.0 - Initial commit of functionwith features outlined in description
0 commit comments