The EXEC SQL DECLARE receipt_cursor CURSOR FOR
SELECT * FROM (
SELECT the M1. *, ROWNUM RN FROM (
SELECT * FROM M21_RECEIPT_INFO M WHERE TELLER_NUMBER=: teller_number1 AND
SAVE_RESULT=: save_result1 AND TRANDE_TIME & lt;=: end_time AND TRANDE_TIME & gt; M1=: begin_time)
WHERE ROWNUM & lt; M2=10)
WHERE the M2. An RN & gt; 0;
The EXEC SQL OPEN receipt_cursor;//open the cursor
for(; I<=number; I++)
{
The EXEC SQL FETCH receipt_cursor INTO: receipt_tables;
If (I==1)
Snprintf (sFhnr, sizeof (sFhnr), "% s | s | | s | | s | | s | | | % d", receipt_tables. Receipt_number, receipt_tables. Trande_type, receipt_tables. Customer_name, receipt_tables. Trande_time, receipt_tables. Save_result, receipt_tables. Reprint_number);
The else
^ sprintf (sFhnr, "% s % s | s | | s | | s | | s | | | % d", sFhnr, receipt_tables. Receipt_number, receipt_tables. Trande_type, receipt_tables. Customer_name, receipt_tables. Trande_time, receipt_tables. Save_result, receipt_tables. Reprint_number);
}
The EXEC SQL CLOSE receipt_cursor;//close the cursor
CodePudding user response:
SELECT *, ROWNUM RN FROM M21_RECEIPT_INFO M WHERE TELLER_NUMBER=: teller_number1 ANDSAVE_RESULT=: save_result1 AND TRANDE_TIME & lt;=: end_time AND TRANDE_TIME & gt; M1=: begin_time)
WHERE ROWNUM & lt;=10
?
CodePudding user response:
Agree with upstairsSELECT *, ROWNUM RN FROM M21_RECEIPT_INFO M WHERE TELLER_NUMBER=: teller_number1 AND
SAVE_RESULT=: save_result1 AND TRANDE_TIME & lt;=: end_time AND TRANDE_TIME & gt; M1=: begin_time)
WHERE ROWNUM & lt;=10
CodePudding user response:
When directly use rownum doing conditions must contain rownum=0, for example,Select * from a
Where rownum & lt;=10;
Need to query does not contain 0, need the rownum as solid column, such as
Select * from
(
Select a. *, rownum as an rn from a
B)
Where b.r n between 6 and 10;