× Heads up!

Aqua Data Studio / nhilam

Follow
IDE for Relational Databases
×
tomconrad reported Aug 24, 2017  · nhilam last modified Sep 26, 2017

Sybase ASE - Script and Describe of Foreign key extraction when target table resides in different database not working.


customer request
Priority Low
Complexity Unknown
Component DB - Sybase ASE
Version 18.0
When using the following features on Sybase ASE:
 
                Scribe Object to (New) Window -> Create (Full)
                Describe Table (Ctrl+D)
 
They both appear to be displaying incorrect information regarding Foreign Key Relationships for Cross Database Constraints. In my specific instance,  a different table and column is displayed for the Foreign Key. For Example:
 
Displayed Text (for a Table in the “Customer” database):
ALTER TABLE dbo.LumbeeCircuit
   ADD CONSTRAINT FK_LumbeeCircuit_EmpCreatedId
   FOREIGN KEY(EmpCreatedId)
   REFERENCES Cash.dbo.TransactionAccount(TransId)
 
Actual Relationship:
ALTER TABLE dbo.LumbeeCircuit
   ADD CONSTRAINT FK_LumbeeCircuit_EmpCreatedId
   FOREIGN KEY(EmpCreatedId)
   REFERENCES Cash.dbo.Employee(EmployeeId)
 
 
Or with the describe command:
CONSTRAINTS:
  FOREIGN KEY: FK_LumbeeCircuit_EmpCreatedId (EmpCreatedId) references TransactionAccount(TransId)
 
But it should say:
CONSTRAINTS:
  FOREIGN KEY: FK_LumbeeCircuit_EmpCreatedId (EmpCreatedId) references Cash.dbo.Employee(EmployeeId)
 
I have verified that the relationship is created as it should using the built-in sp_helpconstraint Sybase ASE command. Watching some of the network traffic when ADS is generating this information, this query appears to return some invalid data.
 
Query:
use cash 
go
SELECT su.name as table_schema, object_name(sr.tableid) table_name, sc1.name column_name, object_name(sr.constrid) const_name, 'FK' as ctype, '' key1, '' key2, '' key3, '' key4, '' key5, '' key6, '' key7, '' key8, '' key9, '' key10, '' key11, '' key12, '' key13, '' key14, '' key15, '' key16, '' key17, '' key18, '' key19, '' key20, '' key21, '' key22, '' key23, '' key24, '' key25, '' key26, '' key27, '' key28, '' key29, '' key30, '' key31, '' as checkText, pmrydbname, USER_NAME(ftab.uid), ftab.name, USER_NAME(rtab.uid), rtab.name, col_name(sr.tableid, sr.fokey1), col_name(sr.tableid, sr.fokey2), col_name(sr.tableid, sr.fokey3), col_name(sr.tableid, sr.fokey4), col_name(sr.tableid, sr.fokey5), col_name(sr.tableid, sr.fokey6), col_name(sr.tableid, sr.fokey7), col_name(sr.tableid, sr.fokey8), col_name(sr.tableid, sr.fokey9), col_name(sr.tableid, sr.fokey10), col_name(sr.tableid, sr.fokey11), col_name(sr.tableid, sr.fokey12), col_name(sr.tableid, sr.fokey13), col_name(sr.tableid, sr.fokey14), col_name(sr.tableid, sr.fokey15), col_name(sr.tableid, sr.fokey16), col_name(sr.reftabid, sr.refkey1), col_name(sr.reftabid, sr.refkey2), col_name(sr.reftabid, sr.refkey3), col_name(sr.reftabid, sr.refkey4), col_name(sr.reftabid, sr.refkey5), col_name(sr.reftabid, sr.refkey6), col_name(sr.reftabid, sr.refkey7), col_name(sr.reftabid, sr.refkey8), col_name(sr.reftabid, sr.refkey9), col_name(sr.reftabid, sr.refkey10), col_name(sr.reftabid, sr.refkey11), col_name(sr.reftabid, sr.refkey12), col_name(sr.reftabid, sr.refkey13), col_name(sr.reftabid, sr.refkey14), col_name(sr.reftabid, sr.refkey15), col_name(sr.reftabid, sr.refkey16), sr.status as status, 1 as status2, '' as segname, -1 as maxrowsperpage, 0 as indid, -1 as fill_factor, -1 as res_page_gap, sc1.colid, '' ord1, '' ord2, '' ord3, '' ord4, '' ord5, '' ord6, '' ord7, '' ord8, '' ord9, '' ord10, '' ord11, '' ord12, '' ord13, '' ord14, '' ord15, '' ord16, '' ord17, '' ord18, '' ord19, '' ord20, '' ord21, '' ord22, '' ord23, '' ord24, '........' ord25, '' ord26, '' ord27, '' ord28, '' ord29, '' ord30, '' ord31, null
 FROM customer..sysreferences sr
      , customer..syscolumns sc1
      , customer..syscolumns sc2
      , customer..syscolumns sc3
      , customer..syscolumns sc4
      , customer..syscolumns sc5
      , customer..syscolumns sc6
, customer..sysobjects so
, customer..sysusers su
, customer..sysobjects ftab
, sysobjects rtab 
WHERE sr.tableid*=sc1.id AND sr.fokey1*=sc1.colid AND sr.reftabid*=sc2.id 
AND sr.refkey1*=sc2.colid AND sr.tableid*=sc3.id AND sr.fokey2*=sc3.colid 
AND sr.reftabid*=sc4.id AND sr.refkey2*=sc4.colid AND sr.reftabid*=sc5.id 
AND sr.refkey2*=sc5.colid AND sr.reftabid*=sc6.id AND sr.refkey2*=sc6.colid 
AND sr.tableid=so.id AND so.uid=su.uid AND sr.tableid *= ftab.id 
and sr.reftabid *= rtab.id AND sr.frgndbname is null 
AND su.name = 'dbo' AND sr.tableid = object_id('customer.dbo.LumbeeCircuit')
 
Some of the output data
table_schema   table_name       column_name  const_name       ctype     name    pmrydbname    column41            name
dbo        (null)     EmpCreatedId   (null)     FK           LumbeeCircuit   Cash      dbo        Employee
dbo        (null)     CircuitId               (null)     FK           LumbeeCircuit   (null)     dbo        TransactionAccount
2 attachments
tomconrad   Aug 24, 2017
Field Old Value New Value
Description

When using the following features on Sybase ASE:

 

                Scribe Object to (New) Window -> Create (Full)

                Describe Table (Ctrl+D)

 

They both appear to be displaying incorrect information regarding Foreign Key Relationships for Cross Database Constraints. In my specific instance,  a different table and column is displayed for the Foreign Key. For Example:

 

Displayed Text (for a Table in the “Customer” database):

ALTER TABLE dbo.LumbeeCircuit
   ADD CONSTRAINT FK_LumbeeCircuit_EmpCreatedId
   FOREIGN KEY(EmpCreatedId)
   REFERENCES Cash.dbo.TransactionAccount(TransId)

 

Actual Relationship:

ALTER TABLE dbo.LumbeeCircuit    ADD CONSTRAINT FK_LumbeeCircuit_EmpCreatedId    FOREIGN KEY(EmpCreatedId)    REFERENCES Cash.dbo.Employee(EmployeeId)

 

 

Or with the describe command:

CONSTRAINTS:

  FOREIGN KEY: FK_LumbeeCircuit_EmpCreatedId (EmpCreatedId) references TransactionAccount(TransId)

 

But it should say:

CONSTRAINTS:

  FOREIGN KEY: FK_LumbeeCircuit_EmpCreatedId (EmpCreatedId) references Cash.dbo.Employee(EmployeeId)

 

I have verified that the relationship is created as it should using the built-in sp_helpconstraint Sybase ASE command. Watching some of the network traffic when ADS is generating this information, this query appears to return some invalid data.

 

Query:

use cash go SELECT su.name as table_schema, object_name(sr.tableid) table_name, sc1.name column_name, object_name(sr.constrid) const_name, 'FK' as ctype, '' key1, '' key2, '' key3, '' key4, '' key5, '' key6, '' key7, '' key8, '' key9, '' key10, '' key11, '' key12, '' key13, '' key14, '' key15, '' key16, '' key17, '' key18, '' key19, '' key20, '' key21, '' key22, '' key23, '' key24, '' key25, '' key26, '' key27, '' key28, '' key29, '' key30, '' key31, '' as checkText, pmrydbname, USER_NAME(ftab.uid), ftab.name, USER_NAME(rtab.uid), rtab.name, col_name(sr.tableid, sr.fokey1), col_name(sr.tableid, sr.fokey2), col_name(sr.tableid, sr.fokey3), col_name(sr.tableid, sr.fokey4), col_name(sr.tableid, sr.fokey5), col_name(sr.tableid, sr.fokey6), col_name(sr.tableid, sr.fokey7), col_name(sr.tableid, sr.fokey8), col_name(sr.tableid, sr.fokey9), col_name(sr.tableid, sr.fokey10), col_name(sr.tableid, sr.fokey11), col_name(sr.tableid, sr.fokey12), col_name(sr.tableid, sr.fokey13), col_name(sr.tableid, sr.fokey14), col_name(sr.tableid, sr.fokey15), col_name(sr.tableid, sr.fokey16), col_name(sr.reftabid, sr.refkey1), col_name(sr.reftabid, sr.refkey2), col_name(sr.reftabid, sr.refkey3), col_name(sr.reftabid, sr.refkey4), col_name(sr.reftabid, sr.refkey5), col_name(sr.reftabid, sr.refkey6), col_name(sr.reftabid, sr.refkey7), col_name(sr.reftabid, sr.refkey8), col_name(sr.reftabid, sr.refkey9), col_name(sr.reftabid, sr.refkey10), col_name(sr.reftabid, sr.refkey11), col_name(sr.reftabid, sr.refkey12), col_name(sr.reftabid, sr.refkey13), col_name(sr.reftabid, sr.refkey14), col_name(sr.reftabid, sr.refkey15), col_name(sr.reftabid, sr.refkey16), sr.status as status, 1 as status2, '' as segname, -1 as maxrowsperpage, 0 as indid, -1 as fill_factor, -1 as res_page_gap, sc1.colid, '' ord1, '' ord2, '' ord3, '' ord4, '' ord5, '' ord6, '' ord7, '' ord8, '' ord9, '' ord10, '' ord11, '' ord12, '' ord13, '' ord14, '' ord15, '' ord16, '' ord17, '' ord18, '' ord19, '' ord20, '' ord21, '' ord22, '' ord23, '' ord24, '........' ord25, '' ord26, '' ord27, '' ord28, '' ord29, '' ord30, '' ord31, null FROM customer..sysreferences sr       , customer..syscolumns sc1       , customer..syscolumns sc2       , customer..syscolumns sc3       , customer..syscolumns sc4       , customer..syscolumns sc5       , customer..syscolumns sc6 , customer..sysobjects so , customer..sysusers su , customer..sysobjects ftab , sysobjects rtab WHERE sr.tableid*=sc1.id AND sr.fokey1*=sc1.colid AND sr.reftabid*=sc2.id AND sr.refkey1*=sc2.colid AND sr.tableid*=sc3.id AND sr.fokey2*=sc3.colid AND sr.reftabid*=sc4.id AND sr.refkey2*=sc4.colid AND sr.reftabid*=sc5.id AND sr.refkey2*=sc5.colid AND sr.reftabid*=sc6.id AND sr.refkey2*=sc6.colid AND sr.tableid=so.id AND so.uid=su.uid AND sr.tableid *= ftab.id and sr.reftabid *= rtab.id AND sr.frgndbname is null AND su.name = 'dbo' AND sr.tableid = object_id('customer.dbo.LumbeeCircuit')

 

Some of the output data

table_schema   table_name       column_name  const_name       ctype     name    pmrydbname    column41            name

dbo        (null)     EmpCreatedId   (null)     FK           LumbeeCircuit   Cash      dbo        Employee

dbo        (null)     CircuitId               (null)     FK           LumbeeCircuit   (null)     dbo        TransactionAccount

 

When using the following features on Sybase ASE:
 
                Scribe Object to (New) Window -> Create (Full)
                Describe Table (Ctrl+D)
 
They both appear to be displaying incorrect information regarding Foreign Key Relationships for Cross Database Constraints. In my specific instance,  a different table and column is displayed for the Foreign Key. For Example:
 
Displayed Text (for a Table in the “Customer” database):
ALTER TABLE dbo.LumbeeCircuit
   ADD CONSTRAINT FK_LumbeeCircuit_EmpCreatedId
   FOREIGN KEY(EmpCreatedId)
   REFERENCES Cash.dbo.TransactionAccount(TransId)
 
Actual Relationship:
ALTER TABLE dbo.LumbeeCircuit
   ADD CONSTRAINT FK_LumbeeCircuit_EmpCreatedId
   FOREIGN KEY(EmpCreatedId)
   REFERENCES Cash.dbo.Employee(EmployeeId)
 
 
Or with the describe command:
CONSTRAINTS:
  FOREIGN KEY: FK_LumbeeCircuit_EmpCreatedId (EmpCreatedId) references TransactionAccount(TransId)
 
But it should say:
CONSTRAINTS:
  FOREIGN KEY: FK_LumbeeCircuit_EmpCreatedId (EmpCreatedId) references Cash.dbo.Employee(EmployeeId)
 
I have verified that the relationship is created as it should using the built-in sp_helpconstraint Sybase ASE command. Watching some of the network traffic when ADS is generating this information, this query appears to return some invalid data.
 
Query:
use cash 
go
SELECT su.name as table_schema, object_name(sr.tableid) table_name, sc1.name column_name, object_name(sr.constrid) const_name, 'FK' as ctype, '' key1, '' key2, '' key3, '' key4, '' key5, '' key6, '' key7, '' key8, '' key9, '' key10, '' key11, '' key12, '' key13, '' key14, '' key15, '' key16, '' key17, '' key18, '' key19, '' key20, '' key21, '' key22, '' key23, '' key24, '' key25, '' key26, '' key27, '' key28, '' key29, '' key30, '' key31, '' as checkText, pmrydbname, USER_NAME(ftab.uid), ftab.name, USER_NAME(rtab.uid), rtab.name, col_name(sr.tableid, sr.fokey1), col_name(sr.tableid, sr.fokey2), col_name(sr.tableid, sr.fokey3), col_name(sr.tableid, sr.fokey4), col_name(sr.tableid, sr.fokey5), col_name(sr.tableid, sr.fokey6), col_name(sr.tableid, sr.fokey7), col_name(sr.tableid, sr.fokey8), col_name(sr.tableid, sr.fokey9), col_name(sr.tableid, sr.fokey10), col_name(sr.tableid, sr.fokey11), col_name(sr.tableid, sr.fokey12), col_name(sr.tableid, sr.fokey13), col_name(sr.tableid, sr.fokey14), col_name(sr.tableid, sr.fokey15), col_name(sr.tableid, sr.fokey16), col_name(sr.reftabid, sr.refkey1), col_name(sr.reftabid, sr.refkey2), col_name(sr.reftabid, sr.refkey3), col_name(sr.reftabid, sr.refkey4), col_name(sr.reftabid, sr.refkey5), col_name(sr.reftabid, sr.refkey6), col_name(sr.reftabid, sr.refkey7), col_name(sr.reftabid, sr.refkey8), col_name(sr.reftabid, sr.refkey9), col_name(sr.reftabid, sr.refkey10), col_name(sr.reftabid, sr.refkey11), col_name(sr.reftabid, sr.refkey12), col_name(sr.reftabid, sr.refkey13), col_name(sr.reftabid, sr.refkey14), col_name(sr.reftabid, sr.refkey15), col_name(sr.reftabid, sr.refkey16), sr.status as status, 1 as status2, '' as segname, -1 as maxrowsperpage, 0 as indid, -1 as fill_factor, -1 as res_page_gap, sc1.colid, '' ord1, '' ord2, '' ord3, '' ord4, '' ord5, '' ord6, '' ord7, '' ord8, '' ord9, '' ord10, '' ord11, '' ord12, '' ord13, '' ord14, '' ord15, '' ord16, '' ord17, '' ord18, '' ord19, '' ord20, '' ord21, '' ord22, '' ord23, '' ord24, '........' ord25, '' ord26, '' ord27, '' ord28, '' ord29, '' ord30, '' ord31, null
 FROM customer..sysreferences sr
      , customer..syscolumns sc1
      , customer..syscolumns sc2
      , customer..syscolumns sc3
      , customer..syscolumns sc4
      , customer..syscolumns sc5
      , customer..syscolumns sc6
, customer..sysobjects so
, customer..sysusers su
, customer..sysobjects ftab
, sysobjects rtab 
WHERE sr.tableid*=sc1.id AND sr.fokey1*=sc1.colid AND sr.reftabid*=sc2.id 
AND sr.refkey1*=sc2.colid AND sr.tableid*=sc3.id AND sr.fokey2*=sc3.colid 
AND sr.reftabid*=sc4.id AND sr.refkey2*=sc4.colid AND sr.reftabid*=sc5.id 
AND sr.refkey2*=sc5.colid AND sr.reftabid*=sc6.id AND sr.refkey2*=sc6.colid 
AND sr.tableid=so.id AND so.uid=su.uid AND sr.tableid *= ftab.id 
and sr.reftabid *= rtab.id AND sr.frgndbname is null 
AND su.name = 'dbo' AND sr.tableid = object_id('customer.dbo.LumbeeCircuit')
 
Some of the output data
table_schema   table_name       column_name  const_name       ctype     name    pmrydbname    column41            name
dbo        (null)     EmpCreatedId   (null)     FK           LumbeeCircuit   Cash      dbo        Employee
dbo        (null)     CircuitId               (null)     FK           LumbeeCircuit   (null)     dbo        TransactionAccount
tomconrad   Aug 25, 2017
Field Old Value New Value
Fixed Build ADS 18.0.18-7 and ADS 19.0.0-beta-40
Resolution Fixed
Resolved Date Aug 25, 2017 4:38 PM
Status New Resolved
JennyNishimura   Aug 25, 2017
Field Old Value New Value
QA Assignee JennyNishimura (Jenny Nishimura) nhilam (Nhi Lam)
tomconrad   Aug 30, 2017
Field Old Value New Value
Status Resolved Verified
nhilam   Sep 26, 2017
Field Old Value New Value
Status Verified Closed

Issue #15450

Closed
Fixed
Resolved Aug 25, 2017
 
 
Completion
No due date
Fixed Build ADS 18.0.18-7 and ADS 19.0.0-beta-40
No time estimate

About AquaClusters Privacy Policy Support Version - 19.0.2-4 AquaFold, Inc Copyright © 2007-2017