-------------------------------------------------
-- To delete a row from a table is difficult,  --
-- because sometimes names (primary key column --
-- and foreign key column) are different.      --
-- To find out which tables are dependable     --
-- of the first one, execute this code.        --
-- YOU MUST BE OWNER!                          --
-- by KNG                                      --
-------------------------------------------------
SET VAR vTabName TEXT
CHOOSE vTabName FROM #TABLES +
  AT CENTER CENTER +
  CHKBOX +
  TITLE 'Returns a list of tables using chosen one' +
  CAPTION 'Table Info' +
  LINES 10
IF vTabName IS NULL OR vTabName = '[Esc]' THEN
  CLEAR VAR vTabName
  RETURN
ENDIF
SELECT SYS_TABLE_ID INTO vTable_ID FROM SYS_TABLES +
  WHERE SYS_TABLE_NAME = .vTabName
SET ERROR MESSAGES OFF
SET MESSAGES OFF
SELECT DISTINCT SYS_TABLE_NAME FROM SYS_TABLES +
  WHERE SYS_TABLE_ID IN +
   (SELECT SYS_TABLE_ID FROM SYS_INDEXES +
      WHERE ('#'+(ctxt(SYS_FOREIGN_KEY))) IN +
       (SELECT SYS_INDEX_NAME FROM SYS_INDEXES +
          WHERE SYS_TABLE_ID = .vTable_ID))
-- If there are no dependable tables,
-- returns the chosen one.
IF SQLCODE = 100 THEN
  SELECT DISTINCT SYS_TABLE_NAME FROM SYS_TABLES +
    WHERE SYS_TABLE_ID = .vTable_ID
ELSE
  SET ERROR MESSAGES ON
  SET MESSAGES ON
  CLEAR VAR vTabName,vTable_ID
  RETURN
ENDIF
--
CLEAR VAR vTabName,vTable_ID
SET ERROR MESSAGES ON
SET MESSAGES ON
--
RETURN


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx

================================================
TO SEE MESSAGE POSTING GUIDELINES:
Send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: INTRO rbase-l
================================================
TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED]
In the message body, put just two words: UNSUBSCRIBE rbase-l

Reply via email to