2.保存到dthealth/web/csp下
上一篇 IIS配置问题
1..MAC文件是m语言,下面是test111.MAC
test111aa()w "abc"q 0
- 最上面的名字和文件名一致
- 然后是方法名
- 文件名和方法名要顶头写,不能有空格
调用方式:DHC-APP>d aa^test111(),方法名有括号就带括号
2..cls是类文件,方法的写法与上面不一样
ClassMethod aa(){
w "abc"q 0}
- 调用方式:DHC-APP>d class(web.test111).aa()
3.建立临时Global
DHC-APP>set ^TEMP=3//Global物理存储到数据库,terminal关了的话还会有,其他变量会消失DHC-APP>S ^TEMP("A")=1//设置节点DHC-APP>s ^TEMP("B")=2
DHC-APP>w $h63802,58589DHC-APP>w $zd(63802)09/07/2015DHC-APP>w $zd(63802,3)2015-09-07DHC-APP>w +$h63802DHC-APP>w $zd(+$h,3)2015-09-07DHC-APP>w $zdh("2015-9-7",3)63802DHC-APP>w $zdh("2024-9-7",3)-$zdh("2015-9-7",3)3288DHC-APP>w $zt(58543)16:15:43DHC-APP>w $zt(58543,2)16:15DHC-APP>w $zt(58543,3)04:15:43PMDHC-APP>w $zt($p($h,",",2))17:07:50
5.$i
对每次运行的global产生唯一一个值
DHC-APP>w $i(^TEMP)4DHC-APP>w $i(^TEMP)5DHC-APP>w $i(^TEMP)6
6.$e截取字符串
DHC-APP>s a="abcdef"DHC-APP>w $e(a,2)bDHC-APP>w $e(a,2,4)bcd
7.for循环1加到100
ClassMethod testfor(){
s m=0f i=1:1:100 d.s m=m+is sum=mq sum}DHC-APP>w class(web.test111).testfor()5050
- 计算有多少个科室
ClassMethod testfor(){
s m=0s ctlocrowid=""//q和d,f和s空两个空格f s ctlocrowid=$o(^CTLOC(ctlocrowid)) q:ctlocrowid="" d.s m=m+1s sum=mq sum}
- 8.Terminal查看Global
zw ^STUDENT
9.buildIndices()重建索引指定的类
上一篇 IIS配置问题
Class User.Student Extends %Persistent [ SqlRowIdName = St_RowID, SqlTableName = t_Student, StorageStrategy = StudentStorage ]{
Property StCode As %String [ Required, SqlColumnNumber = 2, SqlFieldName = st_code ];Property StName As %String [ SqlColumnNumber = 3, SqlFieldName = st_name ];Property StSexDR As CTSex [ SqlColumnNumber = 4, SqlFieldName = st_sex_dr ];Property StDob As %Date [ SqlColumnNumber = 5, SqlFieldName = st_dob ];Relationship ChildCourse As User.StuCourse [ Cardinality = children, Inverse = StudParRef ];Index indexcode On StCode;}
- 2.建立Course表
Class User.Course Extends %Persistent [ SqlRowIdName = C_RowID, SqlTableName = t_Course, StorageStrategy = CourseStorage ]{
Property Code As %String [ SqlColumnNumber = 2, SqlFieldName = C_Code ];/// 课程描述Property Desc As %String [ SqlColumnNumber = 3, SqlFieldName = C_Desc ];Property DateFrom As %Date [ SqlColumnNumber = 4, SqlFieldName = C_DateFrom ];Property Active As %String(DISPLAYLIST = ",Yes,No", MAXLEN = 3, TRUNCATE = 1, VALUELIST = ",Y,N") [ SqlColumnNumber = 5, SqlFieldName = C_Active ];Property UserDr As User.SSUser [ SqlColumnNumber = 6, SqlFieldName = C_User_Dr ];}
3.学生选课表
Class User.StuCourse Extends %Persistent [ SqlRowIdName = SC_RowID, SqlTableName = t_StuCourse, StorageStrategy = stucourse ]{
Index RowIDBasedIDKeyIndex On SCChildSub [ IdKey, PrimaryKey, Unique ];Relationship StudParRef As User.Student [ Cardinality = parent, Inverse = ChildCourse, Required, SqlFieldName = SC_S_ParRef ];Property SCChildSub As %Library.Numeric(SCALE = 0) [ InitialExpression = {$i(^STUDENT($p($s($d(initvalue):initvalue,1:%d(0)),$c(1)),"C",0))}, Required, SqlColumnNumber = 2, SqlFieldName = SC_ChildSub ];Property SCCourseDr As User.Course [ SqlColumnNumber = 3, SqlFieldName = SC_Course_Dr ];Property SCScore As %Float [ SqlColumnNumber = 4, SqlFieldName = SC_Score ];}
注意:Rowid用表名.Rowid
4.查询某个学生的选课情况
Class web.StuCourse Extends %Persistent{
ClassMethod FindCourseByStud(stuno){
Quit:stuno="" "";第二个空是返回值set stuId=$o(^STUDENTi(0,"No",stuno,""))set sub=0For set sub=$o(^STUDENT(stuId,"C",sub)) quit:sub="" d.set g=^STUDENT(stuId,"C",sub).set CourseId=$p(g,"^",1).set CourseDesc=$p(^COURSE(CourseId),"^",2).set Score=$p(g,"^",2).Write CourseDesc_" "_Score}}
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/202042.html原文链接:https://javaforall.net
