Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DMSQT

DMSQT.m

Go to the documentation of this file.
  1. DMSQT ;SFISC/EZ-TROUBLE SHOOTING ;11/13/97 12:25
  1. ;;22.0;VA FileMan;;Mar 30, 1999
  1. ;Per VHA Directive 10-93-142, this routine should not be modified.
  1. Q
  1. ; DMQ - status flag for flow of control
  1. ; DMTDATE, DMEDATE - dates when Tables and Errors last updates
  1. ; DMLTBL - last table
  1. ; DMLFILE, DMNFILE - last file being processed, next one to be done
  1. ; DMLCOL, DMCNODE - last column processed, that column's node
  1. ; DMLCTE, DMLCTBL - last column's table element and table
  1. ; DMLCFILE, DMLCFLD - the last column's file and field reference
  1. ; DMNCFLD - what would be the next column's field reference
  1. ; (using ^DD to see what field is coming up next for processing)
  1. ; DMNCFILE - what would be the next column's file reference
  1. ; DMPARENT - parent to a subfile, may itself be a subfile
  1. ; DMTOPFLD - the top (upper) level field number for a subfile
  1. ; DMNXTFLD - the next field in the upper file to be processed
  1. ; DMNEXTF - the next file to be processed, coming up a subfile path
  1. ; DMNEXTSF - the next subfile to be processed, up from a subfile path
  1. ; DMNAME - the name of a file or subfile
  1. ; DMLFK, DMLFKTE - last foreign key, and it's last table element
  1. ; DMFKTBL - foreign key table, pointer from table element record
  1. ; DMPKTE - primary key table element record
  1. ; DMKEYS, DMC - keys (primary keys), and a counter
  1. ; DMFKFILE - foreign key file, the table element pointer
  1. ; DMASTER - the master table for this index table
  1. ; DMLO, DMLOF - where SQLI left off when building index tables
  1. ; So DMLO would be the last regular table where SQLI left off
  1. ; and DMLOF would be that table's file number.
  1. EN ; main driver logic
  1. ; follows flow of ALLF^DMSQF, checking that each step completed
  1. I $$WAIT^DMSQT1 D Q
  1. . W !?5,"Try again later. An SQLI projection is running right"
  1. . W !?5,"now. It might take a few hours to finish, but then you"
  1. . W !?5,"can try again and get a final status report."
  1. S %ZIS="QM" D ^%ZIS Q:POP
  1. I $D(IO("Q")) D Q
  1. . S ZTRTN="DQ^DMSQT",ZTDESC="SQLI DIAGNOSTICS REPORT"
  1. . D ^%ZTLOAD D HOME^%ZIS K IO("Q")
  1. DQ U IO D INIT D
  1. . D DATE
  1. . D SCHEMA D PAGE Q:$D(DIRUT)
  1. . D A D PAGE Q:$D(DIRUT)
  1. . D B D PAGE Q:$D(DIRUT)
  1. . D C D PAGE Q:$D(DIRUT)
  1. . D D D PAGE Q:$D(DIRUT)
  1. D @$S($D(DIRUT):"EXIT",DMQ=1:"DONE",DMQ=2:"ERROR",1:"EXIT")
  1. D ^%ZISC S:$D(ZTQUEUED) ZTREQ="@"
  1. Q
  1. INIT ; initialize variables
  1. S DMQ="" D DT^DICRW
  1. S DMTDATE=$P($G(^DMSQ("T",1,0)),U,8)
  1. S DMEDATE=$O(^DMSQ("EX","D",0))
  1. S DMLTBL=$O(^DMSQ("T",999999999999999999999999),-1)
  1. S DMLCOL=$O(^DMSQ("C",999999999999999999999999),-1)
  1. S DMLFK=$O(^DMSQ("F",999999999999999999999999),-1)
  1. Q
  1. PAGE K DIRUT I $Y+4>IOSL S DIR(0)="E" D:IOST["C-" ^DIR W @IOF
  1. Q
  1. DATE ; check when projection run, compare with today
  1. S Y=DT D DD^%DT W !?10," TODAY'S DATE: ",Y,!
  1. I 'DMTDATE D
  1. . W !?5,"No date associated with first SQLI Table record."
  1. I 'DMEDATE D
  1. . W !?5,"No dates found in the SQLI Error Log."
  1. I DMTDATE'=DMEDATE D
  1. . W !?5,"Different dates on Table and Error Log files."
  1. S Y=DMTDATE D DD^%DT W !?10,"LAST SQLI TABLE UPDATE: ",Y
  1. S Y=DMEDATE D DD^%DT W !?10,"LAST SQLI ERROR UPDATE: ",Y,!
  1. ;I DMTDATE,DMEDATE,DT'=DMTDATE,DT'=DMEDATE D
  1. I (DMTDATE!DMEDATE)&(DT'=DMTDATE!(DT'=DMEDATE)) D
  1. . W !?5,"SQLI was run in the past. DDs may have changed since then.",!
  1. Q
  1. SCHEMA ; check if schema node set
  1. I '$O(^DMSQ("S",0)) S DMQ=2 D Q
  1. . W !?5,"No SQLI Schema records. Has the SQLI projection been run?"
  1. Q
  1. A ; were all regular tables built?
  1. I 'DMLTBL S DMQ=2 D Q
  1. . W !!?5,"No records in the SQLI Table file."
  1. I $P(^DMSQ("T",DMLTBL,0),U,4) D Q
  1. . W !?5,"All regular tables appear to have been built."
  1. S DMLFILE=$P(^DMSQ("T",DMLTBL,0),U,7) I 'DMLFILE S DMQ=2 Q
  1. ;. W !!?5,"Not all files appear to have been built as tables."
  1. W !?5,"The last regular file to be processed was ",DMLFILE,"."
  1. S DMNFILE=+$O(^DIC(DMLFILE)) I DMNFILE S DMQ=2 D Q
  1. . W !?5,"The next one, file ",DMNFILE," may be the problem."
  1. . D BADFILE(DMNFILE)
  1. S DMNFILE=+$O(^DD(DMLFILE)) I DMNFILE S DMQ=2 D Q
  1. . I $D(^DD(DMNFILE,0,"UP")) D
  1. .. W !?5,"The next one, subfile ",DMNFILE," may be the problem."
  1. .. D BADFILE(DMNFILE)
  1. Q
  1. B ; were all columns built?
  1. I 'DMLCOL S DMQ=2 D Q
  1. . W !!?5,"No records in the SQLI Column file."
  1. S DMLCTE=$P(^DMSQ("C",DMLCOL,0),U,1)
  1. S DMLCTBL=$P($G(^DMSQ("E",DMLCTE,0)),U,3)
  1. I DMLCTBL=DMLTBL D Q
  1. . W !!?5,"Columns have been built for the last table processed."
  1. S DMQ=2 D
  1. . W !!?5,"It looks like not all columns were processed."
  1. S DMCNODE=^DMSQ("C",DMLCOL,0)
  1. S DMLCFILE=$P(DMCNODE,U,5),DMLCFLD=$P(DMCNODE,U,6)
  1. I DMLCFILE,DMLCFLD D
  1. . W !?5,"The last file processed was ",DMLCFILE,"."
  1. . W !?5,"The last field processed was ",DMLCFLD,"."
  1. . S DMNCFLD=$O(^DD(DMLCFILE,DMLCFLD)) I +DMNCFLD D Q
  1. .. W !!?5,"The next field to be processed looks like ",DMNCFLD,"."
  1. .. D BADFILE(DMLCFILE)
  1. . I $D(^DIC(DMLCFILE)) S DMNCFILE=$O(^DIC(DMLCFILE)) I +DMNCFILE D Q
  1. .. W !?5,"Having finished with all fields of ",DMLCFILE,", SQLI was probably"
  1. .. W !?5,"trying to process ",DMNCFILE,", the next file."
  1. .. D BADFILE(DMNCFILE)
  1. . S DMPARENT=$G(^DD(DMLCFILE,0,"UP")) I DMPARENT D
  1. .. W !?5,"The last one (",DMLCFILE,") is a subfile of ",DMPARENT,"."
  1. .. S DMTOPFLD=$O(^DD(DMPARENT,"SB",DMLCFILE,0))
  1. .. W !?5,"It is field ",DMTOPFLD," of file ",DMPARENT,"."
  1. .. S DMNXTFLD=$O(^DD(DMPARENT,DMTOPFLD)) I +DMNXTFLD D
  1. ... W !?5,"The next field to be processed looks like ",DMNXTFLD,"."
  1. ... D BADFILE(DMPARENT)
  1. .. I '+DMNXTFLD D
  1. ... W !?5,"That looks like the last field in ",DMPARENT,"."
  1. ... I $D(^DIC(DMPARENT)) D Q
  1. .... S DMNEXTF=$O(^DIC(DMPARENT)) I +DMNEXTF D
  1. ..... W !?5,"The next file to be processed looks like ",DMNEXTF,"."
  1. ..... D BADFILE(DMNEXTF)
  1. ... S DMNEXTSF=$G(^DD(DMPARENT,0,"UP")) I DMNEXTSF D Q
  1. .... W !?5,"The next subfile to be processed looks like ",DMNEXTSF,"."
  1. .... D BADFILE(DMNEXTSF)
  1. Q
  1. BADFILE(NUM) ;
  1. S DMNAME=$P($G(^DIC(NUM,0)),U,1)
  1. I 'DMNAME S DMNAME=$O(^DD(NUM,0,"NM",0))
  1. D PAGE Q:$D(DIRUT)
  1. W !!?5,"SUGGESTION: Investigate this file/subfile as the potential"
  1. W !?5,"source of the problem. That's: ",NUM," ",DMNAME,!
  1. Q
  1. C ; were all foreign keys built?
  1. I 'DMLFK S DMQ=2 D Q
  1. . W !!?5,"No foreign key records have been built."
  1. S DMLFKTE=$O(^DMSQ("E","E","F",999999999999),-1)
  1. I 'DMLFKTE S DMQ=2 D Q
  1. . W !?5,"No table elements have been built for foreign keys."
  1. S DMFKTBL=$P(^DMSQ("E",DMLFKTE,0),U,3)
  1. S DMPKTE=$O(^DMSQ("E","F",DMFKTBL,"P",0))
  1. S (DMKEYS,DMC)=0
  1. F S DMKEYS=$O(^DMSQ("P","B",DMPKTE,DMKEYS)) Q:DMKEYS="" S DMC=DMC+1
  1. S DMFKFILE=$P(^DMSQ("T",DMFKTBL,0),U,7)
  1. I DMC>1 D Q
  1. . W !!?5,"All regular foreign keys have been built (FKs)."
  1. . W !?5,"Parent foreign keys (PFKs) have also been built, the"
  1. . W !?5,"last one being for file/subfile ",DMFKFILE,"."
  1. I DMC'>1 S DMQ=2 D Q
  1. . W !!?5,"Only regular foreign keys (FKs) have been processed."
  1. . W !?5,"The last was for file/subfile ",DMFKFILE,"."
  1. Q
  1. D ; were all index tables built?
  1. I 'DMLTBL S DMQ=2 D Q
  1. . W !!?5,"No records for SQLI index tables."
  1. S DMASTER=$P(^DMSQ("T",DMLTBL,0),U,4) I 'DMASTER S DMQ=2 D Q
  1. . W !!?5,"Index tables don't appear to have been built."
  1. S DMLO=$O(^DMSQ("T",DMASTER)) I 'DMLO S DMQ=2 Q
  1. S DMLOF=$P(^DMSQ("T",DMLO,0),U,7) I DMLOF D
  1. . ; find out if any indexes remain to be processed
  1. . S DMLOOP=DMASTER F S DMLOOP=$O(^DMSQ("T",DMLOOP)) Q:DMLOOP'>0 D
  1. .. Q:$P(^DMSQ("T",DMLOOP,0),U,4)
  1. .. S:$$IDX^DMSQT1(DMLOOP) DMQ=2
  1. I DMQ=2 W !!?5,"Index processing stopped at file ",DMLOF,"." Q
  1. S DMQ=1
  1. W !!?5,"All index tables appear to have been built. The last was for"
  1. W !?5,"file/subfile ",$P(^DMSQ("T",DMASTER,0),U,7),"."
  1. Q
  1. DONE ; come here if all checks succeed
  1. W !!?5,"No problems detected in SQLI data structures themselves.",!
  1. Q
  1. ERROR ; come here on error
  1. W !!?5,"Problems found in SQLI data structures."
  1. W !?5,"---------------------------------------"
  1. W !?5,"See SQLI Site Manual, trouble-shooting section, for ideas about"
  1. W !?5,"how to investigate the problem. For example, RUNONE^DMSQ may be"
  1. W !?5,"used to explore a potential problem file."
  1. Q
  1. EXIT K DMQ,DMTDATE,DMEDATE,DMLTBL,DMLFILE,DMNFILE
  1. K DMLCOL,DMLCTE,DMLCTBL,DMCNODE,DMLCFILE,DMLCFLD,DMNCFLD
  1. K DMNCFILE,DMPARENT
  1. K DMTOPFLD,DMNXTFLD,DMNEXTF,DMNEXTSF,DMNAME,DMLFK,DMLFKTE,DMFKTBL
  1. K DMPKTE,DMKEYS,DMC,DMFKFILE,DMASTER,DMLO,DMLOF,DMLOOP
  1. Q