Caché应用笔记

1         ODBC

1.1     ODBC ConnectionString

    通过ODBC连接CachéConnectionString是一个麻烦事,下面是一个可用的例子:

Provider=MSDASQL.1;Extended Properties="DRIVER={InterSystems ODBC};SERVER=127.0.0.1;PORT=1972;DATABASE=HMSDICT;UID=_SYSTEM;PWD=SYS"

1.2     TroubleShooting

平时遇到的一些问题和解决办法

错误编号

描述

解决方法

1

使用ADO来连接, 最简单的方式来修改一个值然后Post,就报错:: 无法定位更新行,***已被改变

更新其中一个为空的字符串字段为’ ’

or

修改其长度10240->1024

2

Native Code 461

数据库不能连接, 检查其连接

3

Native Code 469

修改ODBC的连接字符串,不要使用Delphi自己产生的字符串,而是使用本章1中的ODBC ConnectionString

2         分发/部署(Deployment)

2.1     分发时删除源码

l         $system.OBJ.MakeClassDeployed

    classmethod MakeClassDeployed(classname As %String = "", flags As %String = "") returns %Status

Make a class in deployed mode. This will delete all the source code of the class from the disk. Once a class is in deployed mode, it can not be edited nor exported. It also can not be compiled, and non of it's sub-classes can be compiled either.

 

例如:

W $SYSTEM.OBJ.MakeClassDeployed("Sample.Film")

l        %ROMF
%ROMF and then load it into a clean database using %RIMF for distribution. This is similar to shipping only an executable in other languages.

l         直接从Explore中删除 Routines

3         数据库移植(5.x->4.x

l         导出CDL

    w $SYSTEM.OBJ.ExportCDLPackage("Division","Divistion.cdl",4)

 

    *注意事项

        %ID -> ID

        while 条件不能加括号

        TS TC TRO 后面不能有空格(紧接其后回车可解决)

    不能使用Continue(使用goto代替)

    不能使用isObject

    不能使用 >=

    不能使用 %XML

    不能使用 %System.SYS

 

*导出CDL的格式要求

5.04.0Global的格式有差别。 5 GlobalListNode的第一项 "value (1) = %%CLASSNAME",而4中则不含此项。因此,会导致在4中,OpenId出错:class not exist

无法打开对象。

 

解决方法: %%CLASSNAME替换成其他字符串,但不要和属性名重复。(在HMS中,使用TaoReserved替换)

 

2 ROWSPEC 中的 ID 不用加属性描述

 ID:%String:Dcit.EMedicalRecords.ICD10 -> ID:%String

 

1.         Stream

s b=##Class(%Dictionary.ClassDefinition).%OpenId("Dict.Report.ReportItems")

w b.Storages.GetAt(1).StreamLocation

4         对象操作

4.1     对象引用的快速赋值

对象引用时使用对象方法实现为:

  S obja=##Class(ClassA).$OpenId(“1”)

  S objb=##Class(ClassB).$OpenId(“1”)

  S obja.propertyB=objb

  D obja.%Save()

Global操作:

  假设 propertyB Globa  ^ClassAD中位置在第三位,则

  $LIST(^ClassAD(“1”,3))=”1”

 

5         索引(Index)

ü         不要使用唯一Bitmap索引(Do not make unique indexes bit map

ü         保持Index Collation(索引排序)和Property Collation属性排序相同

如果要更改Collation,就修改属性的Collation,而不要更改索引Collation

ü         确保为所有的外键(对象引用、关联等)都建立索引

ü         所有可能会用来比较(=,>,<,LIKE,BETWEEN )等操作的属性都可以考虑建立索引。如果可能出现的值在10,000个以上,使用一般的索引,否则可以考虑使用Bitmap。各个属性单独建立索引。

ü         %BuildIndices for Bitmap: 如果索引已经记录了索引值,那在调用%BuildIndices之前最好先调用%PurgeIndices 以去掉旧的索引值

posted @ 2005-04-07 18:07  观无明  阅读(1877)  评论(9)    收藏  举报