DatabaseProcApplicationCreatedLinks
sybsystemprocssp_odbc_fkeys  14 déc. 14Defects Propagation Dependencies

1     
2     
3     /* sccsid = "%Z% generic/sproc/src/%M% %I% %G%" */
4     /*
5     ** note: there is one raiserror message: 18040
6     **
7     ** messages for "sp_odbc_fkeys"               18039, 18040
8     **
9     ** 17461, "Object does not exist in this database." 
10    ** 18040, "Catalog procedure %1! can not be run in a transaction.", sp_odbc_fkeys
11    ** 18043 " Primary key table name or foreign key table name or both must be 
12    ** given"
13    ** 18044, "%1! table qualifier must be name of current database." [Primary
14    ** key | Foreign key]
15    **
16    */
17    CREATE OR REPLACE PROCEDURE sp_odbc_fkeys
18        @pktable_name varchar(255) = null,
19        @pktable_owner varchar(32) = null,
20        @pktable_qualifier varchar(32) = null,
21        @fktable_name varchar(255) = null,
22        @fktable_owner varchar(32) = null,
23        @fktable_qualifier varchar(32) = null
24    as
25        declare @ftabid int, @ptabid int, @constrid int, @keycnt int, @i int
26        declare @fokey1 int, @fokey2 int, @fokey3 int, @fokey4 int, @fokey5 int
27        declare @fokey6 int, @fokey7 int, @fokey8 int, @fokey9 int, @fokey10 int
28        declare @fokey11 int, @fokey12 int, @fokey13 int, @fokey14 int, @fokey15 int
29        declare @refkey1 int, @refkey2 int, @refkey3 int, @refkey4 int, @refkey5 int
30        declare @refkey6 int, @refkey7 int, @refkey8 int, @refkey9 int, @refkey10 int
31        declare @refkey11 int, @refkey12 int, @refkey13 int, @refkey14 int
32        declare @refkey15 int, @refkey16 int, @fokey16 int, @status int
33        declare @msg varchar(1024)
34        declare @msg2 varchar(1024)
35        declare @ordpkey int
36        declare @notDeferrable smallint
37        declare @startedInTransaction bit
38        if (@@trancount > 0)
39            select @startedInTransaction = 1
40        else
41            select @startedInTransaction = 0
42    
43        set nocount on
44    
45        if (@@trancount = 0)
46        begin
47            set chained off
48        end
49    
50        set transaction isolation level 1
51    
52        if (@startedInTransaction = 1)
53            save transaction odbc_keep_temptable_tx
54    
55        select @notDeferrable = 7
56    
57        if (@pktable_name is null) and (@fktable_name is null)
58        begin
59            /* If neither primary key nor foreign key table names given */
60            /* 
61            ** 18043 "Primary key table name or foreign key table name 
62            ** or both must be given"
63            */
64            raiserror 18043
65            return (1)
66        end
67    
68        if @fktable_qualifier is not null
69        begin
70            if db_name() != @fktable_qualifier
71            begin
72                /* If qualifier doesn't match current database */
73                /* 18044 "%1! Table qualifier must be name of current database"
74                ** 18050 "Foreign key"
75                */
76                exec sp_getmessage 18050, @msg2 output
77                raiserror 18044, @msg2
78                return (1)
79            end
80        end
81        else
82        begin
83            /*
84            ** Now make sure that foreign table qualifier is pointing to the
85            ** current database in case it is not specified.
86            */
87            select @fktable_qualifier = db_name()
88        end
89    
90        if @pktable_qualifier is not null
91        begin
92            if db_name() != @pktable_qualifier
93            begin
94                /* If qualifier doesn't match current database */
95                /* 18044 "%1! Table qualifier must be name of current database"
96                ** 18051 "Primary Key"
97                */
98                exec sp_getmessage 18051, @msg2 output
99                raiserror 18044, @msg2
100               return (1)
101           end
102       end
103       else
104       begin
105           /*
106           ** Now make sure that primary table qualifier is pointing to the
107           ** current database in case it is not specified.
108           */
109           select @pktable_qualifier = db_name()
110       end
111   
112   
113       create table #opid(pid int, uid int, name varchar(255))
114       create table #ofid(fid int, uid int, name varchar(255))
115   
116       /* we will sort by fkey		*/
117       /* unless pktable is null	*/
118   
119       select @ordpkey = 0
120   
121       if @pktable_name is not null
122       begin
123   
124           if (@pktable_owner is null)
125           begin
126               /* 
127               ** owner is NULL, so default to the current user
128               ** who owns this table, otherwise default to dbo
129               ** who owns this table.
130               */
131               insert into #opid
132               select id, uid, name
133               from sysobjects
134               where name = @pktable_name and uid = user_id()
135                   and type in ("S", "U")
136   
137               /* 
138               ** If the current user does not own the table, see
139               ** if the DBO of the current database owns the table.
140               */
141   
142               if ((select count(*) from #opid) = 0)
143               begin
144                   insert into #opid
145                   select id, uid, name
146                   from sysobjects
147                   where name = @pktable_name and uid = 1
148                       and type in ("S", "U")
149               end
150           end
151           else
152           begin
153               insert into #opid
154               select id, uid, name
155               from sysobjects
156               where name = @pktable_name
157                   and uid = user_id(@pktable_owner)
158                   and type in ("S", "U")
159           end
160       end
161       else
162       begin
163           if (@pktable_owner is null)
164           begin
165               /* 
166               ** If neither pktable_name nor pktable_owner is specified,
167               ** then we are interested in every user or system table.
168               */
169               insert into #opid
170               select id, uid, name
171               from sysobjects
172               where type in ("S", "U")
173           end
174           else
175           begin
176               insert into #opid
177               select id, uid, name
178               from sysobjects
179               where uid = user_id(@pktable_owner)
180                   and type in ("S", "U")
181           end
182       end
183   
184       if @fktable_name is not null
185       begin
186           /* sort by pkey	*/
187           select @ordpkey = 1
188   
189           if (@fktable_owner is null)
190           begin
191               /* 
192               ** owner is NULL, so default to the current user
193               ** who owns this table, otherwise default to dbo
194               ** who owns this table.
195               */
196               insert into #ofid
197               select id, uid, name
198               from sysobjects
199               where name = @fktable_name and uid = user_id()
200                   and type in ("S", "U")
201   
202               /* 
203               ** If the current user does not own the table, see
204               ** if the DBO of the current database owns the table.
205               */
206   
207               if ((select count(*) from #opid) = 0)
208               begin
209                   insert into #ofid
210                   select id, uid, name
211                   from sysobjects
212                   where name = @fktable_name and uid = 1
213                       and type in ("S", "U")
214               end
215           end
216           else
217           begin
218               insert into #ofid
219               select id, uid, name
220               from sysobjects
221               where name = @fktable_name
222                   and uid = user_id(@fktable_owner)
223                   and type in ("S", "U")
224           end
225       end
226       else
227       begin
228           if (@fktable_owner is null)
229           begin
230               /* 
231               ** If neither fktable_name nor fktable_owner is specified,
232               ** then we are interested in every user table or systme 
233               ** table.
234               */
235               insert into #ofid
236               select id, uid, name
237               from sysobjects
238               where type in ("S", "U")
239           end
240           else
241           begin
242               insert into #ofid
243               select id, uid, name
244               from sysobjects
245               where uid = user_id(@fktable_owner)
246                   and type in ("S", "U")
247           end
248       end
249   
250       if (((select count(*) from #ofid) = 0) or
251               ((select count(*) from #opid) = 0))
252       begin
253           /* 17461, "Object does not exist in this database." */
254           raiserror 17461
255           return (1)
256       end
257   
258       create table #ofkey_res(PKTABLE_CAT varchar(32),
259           PKTABLE_SCHEM varchar(32),
260           PKTABLE_NAME varchar(255),
261           PKCOLUMN_NAME varchar(255),
262           FKTABLE_CAT varchar(32),
263           FKTABLE_SCHEM varchar(32),
264           FKTABLE_NAME varchar(255),
265           FKCOLUMN_NAME varchar(255),
266           KEY_SEQ smallint,
267           UPDATE_RULE smallint,
268           DELETE_RULE smallint,
269           FK_NAME varchar(255),
270           PK_NAME varchar(255))
271       create table #opkeys(seq int, keys varchar(255) null)
272       create table #ofkeys(seq int, keys varchar(255) null)
273   
274       /*
275       ** Since there are possibly multiple rows in sysreferences
276       ** that describe foreign and primary key relationships among
277       ** two tables, so we declare a cursor on the selection from
278       ** sysreferences and process the output at row by row basis.
279       */
280   
281       declare curs_sysreferences cursor
282       for
283       select tableid, reftabid, constrid, keycnt,
284           fokey1, fokey2, fokey3, fokey4, fokey5, fokey6, fokey7, fokey8,
285           fokey9, fokey10, fokey11, fokey12, fokey13, fokey14, fokey15,
286           fokey16, refkey1, refkey2, refkey3, refkey4, refkey5,
287           refkey6, refkey7, refkey8, refkey9, refkey10, refkey11,
288           refkey12, refkey13, refkey14, refkey15, refkey16
289       from sysreferences
290       where tableid in (
291               select fid from #ofid)
292           and reftabid in (
293               select pid from #opid)
294           and frgndbname is NULL and pmrydbname is NULL
295       for read only
296   
297       open curs_sysreferences
298   
299       fetch curs_sysreferences into @ftabid, @ptabid, @constrid, @keycnt, @fokey1,
300           @fokey2, @fokey3, @fokey4, @fokey5, @fokey6, @fokey7, @fokey8,
301           @fokey9, @fokey10, @fokey11, @fokey12, @fokey13, @fokey14, @fokey15,
302           @fokey16, @refkey1, @refkey2, @refkey3, @refkey4, @refkey5, @refkey6,
303           @refkey7, @refkey8, @refkey9, @refkey10, @refkey11, @refkey12,
304           @refkey13, @refkey14, @refkey15, @refkey16
305   
306       while (@@sqlstatus = 0)
307       begin
308           /*
309           ** For each row of sysreferences which describes a foreign-
310           ** primary key relationship, do the following.
311           */
312   
313           /*
314           ** First store the column names that belong to primary keys
315           ** in table #pkeys for later retrieval.
316           */
317   
318           delete #opkeys
319           insert #opkeys values (1, col_name(@ptabid, @refkey1))
320           insert #opkeys values (2, col_name(@ptabid, @refkey2))
321           insert #opkeys values (3, col_name(@ptabid, @refkey3))
322           insert #opkeys values (4, col_name(@ptabid, @refkey4))
323           insert #opkeys values (5, col_name(@ptabid, @refkey5))
324           insert #opkeys values (6, col_name(@ptabid, @refkey6))
325           insert #opkeys values (7, col_name(@ptabid, @refkey7))
326           insert #opkeys values (8, col_name(@ptabid, @refkey8))
327           insert #opkeys values (9, col_name(@ptabid, @refkey9))
328           insert #opkeys values (10, col_name(@ptabid, @refkey10))
329           insert #opkeys values (11, col_name(@ptabid, @refkey11))
330           insert #opkeys values (12, col_name(@ptabid, @refkey12))
331           insert #opkeys values (13, col_name(@ptabid, @refkey13))
332           insert #opkeys values (14, col_name(@ptabid, @refkey14))
333           insert #opkeys values (15, col_name(@ptabid, @refkey15))
334           insert #opkeys values (16, col_name(@ptabid, @refkey16))
335   
336           /*
337           ** Second store the column names that belong to foreign keys
338           ** in table #fkeys for later retrieval.
339           */
340   
341           delete #ofkeys
342           insert #ofkeys values (1, col_name(@ftabid, @fokey1))
343           insert #ofkeys values (2, col_name(@ftabid, @fokey2))
344           insert #ofkeys values (3, col_name(@ftabid, @fokey3))
345           insert #ofkeys values (4, col_name(@ftabid, @fokey4))
346           insert #ofkeys values (5, col_name(@ftabid, @fokey5))
347           insert #ofkeys values (6, col_name(@ftabid, @fokey6))
348           insert #ofkeys values (7, col_name(@ftabid, @fokey7))
349           insert #ofkeys values (8, col_name(@ftabid, @fokey8))
350           insert #ofkeys values (9, col_name(@ftabid, @fokey9))
351           insert #ofkeys values (10, col_name(@ftabid, @fokey10))
352           insert #ofkeys values (11, col_name(@ftabid, @fokey11))
353           insert #ofkeys values (12, col_name(@ftabid, @fokey12))
354           insert #ofkeys values (13, col_name(@ftabid, @fokey13))
355           insert #ofkeys values (14, col_name(@ftabid, @fokey14))
356           insert #ofkeys values (15, col_name(@ftabid, @fokey15))
357           insert #ofkeys values (16, col_name(@ftabid, @fokey16))
358   
359           /* 
360           ** For each column of the current foreign-primary key relation,
361           ** create a row into result table: #fkey_res.
362           */
363   
364           select @i = 1
365           while (@i <= @keycnt)
366           begin
367               insert into #ofkey_res
368               select @pktable_qualifier,
369                       (select user_name(uid) from #opid where pid = @ptabid),
370                   object_name(@ptabid),
371                       (select keys from #opkeys where seq = @i),
372                   @fktable_qualifier,
373                       (select user_name(uid) from #ofid where fid = @ftabid),
374                   object_name(@ftabid),
375                       (select keys from #ofkeys where seq = @i), @i,
376                   1, 1,
377                   /* Foreign Key */
378                   object_name(@constrid),
379                       /* Primary key name */
380                       (select name from sysindexes where id = @ptabid
381                           and status > 2048 and status < 32768)
382               select @i = @i + 1
383           end
384   
385           /* 
386           ** Go to the next foreign-primary key relationship if any.
387           */
388   
389           fetch curs_sysreferences into @ftabid, @ptabid, @constrid, @keycnt, @fokey1,
390               @fokey2, @fokey3, @fokey4, @fokey5, @fokey6, @fokey7, @fokey8,
391               @fokey9, @fokey10, @fokey11, @fokey12, @fokey13, @fokey14, @fokey15,
392               @fokey16, @refkey1, @refkey2, @refkey3, @refkey4, @refkey5, @refkey6,
393               @refkey7, @refkey8, @refkey9, @refkey10, @refkey11, @refkey12,
394               @refkey13, @refkey14, @refkey15, @refkey16
395       end
396   
397       close curs_sysreferences
398       deallocate cursor curs_sysreferences
399   
400       /*
401       ** Everything is now in the result table #fkey_res, so go ahead
402       ** and select from the table now.
403       */
404   
405       /* if @ordpkey = 0 sort by fkey */
406       /* else sort by pkey		*/
407       if @ordpkey = 0
408       begin
409           select PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME,
410               PKCOLUMN_NAME, FKTABLE_CAT, FKTABLE_SCHEM,
411               FKTABLE_NAME, FKCOLUMN_NAME, KEY_SEQ, UPDATE_RULE, DELETE_RULE,
412               FK_NAME, PK_NAME, @notDeferrable as DEFERRABILITY
413           from #ofkey_res
414           order by FKTABLE_NAME, FKTABLE_SCHEM, KEY_SEQ, FKTABLE_CAT
415       end
416       else
417       begin
418           select PKTABLE_CAT, PKTABLE_SCHEM, PKTABLE_NAME,
419               PKCOLUMN_NAME, FKTABLE_CAT, FKTABLE_SCHEM,
420               FKTABLE_NAME, FKCOLUMN_NAME, KEY_SEQ, UPDATE_RULE, DELETE_RULE,
421               FK_NAME, PK_NAME, @notDeferrable as DEFERRABILITY
422           from #ofkey_res
423           order by PKTABLE_NAME, PKTABLE_SCHEM, KEY_SEQ, PKTABLE_CAT
424       end
425   
426       drop table #opkeys
427       drop table #ofkeys
428       drop table #ofkey_res
429       if (@startedInTransaction = 1)
430           rollback transaction odbc_keep_temptable_tx
431   
432   


exec sp_procxmode 'sp_odbc_fkeys', 'AnyMode'
go

Grant Execute on sp_odbc_fkeys to public
go
RESULT SETS
sp_odbc_fkeys_rset_002
sp_odbc_fkeys_rset_001

DEFECTS
 MTYP 4 Assignment type mismatch KEY_SEQ: smallint = int 375
 QCSC 4 Costly 'select count()', use 'exists()' 142
 QCSC 4 Costly 'select count()', use 'exists()' 207
 QCSC 4 Costly 'select count()', use 'exists()' 250
 QCSC 4 Costly 'select count()', use 'exists()' 251
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: sysobjects.ncsysobjects unique
(name, uid)
Intersection: {uid}
179
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: sysobjects.ncsysobjects unique
(name, uid)
Intersection: {uid}
245
 QPUI 4 Join or Sarg with Un-Rooted Partial Index Use SARG Candidate index: sysreferences.csysreferences clustered
(tableid, frgndbname)
Intersection: {frgndbname}
294
 QTYP 4 Comparison type mismatch Comparison type mismatch: smallint vs int 381
 TNOU 4 Table with no unique index sybsystemprocs..sysreferences sybsystemprocs..sysreferences
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 132
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 145
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 154
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 170
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 177
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 197
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 210
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 219
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 236
 MAW1 3 Warning message on %name% sybsystemprocs..sysobjects.id: Warning message on sysobjects 243
 MAW1 3 Warning message on %name% sybsystemprocs..sysindexes.id: Warning message on sysindexes 380
 MGTP 3 Grant to public sybsystemprocs..sp_odbc_fkeys  
 MGTP 3 Grant to public sybsystemprocs..sysindexes  
 MGTP 3 Grant to public sybsystemprocs..sysobjects  
 MGTP 3 Grant to public sybsystemprocs..sysreferences  
 MNER 3 No Error Check should check return value of exec 76
 MNER 3 No Error Check should check return value of exec 98
 MNER 3 No Error Check should check @@error after insert 131
 MNER 3 No Error Check should check @@error after insert 144
 MNER 3 No Error Check should check @@error after insert 153
 MNER 3 No Error Check should check @@error after insert 169
 MNER 3 No Error Check should check @@error after insert 176
 MNER 3 No Error Check should check @@error after insert 196
 MNER 3 No Error Check should check @@error after insert 209
 MNER 3 No Error Check should check @@error after insert 218
 MNER 3 No Error Check should check @@error after insert 235
 MNER 3 No Error Check should check @@error after insert 242
 MNER 3 No Error Check should check @@error after delete 318
 MNER 3 No Error Check should check @@error after insert 319
 MNER 3 No Error Check should check @@error after insert 320
 MNER 3 No Error Check should check @@error after insert 321
 MNER 3 No Error Check should check @@error after insert 322
 MNER 3 No Error Check should check @@error after insert 323
 MNER 3 No Error Check should check @@error after insert 324
 MNER 3 No Error Check should check @@error after insert 325
 MNER 3 No Error Check should check @@error after insert 326
 MNER 3 No Error Check should check @@error after insert 327
 MNER 3 No Error Check should check @@error after insert 328
 MNER 3 No Error Check should check @@error after insert 329
 MNER 3 No Error Check should check @@error after insert 330
 MNER 3 No Error Check should check @@error after insert 331
 MNER 3 No Error Check should check @@error after insert 332
 MNER 3 No Error Check should check @@error after insert 333
 MNER 3 No Error Check should check @@error after insert 334
 MNER 3 No Error Check should check @@error after delete 341
 MNER 3 No Error Check should check @@error after insert 342
 MNER 3 No Error Check should check @@error after insert 343
 MNER 3 No Error Check should check @@error after insert 344
 MNER 3 No Error Check should check @@error after insert 345
 MNER 3 No Error Check should check @@error after insert 346
 MNER 3 No Error Check should check @@error after insert 347
 MNER 3 No Error Check should check @@error after insert 348
 MNER 3 No Error Check should check @@error after insert 349
 MNER 3 No Error Check should check @@error after insert 350
 MNER 3 No Error Check should check @@error after insert 351
 MNER 3 No Error Check should check @@error after insert 352
 MNER 3 No Error Check should check @@error after insert 353
 MNER 3 No Error Check should check @@error after insert 354
 MNER 3 No Error Check should check @@error after insert 355
 MNER 3 No Error Check should check @@error after insert 356
 MNER 3 No Error Check should check @@error after insert 357
 MNER 3 No Error Check should check @@error after insert 367
 MUCO 3 Useless Code Useless Brackets 38
 MUCO 3 Useless Code Useless Brackets 45
 MUCO 3 Useless Code Useless Brackets 52
 MUCO 3 Useless Code Useless Brackets 65
 MUCO 3 Useless Code Useless Brackets 78
 MUCO 3 Useless Code Useless Brackets 100
 MUCO 3 Useless Code Useless Brackets 124
 MUCO 3 Useless Code Useless Brackets 142
 MUCO 3 Useless Code Useless Brackets 163
 MUCO 3 Useless Code Useless Brackets 189
 MUCO 3 Useless Code Useless Brackets 207
 MUCO 3 Useless Code Useless Brackets 228
 MUCO 3 Useless Code Useless Brackets 250
 MUCO 3 Useless Code Useless Brackets 255
 MUCO 3 Useless Code Useless Brackets 306
 MUCO 3 Useless Code Useless Brackets 365
 MUCO 3 Useless Code Useless Brackets 429
 MUIN 3 Column created using implicit nullability 113
 MUIN 3 Column created using implicit nullability 114
 MUIN 3 Column created using implicit nullability 258
 MUIN 3 Column created using implicit nullability 271
 MUIN 3 Column created using implicit nullability 272
 QCRS 3 Conditional Result Set 409
 QCRS 3 Conditional Result Set 418
 QISO 3 Set isolation level 50
 QJWT 3 Join or Sarg Without Index on temp table 290
 QJWT 3 Join or Sarg Without Index on temp table 292
 QPRI 3 Join or Sarg with Rooted Partial Index Use SARG Candidate index: sysindexes.csysindexes unique clustered
(id, indid)
Intersection: {id}
380
 VUNU 3 Variable is not used @status 32
 VUNU 3 Variable is not used @msg 33
 CRDO 2 Read Only Cursor Marker (has for read only clause) 283
 MRST 2 Result Set Marker 409
 MRST 2 Result Set Marker 418
 MSUB 2 Subquery Marker 369
 MSUB 2 Subquery Marker 371
 MSUB 2 Subquery Marker 373
 MSUB 2 Subquery Marker 375
 MSUB 2 Subquery Marker 380
 MTR1 2 Metrics: Comments Ratio Comments: 24% 17
 MTR2 2 Metrics: Cyclomatic Complexity Cyclo: 24 = 27dec - 5exi + 2 17
 MTR3 2 Metrics: Query Complexity Complexity: 252 17

DATA PROPAGATION detailed
ColumnWritten To
@fktable_qualifiersp_odbc_fkeys_rset_001.FKTABLE_CAT sp_odbc_fkeys_rset_002.FKTABLE_CAT
@pktable_qualifiersp_odbc_fkeys_rset_001.PKTABLE_CAT sp_odbc_fkeys_rset_002.PKTABLE_CAT

DEPENDENCIES
PROCS AND TABLES USED
reads table sybsystemprocs..sysreferences  
reads table sybsystemprocs..sysobjects  
read_writes table tempdb..#opkeys (1) 
read_writes table tempdb..#ofid (1) 
calls proc sybsystemprocs..sp_getmessage  
   reads table sybsystemprocs..sysusermessages  
   reads table master..syslanguages (1)  
   reads table master..sysmessages (1)  
   calls proc sybsystemprocs..sp_validlang  
      reads table master..syslanguages (1)  
read_writes table tempdb..#opid (1) 
writes table sybsystemprocs..sp_odbc_fkeys_rset_001 
read_writes table tempdb..#ofkeys (1) 
read_writes table tempdb..#ofkey_res (1) 
writes table sybsystemprocs..sp_odbc_fkeys_rset_002 
reads table sybsystemprocs..sysindexes