Using stored procedures to achieve paging printing

Source: Internet
Author: User
Tags insert rowcount
Stored Procedures | printing | pagination

Use stored procedures to achieve paging printing.

This stored procedure is a community broadband user management system, part of the project code.

Features are:
The realization of the table UserInfo user data in the IP network segment sorting to print paging!!
For example, 172.20.128.XX IP referred to as 128 network segment of users,
172.20.119.XX IP abbreviation for 119 users of the network segment,

Each segment of the user is printed on a A4 sheet of paper,
Less than one sheet of print, the rest can be vacated.
More than one sheet of less than two, press two print, the rest is empty.
A maximum of 37 lines can be printed on an estimated page.
The idea is: first select out of the user information by IP group and the calculated space line insert into a temporary table
Then you can print more of this temporary table.



--First clear the table
--truncate Table Subip

DECLARE @result int
DECLARE @subip varchar (20)
DECLARE cur_e scroll cursor for
Select substring (ip_address,8,3) from UserInfo Group by substring (ip_address,8,3)

Open cur_e--Cursor
--print ' AAA ' +convert (char (), @ @cursor_rows)
Fetch the cur_e into @subip

while (@ @fetch_status =0)
Begin
--insert into Subip (SUPIP) VALUES (@subip)
Insert INTO SUBIP select Userinfo.username,userinfo.catalyst_port,userinfo.home_address,
Userinfo.ip_address,userinfo.phone,catalyst.label, "from UserInfo,
Catalyst where userinfo.catalyst_id=catalyst.id and substring (userinfo.ip_address,8,3) = @subip
Set @result =@ @rowcount
if (@result >37)
Begin
while (@result <74)
Begin
INSERT INTO SUBIP Select

Username= ', catalyst_port= ', home_address= ', ip_address= ', phone= ', label= ', account= '
Set @result = @result +1
End
End
Else
Begin
while (@result <37)
Begin
INSERT INTO SUBIP Select

Username= ', catalyst_port= ', home_address= ', ip_address= ', phone= ', label= ', account= '
Set @result = @result +1
End
End
--select @ @rowcount
FETCH NEXT from Cur_e into @subip
End
Close Cur_e
Deallocate cur_e


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: info-contact@alibabacloud.com 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.