Question

Yesterday I have given an exam in that one question is asked something like this:

We have table named tbl_demo, it has 30 records.

If we give following command in order,

GO BOTTOM then SKIP 3

What happen if this both command executes in that order ?

will it came to record number 3rd or 28th ?

3rd because it will goes bottom then skip 3 will execute so went to 3rd record.

or it will came up to 28th record, go bottom then skip 3, so it at last then skip 3 so no record so back 3 records.

or other thing will happen ?

Anyone have idea that what this command actually do if we execute in given order ?

Was it helpful?

Solution

In this general frame you are putting the question into, I'd say this is undefined behaviour.

Common behaviours are to begin again and end up with record 3 or 4 (if 1 is the first record) or throwing an error.

OTHER TIPS

Isn't it 4th record?The GO BOTTOM command shifts the control to the bottom of the database and then the SKIP 3 command skips three records so ultimately the control gets transferred to the 4th record.

GO Moves the record pointer to the specified record number.

BOTTOM Positions the record pointer on the last record in the table. If the table has an ascending index in use, the last record is the record with the highest key value. If the index is in descending order, the last record is the record with the lowest key value.

SKIP [nRecords]

nRecords:

Specifies the number of records to move the record pointer. Issuing SKIP without nRecords advances the record pointer to the next record. The record pointer moves toward the end of the file nRecords records if nRecords evaluates to a positive number. The record pointer moves toward the beginning of the file nRecords records if nRecords evaluates to a negative number.

here nRecords = 3.

Go BOTTOM will go to record no 30. Then SKIP 3 means skipping 30,29,28.

it means the control is now at 27. So the answer is 27.

This question is taken from UGC NET 2013 December paper 2 question no 12. UGC has given official answer i.e. 27.

https://msdn.microsoft.com/en-us/library/aa977827

https://msdn.microsoft.com/en-us/library/aa978459

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top