source: WorldVistAEHR/trunk/r/VA_FILEMAN-ARJT-DI-DD-DM-DT-%DT-%RCR/DMSQS.m@ 862

Last change on this file since 862 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 2.6 KB
RevLine 
[613]1DMSQS ;SFISC/JHM-BUILD STANDARD SCHEMA ;7/31/97 13:55
2 ;;22.0;VA FileMan;;Mar 30, 1999
3 ;Per VHA Directive 10-93-142, this routine should not be modified.
4 Q
5SCHEMA ;BUILD OR REPLACE SQLI SCHEMA
6 N SI,TT,IEN,FDA
7 S SI=$O(^DMSQ("S","B","SQLI",""))
8 S TT=1.521,IEN=$S(SI:SI,1:"+1")_","
9 S FDA(TT,IEN,.01)="SQLI" ; SCHEMA NAME
10 S FDA(TT,IEN,2)="FileMan SQL/ODBC interface tables" ; COMMENT
11 S SI=$$PUT^DMSQU(IEN,"FDA","ERR")
12 I $D(ERR)!'SI D ERR^DMSQU(1.521,"","SCHEMA: RECORD INSERT FAILED")
13 Q
14ALLS Q:$G(DUZ(0))'["@" N TI,@$$NEW^DMSQU D ENV^DMSQU S TI=0
15 F S TI=$O(^DMSQ("T",TI)) Q:'TI D STEXE
16 Q
17STATS(TI) ;DO NODE STATISTICS FOR TABLE TI
18 Q:$G(DUZ(0))'["@" ;NOT FOR NON-PROGRAMMERS
19 Q:'$D(^DMSQ("T",TI,0)) ;NO GLOBAL STRUCTURE ON FILE
20 N @$$NEW^DMSQU D ENV^DMSQU
21STEXE N T,MT,G,G0,CND,K,O,INI,C,MC,I,CT,TT,IEN,FDA,ERR,PI,PEI,F
22 S T=^DMSQ("T",TI,0),MT=$P(T,U,4),(G0,G)=$G(^(1)) Q:G=""
23 S CND=$S(MT:"K(OI)]""""",1:"K(OI)"),INI=$S(MT:"",1:0),MC=5000
24 S (CT,O)=0,F="{K}" F Q:G'[F D
25 . S O=O+1,K="K("_O_")"
26 . S G(O)=$P(G,F)_K_")",C(O)=0,G=$P(G,F)_K_$P(G,F,2,9)
27 S K(1)=INI D CNT(1)
28 I CT=MC S OI=1 D
29 . F I=2:1:O S C(I)=C(I)/C(1)
30 . F S K(1)=$O(@G(1)),@("K="_CND) Q:'K S C(1)=C(1)+1
31 . F I=2:1:O S C(I)=C(I)*C(1) I C(I)["." D
32 . . S C(I)=$S(C(I)<10:+$J(C(I),"",2),C(I)<100:+$J(C(I),"",1),1:C(I)\1)
33 K ^STATS(TI) M ^STATS(TI)=C ;REMOVE AFTER DEBUG
34 ;STORE T_ROW_COUNT IN SQLI_TABLE
35 S TT=1.5215,IEN=TI_"," K FDA
36 S FDA(TT,IEN,5)=C(O) ;NUMBER OF ROWS IN TABLE
37 S C=$$PUT^DMSQU(IEN,"FDA","ERR")
38 I $D(ERR)!'C D ERR^DMSQU(TT,"","STATS: RECORD INSERT FAILED")
39 ;STORE P_ROW_COUNT IN SQLI_PRIMARY_KEY
40 S TT=1.5218,PEI=$O(^DMSQ("E","D",TI,"")),PI=0
41 F I=1:1 S PI=$O(^DMSQ("P","B",PEI,PI)) Q:'PI D
42 . S IEN=PI_"," K FDA
43 . S FDA(TT,IEN,5)=C(I) ;ESTIMATED ROW COUNT FOR THIS LEVEL
44 . S C=$$PUT^DMSQU(IEN,"FDA","ERR")
45 . I $D(ERR)!'C D ERR^DMSQU(TT,5,"STATS: KEY COUNT INSERT FAILED")
46 Q
47CNT(OI) ;ACCUMULATE NODE COUNT
48 F S K(OI)=$O(@G(OI)) D Q:'OI
49 . I @CND D
50 . . S CT=CT+1,C(OI)=C(OI)+1 I CT=MC S OI=0
51 . . E I OI<O S OI=OI+1,K(OI)=INI
52 . E S OI=OI-1
53 Q
54EP ;EDIT PROTECT ALL SQLI FILES
55 Q:$G(DUZ(0))'="@" N DMF,DMFI W !,"EDIT-PROTECTING SQLI FILES..."
56 S DMF=1.520
57 F S DMF=$O(^DD(DMF)) Q:DMF>1.52192 S DMFI=0 W DMF D
58 . F S DMFI=$O(^DD(DMF,DMFI)) Q:'DMFI D
59 . . W ?10,DMFI,?20,$G(^DD(DMF,DMFI,9))
60 . . S ^(9)="^" W "->^",!
61 W "Done" Q
62EU ;EDIT UNPPROTECT ALL SQLI FILES
63 Q:$G(DUZ(0))'="@" N DMF,DMFI W !,"EDIT-UNPROTECTING SQLI FILES..."
64 S DMF=1.520
65 F S DMF=$O(^DD(DMF)) Q:DMF>1.52192 S DMFI=0 W DMF D
66 . F S DMFI=$O(^DD(DMF,DMFI)) Q:'DMFI D
67 . . W ?10,DMFI,?20,$G(^DD(DMF,DMFI,9))
68 . . S ^(9)="@" W "->@",!
69 W "Done" Q
Note: See TracBrowser for help on using the repository browser.