{"id":15840128,"url":"https://github.com/davealdon/dynamic-sql-to-dynamic-object","last_synced_at":"2025-04-01T17:19:07.938Z","repository":{"id":45955206,"uuid":"197630420","full_name":"DaveAldon/Dynamic-SQL-to-Dynamic-Object","owner":"DaveAldon","description":"📟 ObjectScript function to convert any sql query into a dynamic object","archived":false,"fork":false,"pushed_at":"2021-11-24T19:20:22.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-29T04:07:04.666Z","etag":null,"topics":["dynamic","intersystems","intersystems-cache","intersystems-iris","namespace","object","objectscript","sql"],"latest_commit_sha":null,"homepage":"https://davealdon.github.io/Dynamic-SQL-to-Dynamic-Object/","language":"ObjectScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DaveAldon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-18T17:31:43.000Z","updated_at":"2021-11-24T19:20:26.000Z","dependencies_parsed_at":"2022-09-02T18:41:28.622Z","dependency_job_id":null,"html_url":"https://github.com/DaveAldon/Dynamic-SQL-to-Dynamic-Object","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaveAldon%2FDynamic-SQL-to-Dynamic-Object","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaveAldon%2FDynamic-SQL-to-Dynamic-Object/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaveAldon%2FDynamic-SQL-to-Dynamic-Object/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DaveAldon%2FDynamic-SQL-to-Dynamic-Object/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DaveAldon","download_url":"https://codeload.github.com/DaveAldon/Dynamic-SQL-to-Dynamic-Object/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246679061,"owners_count":20816402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dynamic","intersystems","intersystems-cache","intersystems-iris","namespace","object","objectscript","sql"],"created_at":"2024-10-05T16:41:40.828Z","updated_at":"2025-04-01T17:19:07.909Z","avatar_url":"https://github.com/DaveAldon.png","language":"ObjectScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dynamic SQL to Dynamic Object\n\n[![Gitter](https://img.shields.io/badge/Available%20on-Intersystems%20Open%20Exchange-00b2a9.svg)](https://openexchange.intersystems.com/package/Dynamic-SQL-to-Dynamic-Object)\n\n## Overview\n\nThis 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.\n\n## Prerequisites\n\nMake sure you have [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) and [Docker desktop](https://www.docker.com/products/docker-desktop) installed.\n\n## Installation \n\nOpen terminal and clone/git pull the repo into any local directory\n\n```\n$ git clone git@github.com:DaveAldon/Dynamic-SQL-to-Dynamic-Object.git\n```\n\nOpen the terminal in this directory and run:\n\n```\n$ docker-compose build\n```\n\n3. Run the IRIS container with your project:\n\n```\n$ docker-compose up -d\n```\n\n## How to Run the Application\n\nFor a quick SQL demo, below includes instructions on installing the samples data and then using the application on it.\n\nOpen InterSystems IRIS terminal:\n\n```\n$ docker-compose exec iris iris session iris\nIRISAPP\u003ezpm\nzpm: IRISAPP\u003einstall samples-aviation\n\nIRISAPP\u003ewrite ##class(SQLtoObject.SQLtoObject).Build(\"SELECT AircraftCategory FROM Aviation.Aircraft\",\"IRISAPP\").%ToJSON()\n[{\"AircraftCategory\":\"Airplane\"},{\"AircraftCategory\":\"Airplane\"},{\"AircraftCategory\":\"Airplane\"}... etc.\n```\n\n## How to start coding\n\nThis repository is ready to code in VSCode with ObjectScript plugin.\nInstall [VSCode](https://code.visualstudio.com/), [Docker](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker) and [ObjectScript](https://marketplace.visualstudio.com/items?itemName=daimor.vscode-objectscript) plugins and open the folder in VSCode.\n\nRight-click on **docker-compose.yml** file and click Compose Restart\n\nOnce docker will finish starting procedure and show:\n\n```\nCreating objectscript-contest-template_iris_1 ... done\n```\n\nClick on the ObjectScript status bar and select Refresh connection in the menu.\nWait for VSCode to make connection and show something like \"localhost:32778[IRISAPP] - Connected\"\n\nYou can start coding after that. Open **SQLtoObject.cls** in VSCode, make changes and save - the class will be compiled by IRIS on 'Save'.\n\n## Features\n\nThis 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 previously, and later in the examples section. There are four parameters to the Build function that should be understood before using this code:\n\n* **Query (Required String)**: The query string that will be run\n* **Namespace (Optional String)**: Default Value = \"\" - Runs the query on the defined namespace\n* **Mode (Optional String)**: Default Value = \"0\" - Determines which mode the query will be run on\n* **Dialect (Optional String)**: Default Value = \"IRIS\" - Determines which dialect the query will use\n\n### Mode\n\nMode values are as follows:\n* **0**: Logical\n* **1**: ODBC\n* **2**: Display\n\n### Dialect\n\nFor 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).\n* **Sybase**\n* **MSSQL**\n* **MSSQLSERVER**\n* **IRIS**\n* **CACHE** (If using older versions)\n\n## Example Usage\n\nThis code assumes installation of the samples package like so:\n\n```\n$ docker-compose exec iris iris session iris\nIRISAPP\u003ezpm\nzpm: IRISAPP\u003einstall samples-aviation\n```\nThen run the following:\n\n```sh\nIRISAPP\u003e write ##class(SQLtoObject.SQLtoObject).Build(\"SELECT AircraftCategory FROM Aviation.Aircraft\",\"SAMPLES\")\n27@%Library.DynamicArray\n\nIRISAPP\u003e write ##class(SQLtoObject.SQLtoObject).Build(\"SELECT AircraftCategory FROM Aviation.Aircraft\",\"SAMPLES\").%ToJSON()\n[{\"AircraftCategory\":\"Airplane\"},{\"AircraftCategory\":\"Airplane\"},{\"AircraftCategory\":\"Airplane\"}... etc.\n```\n\nSQL errors will be written out immediately, and logic errors will be returned in the return object\n\n## Version history\n\n2020-03-22 - v1.1 - Compatibility with the InterSystems Online Programming Contest 2020\n\n2019-07-18 - v1.0 - Initial commit of function with features outlined in description\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavealdon%2Fdynamic-sql-to-dynamic-object","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavealdon%2Fdynamic-sql-to-dynamic-object","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavealdon%2Fdynamic-sql-to-dynamic-object/lists"}