ROWID in *.dbf Files
Is there a way to get the recno() / ROWID as field from the *dbf File?
Answer
Yes indeed. Just use a CONNECT special column, for instance:
create table t1 (
id int(6) not null,
msg char(10),
recno int(4) not null default 0 special=rowid
) engine=connect table_type=DBF file_name='afile.dbf';
insert into t1(id,msg) values(2,'two'),(3,'three'),(5,'five');
select * from t1;
The table will be displayed like this:
id | msg | recno | ||||
2 | two | 1 | ||||
3 | three | 2 | ||||
5 | five | 3 |
This is true for all file based CONNECT tables. However, for DBF tables:
Note 1: The current CONNECT version has a bug that causes an error being raised when inserting in a new void table (because special columns are wrongly kept when writing the header) This will be fixed in next versions. Meanwhile, you can insert in a new void table with a table defined without the special column and later add the special column with an ALTER TABLE statement.
Note 2: If instead of a ROWID special column you use a ROWNUM special column, it will give the record number including the "soft" deleted lines.