Coding error in test program?
Yes, see at:
Trim(FQuery.Fields[0].AsString) , ',' ,
Trim(FQuery.Fields[1].AsString) , ',' ,
Trim(FQuery.Fields[2].AsString)
When you select only 1 column, there are no Fields[1] and Fields[2] ... so this causes exception
(use loop and for example Fields.Count or FieldsCount)
Of course.
Thanks Lacak, seems I'm getting dumber and dumber. I should have just gone through the code, it stands out like a sore thumb.
Think it's time for a coding break now... so I'll just fiddle with my own stuff instead of bothering you
I tested also EXEC sp_helpindex 'master..syslogins' and also it returns, that "Object must be in current database"
Yep, same as in my JDBC query GUI.
Maybe switch to right database with "go <whatever db>" then execute the sp & back to current database with "go <currentdb"
... but the problem is probably to find out the right db?? Don't know if the tablename in
procedure UpdateIndexDefs(IndexDefs:TIndexDefs; TableName:string); override;
... or some other variable contains the db name as well!?!
Once we have the db name, we could of course also prefix the tables:
'select i.name, i.indid,' +
'index_col(object_name(i.id),i.indid,c.colid) as col_name,' +
'(i.status & 2)/2 as IsUnique,' +
'(i.status & 2048)/2048 as IsPrimaryKey ' +
'from ' + dbname + '.' + ownername +'.sysindexes i '+
' join ' + dbname + '.' + ownername +'.syscolumns c on c.id=i.id and c.colid<=i.keycnt-case i.indid when 1 then 0 else 1 end ' +
'where i.id=object_id(''%s'') '+
' and i.indid between 1 and 254 '+ // indid 0 is the table name, 255 is TEXT,IMAGE
'order by i.indid, c.colid'
or something...
But I'll just stop here, I'm afraid I'm starting to make less & less sense.