Giter Club home page Giter Club logo

inline-query's Introduction

Inline Query | SQL like Queries in Business Central

Inline Query is a library that can execute SQL like Queries in Business Central AL Language. This is a small compiler in AL that compiles and executes SQL like queries in text constants or text variables.

Example

Count of released Sales Orders

Query

SELECT COUNT(1) FROM [Sales Header] WHERE Status = 'Released'

AL Code

procedure GetOrderCount(): Integer
var
	InlineQuery: Codeunit "Inline Query";
	OrderCount: Integer;
	QueryTxt: Label 'SELECT COUNT(1) FROM [Sales Header] WHERE Status = ''Released''', Locked = true;
begin
	OrderCount := InlineQuery.AsInteger(QueryTxt);
	exit(OrderCount);
end;

See msnJournals.com for more information.

inline-query's People

Contributors

msnraju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

inline-query's Issues

select multiple columns, order by clause

Inline Query should accept multiple columns, and ORDER BY clause

example:
SELECT [No.], Name FROM Customer ORDER BY Name

Need to have a new method "AsRecord" in "Inline Query" codeunit that should accept the following parameters:

  1. Query Text - The above syntax shoule be supported.
  2. RecordRef (Reference type) - WHERE clause (Filters) and ORDER BY clause (Key) should be applied on this Parameter.

INSERT Statement

To insert a record in to a table.

example:
INSERT INTO [Sales Line] ([Document Type], [Document No.], [Line No.], Type, [No.], Quantity) VALUES ('Order', 'ORD-001', 10000, 'Item', 'I-001', 10)

Grid doesn't appear

i tried to install your project on mine, but it doesn't show me the grid layout. only json works.
issue

AsJson method in Inline Query Codeunit

"Inline Query" codeunit should have "AsJson" method that should export Query result as Json Array.

example:
JCustomers := InlineQuery.AsJson('SELECT [No.] as code, [Name] as customer_name FROM [Customer]')

Columns should accept Json property names
example:
[No.] as code

In the syntax, "No." is the field name, "code" is the property name in the Json Object.

output:
[{ "code": "C001", customer_name: "ABC"} , { "code": "C002", customer_name: "XYZ"}]

Performance and subqueries

I am currently running 2 Query objects to retrieve a combined result. I was thinking of replacing them with one call with the inline query. I have 2 questions:

  1. In the MS Journal blog information under "Limitations / Disadvantages" it is stated that "It compiles the Query Text every time before executing. This is not good for performance.". How much of an impact is does the compilation have? I am trying to compare with 2 Query objects calling the same table with different subqueries.
  2. Can I do subqueries? I am trying to combine the 2 Query objects I am running today into one select query containing 2 subqueries.

Thank you.

UPDATE Statement

To update records in a Table.

example:
UPDATE [Sales Line] SET Quantity = 0 WHERE [Document Type] = 'Order' AND [Document No.]='ORD-001'

DELETE Statement

To delete records in a table.

example:
DELETE FROM [Sales Header] WHERE [Document Type] = 'Quote'

SELECT TOP Clause support

"Inline Query" should support TOP clause

example:
SELECT TOP 10 [No.] as code, Name as customer_name FROM Customer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.