-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_foreign_key_cluster_err.txt
48 lines (38 loc) · 1.45 KB
/
get_foreign_key_cluster_err.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
ARRAY LONGINT($tn;0)
ARRAY LONGINT($fn;0)
//N-field
Begin SQL
SELECT _USER_COLUMNS.TABLE_ID,_USER_COLUMNS.COLUMN_ID
FROM _USER_CONS_COLUMNS,_USER_COLUMNS,_USER_CONSTRAINTS,_USER_INDEXES,_USER_IND_COLUMNS
WHERE _USER_CONSTRAINTS.CONSTRAINT_TYPE= '4DR'
AND _USER_CONSTRAINTS.CONSTRAINT_ID = _USER_CONS_COLUMNS.CONSTRAINT_ID
AND _USER_COLUMNS.TABLE_ID = _USER_CONSTRAINTS.TABLE_ID
AND _USER_COLUMNS.COLUMN_ID = _USER_CONS_COLUMNS.COLUMN_ID
AND _USER_COLUMNS.TABLE_ID = _USER_IND_COLUMNS.TABLE_ID
AND _USER_COLUMNS.COLUMN_ID = _USER_IND_COLUMNS.COLUMN_ID
AND _USER_INDEXES.INDEX_ID = _USER_IND_COLUMNS.INDEX_ID
AND (_USER_INDEXES.INDEX_TYPE = 1 OR _USER_INDEXES.INDEX_TYPE = 7)
INTO :$tn,:$fn;
End SQL
MULTI SORT ARRAY($tn;>;$fn;>)
$results:=New collection
For ($i;1;Size of array($tn))
$t:=$tn{$i}
$f:=$fn{$i}
$tr:=0
$fr:=0
Begin SQL
SELECT _USER_CONSTRAINTS.RELATED_TABLE_ID,_USER_CONS_COLUMNS.RELATED_COLUMN_ID
FROM _USER_CONS_COLUMNS,_USER_COLUMNS,_USER_CONSTRAINTS
WHERE _USER_CONSTRAINTS.CONSTRAINT_TYPE= '4DR'
AND _USER_CONSTRAINTS.CONSTRAINT_ID = _USER_CONS_COLUMNS.CONSTRAINT_ID
AND _USER_CONS_COLUMNS.TABLE_ID = :$t
AND _USER_CONS_COLUMNS.COLUMN_ID = :$f
LIMIT 1
INTO :$tr,:$fr;
End SQL
$results.push(New collection(\
Parse formula("[:"+String($t)+"]:"+String($f);Formula out with tokens);\
Parse formula("[:"+String($tr)+"]:"+String($fr);Formula out with tokens)).join("\t"))
End for
SET TEXT TO PASTEBOARD($results.join("\r"))