SQL Structure

Cursor Syntax

Please refer to the image below containing SQL query and matching template.

AOP Plug-in supports PL/SQL cursor expressions which can be used in your templates as "data loops".

The left side corresponds to the SQL query that we used in our demo example. The right side is our Word template.

In a SQL query you will notice three inner cursors called data, orders and product.

The idea is for each customer to find orders and products and display it as an invoice letter.

The data cursor is a standard part of the AOP JSON structure and it needs to be present in all SQL queries. At the same time you do not have to specify it as a loop in your template.

Two other cursor names can be of your preference, as long as they are declared in your template.

Why do we use a cursor syntax?

This is the way AOP engine merges your data with your templates.

In our template example you want to display customer details (Data cursor) and then display all their orders (Orders cursor) with products (Product cursor) so each represents a separate cursor.

This means that we want to be able to create a loop for orders and a separate loop for products. This is exactly what we have done in this template.

The way AOP template loop works is by using {#loop element}….{/loop element} notation. In the template notice that we are using the following:

"Thank you for shopping. We have following products reserved for you:

    - {product_name}{/product}
The total amount of your order is €{order_total}.

First open Orders loop then open Product loop then doing a bullet numbering for all products. Before closing the Product loop and then closing the Orders loop.

Once you create your SQL query it is very easy to implement it in your template following few simple tagging rules depending on a template type you are creating.