Auto increment column

Stimulsoft Reports.PHP discussion
Post Reply
kaktusman69
Posts: 6
Joined: Thu Jun 23, 2016 1:18 pm

Auto increment column

Post by kaktusman69 »

Hello.

I need to create a column with auto increment, depending of the lines in Data Band.
Here is the solution for a simple MySQL query, http://stackoverflow.com/questions/1186 ... d-in-the-r, how can i adapt this functionality in a StimulSoft->DataSource->query.

Thanks,
Vadim
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Auto increment column

Post by Alex K. »

Hello,

You can use the system variable {Line} from the Dictionary on the data band for this task.

Thank you.
kaktusman69
Posts: 6
Joined: Thu Jun 23, 2016 1:18 pm

Re: Auto increment column

Post by kaktusman69 »

Hi Aleksey.

Thanks for the idea, but in my case i can't use.
For example: we have 'x' large chapters with subchapters, in a query, i make a "UNION" and receive the respective chapters with subchapters: [chapter 1 , chapter 2, ..., subchapter 1, ..., subchapter 10].
Now, i want to make a classification/ordering, to look like this:
1 Chapter 1
1.1 Subchapter 1
1.2 Subchapter 2
...
10 Chapter 10
10.1 Subchapter 10
...
In a simple MySQL query, i use the code from the link i've put above, but i can adopt to Data Source->query.

Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Auto increment column

Post by Alex K. »

Hello,

We need some additional time for investigating the issue. We will let you know about the result.

Thank you.
kaktusman69
Posts: 6
Joined: Thu Jun 23, 2016 1:18 pm

Re: Auto increment column

Post by kaktusman69 »

Thank you much, let me know about results.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Re: Auto increment column

Post by Ivan »

Hello,

Please check the sample report template in the attachment.
We used an additional variable and a script to organize autoincrement.
We do not have your data, so the example uses our database.
Let us know if you need any additional help.

Thank you.
Attachments
ReportSample.mrt
(8.51 KiB) Downloaded 526 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Auto increment column

Post by Alex K. »

Hello,

Also, you can use stored procedure for this task. In this case, you can create Stored Procedure for this task.

Code: Select all

CREATE DEFINER=`root`@`localhost` PROCEDURE `incrementSelect`()
BEGIN
SELECT  @s:=@s+1 serial_number, product_name, list_price
FROM    products,
        (SELECT @s:= 0) AS s;
END
And then use in the data source as:

Code: Select all

call incrementSelect();
But in this case, in PHP version you need to add all columns manually. In JS(HTML5) version retrieve columns works correctly.

Thank you.
Attachments
02.PNG
02.PNG (230.32 KiB) Viewed 4336 times
01.PNG
01.PNG (76.75 KiB) Viewed 4336 times
Post Reply