[freetds] bcp, for browse and flags
Frediano.Ziglio at vodafoneomnitel.it
Tue Apr 29 05:10:30 EDT 2003
I work a bit on column flags. Server send information from column to client. I checked and updated these information including:
- column is a key
- column is writable
- column is an identity
- column is hidden
- column is nullable
TDS4.2 do not return many information (from a Sybase seem to return no information...).
If FOR BROWSE clause is specified (ie SELECT * FROM table_name FOR BROWSE) some additional (hidden) field are returned and flags like key and/or identity are returned. These flags should be useful in bcp (to discover what columns are keys).
If we have a table like (see also flags.c test in tds)
CREATE TABLE table_name
id NUMERIC(10,0) IDENTITY PRIMARY KEY, -- I used NUMERIC cause is more portable
b VARCHAR(10) NULL,
c INT NOT NULL
And do a "SELECT c,b FROM table_name FOR BROWSE" 3 columns are returned (TODO: do not show third column to client)
c: not nullable and writable (nullable not returned from TDS4.2)
b: nullable and writable (nullable not returned from TDS4.2)
id: writable, identity, key, hidden (some db do not return key for identity)
IMHO BCP should issue FOR BROWSE select and test if a column is key and/or identity (these flags are valid in all version of TDS). However I don't know how BCP should handle id/key fields... set identity_insert on ??? do not insert these field assuming db generate it (perhaps we lost foreign key) ??
More information about the FreeTDS