| Blog信息 |
|
blog名称:注册会计师(注会)练习软件 日志总数:398 评论数量:116 留言数量:27 访问次数:3282842 建立时间:2005年6月6日 |

| |
|
[borland eco 技术]eco中的ocl查询语句 软件技术
吕向阳 发表于 2006/4/22 21:29:45 |
|
[borland eco delphi ocl 查询]因为内容较多,较细,分一些日子陆续贴出来
我们假定有两个类,其中一个是person,另一个是每个人工作的部门类department,两者之间的关系是person 0..* ------department 0..1,person类中有name:string,telephone:string,birthday:datetime;department类有name:string我们试着来做一些查询:
person(类中的所有成员) 因为eco 中person类事实上是映射到person 数据表的,ocl语句中person是指的类,select 语句中person指的是表。person.allinstances 相当于select * from person person.allinstances->size 相当于select count(*) from personperson.allinstances->select(name='张三') 相当于select * from person where name='张三'person.allinstances.birthday 相当于select birthday from personperson.allinstances->select(birthday>=#1997-01-01) 相当于select * from person where birthday>=#1997-01-01person.allinstances->select(birthday.indaterange(#1975-01-01,#1995-01-01))下面我就不作比方了indaterange相当于between;person.allinstances.formatdatetime('d mmmm yyyy')显示特定的日期格示如 9 december 1995是上面的一种对应显示person.allinstances.name.concat( ' some text')与person.allinstances.name+'some text'是一致的,相当于select name+'some text ' from personperson.allinstances.department 返回的是一个对象,指的是它对应的部门是哪一个,在sql语句中应无对应功能。department.allinstances.person.birthday 是指所有部门中的所有人员的生日department.allinstances->collect(person) 所有部门的所有成员,不重复的。department.allinstances->collect(person)->collect(birthday)所有部门所有成员的生日集合。department.allinstances->collect(person->size)每一个部门中人员总数集合,有点类似于select语句中的group by 的味道person.allinstances->orderby(birthday)不用说,是排序的结果person.allinstances->orderdescending(birthday)倒序person.allinstances->first返回第一条person.allinstances->orderby(name)->last 姓名排序后的最后一条person.allinstances->at(2)第二条记录person.allinstances->subsequence(2,6)第二条到第六条person.allinstances->select(name.sqllike('%张%'))姓名中含姓张的所有人%为通配符相信这些对eco学习的人来说很有用,因为我最初为找到这些资料大费周章。后续的细节我会陆续补上。
|
|
|
回复:eco中的ocl查询语句 软件技术
沧海一声笑(游客)发表评论于2006/6/28 14:13:07 |
|
» 1 »
|