How to invoke a segment of SQL statement via JS

Source: Internet
Author: User

How to invoke a SQL statement via JS is common in the development of reports and data platforms. Take the report platform Finereport Development as an example, for example, after clicking on a button, determine the number of database bars, and then decide what to do next. So how does this work in the background?

Solution Ideas

Realize this function, first need to understand finereport built-in formula, SQL function, this Ken can everybody understand, do not introduce.

Call Finerepor's built-in formula: Fr.remoteevaluate ("concrete formula"), the return value is: The result of this specific formula.

For example: var a = Fr.remoteevaluate ("sum (1+2)");

At this point, the value of variable A is 3.

It is important to note that since you need to use double quotation marks (") multiple times in the SQL function, you should be aware of escaping with a backslash (\): var sql =" SQL (\ "frdemo\", \ "SELECT COUNT (*) fromsales_basic\", )"

Or to reduce the complexity of escaping, you can write the following format: Var sql= "SELECT COUNT (*) from Sales_basic"; Varres=fr.remoteevaluate (' SQL ' ("Frdemo", "' +sql+ '", 1, 1) ');

Add a button to the parameters panel and write the following SQL in the button's Click event:

var sql = "SQL (\" frdemo\ ", \" SELECT COUNT (*) fromsales_basic\ ",") "Alert (sql); var count = fr.remoteevaluate (SQL); alert (Count);

650) this.width=650; "Src=" Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center "Width=" 831 "height=" 418 "/>

Pagination Preview template, click the button, the effect is as follows:

650) this.width=650; "Src=" Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center "Width=" 834 "height=" 627 "/>

650) this.width=650; "Src=" Ahr0cdovl2jsb2cuy3nkbi5uzxqv/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/center "Width=" 782 "height=" 588 "/>

How to invoke a segment of SQL statement via JS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.