Subject RE: [firebird-support] Printing to new page in Firebird 2.5.1
Author Svein Erling Tysvær
>Hi ALL,
>
>Pls help to print the following data:
>
>NO. ITEM Qty PageMark
>1 ABC 10 1
>2 BCD 20
>3 XYZ 30 2
>4 YZ 29 3
>
>Need to print out as follow in firebird 2.5.1
>
>PAGE HEADER
>
>Page 1:
>NO. ITEM QTY
>1 ABC 10
>2 BCD 20
>
>Page 2:
>No. ITEM QTY
>3 XYZ 30
>
>Page 3:
>No ITEM QTY
>4 YZ 29
>
>PAGE FOOTER
>
>THank you.
>ZIM

Hi ZIM!

Firebird is a database that returns datasets when you ask for it and has no knowledge about printers. So, printing the pages is something you have to do yourself in your application. What Firebird can do, is to return a dataset for a given page when you ask for it, e.g. (using MyNo rather than No as a fieldname, assuming PageMark is continuous without missing numbers and that MyNo never will be more than 999999999)

WITH TMP(MIN_NO, MAX_NO) AS
(SELECT M1.MYNO, COALESCE(M2.MYNO-1, 999999999)
FROM MY_TABLE M1
LEFT JOIN MY_TABLE M2 ON M1.PAGEMARK+1 = M2.PAGEMARK
WHERE M1.PAGEMARK = :PM)

SELECT M.MYNO, M.ITEM, M.QTY
FROM MY_TABLE M
JOIN TMP T ON M.MYNO BETWEEN T.MIN_NO AND T.MAX_NO
ORDER BY 1

HTH,
Set