About Row Number / Limit

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Hello there,
I want to use sql limit and line number.
How can I do that?

Code
Select ..... limit, 5

or
Code
Select rank () ....

or
Code
Select rownumber () .....

...
...
or
Code
   Query = New Query;
   Query.Text = "SELECT
                |   Table1.Code,
                |   Table1.Description ////using row number or limit ??
                |FROM
                |   Catalog.Table1 AS Table1";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();

Can you give an example?

Edited: Erdogan Uguz - Nov 18, 2016 01:15 AM
 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Erdogan, you can add TOP clause to the query:

Code
   Query = New Query;
   Query.Text = "SELECT TOP 10
                |   Table1.Code,
                |   Table1.Description 
                |FROM
                |   Catalog.Table1 AS Table1";
   
   QueryResult = Query.Execute();
   
   SelectionDetailRecords = QueryResult.Select();

 
#3
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

I want to make pagination.
Can I do it any other way?

I list the records with JSON.
Too many records.
I want to divide them (Paging).
I have to use it in the query for this.

How else can I do it?

 
#4
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Hello, Erdogan.

Maybe you could change the behavior to something better? In most cases you can't expect that the user will click on each page of the long list. Maybe you can display a message that there are N extra items in the database so the list is not full and add a button to export entire the list?

 
#5
People who like this:0Yes/0No
Interested
Rating: 27
Joined: Apr 5, 2012
Company: 1TÇ Şirketi - Merv Bilgi İşlem Otomasyonu Yazılım Ltd. Şti.

Hi, Erdoğan.

How I get your question, you need to get more data list in several pages that is related with row count and page maximum row count?

If question is true. You may examine an example that I prepared for you. External data processor message you how many pages can be created, will how many count in each page and totally how many rows in whole.

For that you need to open firstly 1TC:Ticaret Yönetimi + Genel Muhasebe configuration and then open data processor.

 
#6
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Wonderful...
Thank you so much. :)

 
#7
People who like this:0Yes/0No
Active user
Rating: 4
Joined: Feb 26, 2015
Company: Uguz Limited sirketi

Actually, I wanted to paginate.
I built a Web Store.
I list products by category.
I want to paginate it.

Pagination can be done using TSQL and PSQL. (Ms Sql Server, IBM DB2, Oracle, MySQL). It's very simple. We just need to write in the query. I wrote the examples in my first post. In ADO components, the RecordSet object can also paginate. How can we do this at 1C? I wanted to ask.

Is there a pagination for Query and RecordSet object in 1C?
Sample ;

Code
QueryResult.PageSize
..
or
..
RecordSet.PageSize
..
or
...


If not, I can use this file.
I also did it with JSON pagination.

 
#8
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Pagination is implemented in dynamic lists, but i'm afraid you can only emulate it in queries by skipping the required number of rows and returning ones that match the window.

 
#9
People who like this:0Yes/0No
Just came
Rating: 0
Joined: May 24, 2013
Company: 1C-Poland Sp. z o.o.

Hi Erdogan, you can make pagination with sequential access like that

Code
SELECT TOP <YourPageSize>
   Table1.Ref AS Ref,
   Table1.Code,
   Table1.Description
FROM
   Catalog.Table1 AS Table1
WHERE Table1.Ref>&LastPageRef

ORDER BY
   Ref

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.