转贴 borland eco delphi ocl 查询
2007-09-12 14:18
573 查看
我们假定有两个类,其中一个是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 person
person.allinstances->select(name='张三') 相当于select * from person where name='张三'
person.allinstances.birthday 相当于select birthday from person
person.allinstances->select(birthday>=#1997-01-01) 相当于select * from person where birthday>=#1997-01-01
person.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 person
person.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('%张%'))姓名中含姓张的所有人%为通配符
我们试着来做一些查询:
person(类中的所有成员) 因为eco 中person类事实上是映射到person 数据表的,ocl语句中person是指的类,select 语句中person指的是表。
person.allinstances 相当于select * from person
person.allinstances->size 相当于select count(*) from person
person.allinstances->select(name='张三') 相当于select * from person where name='张三'
person.allinstances.birthday 相当于select birthday from person
person.allinstances->select(birthday>=#1997-01-01) 相当于select * from person where birthday>=#1997-01-01
person.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 person
person.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('%张%'))姓名中含姓张的所有人%为通配符
相关文章推荐
- Borland企业核心对象“ECO”技术加快软件快速开发的进程(转贴一篇老文章)
- 希望我不要下定决心放弃borland与delphi
- Delphi Adoquery 多次查询
- 常用的系统状态查询命令 (转贴)
- Borland Delphi一句话帮助
- transact---sql高级查询 (转贴)
- Delphi中实现多线程同步查询
- Delphi模糊查询[ POS函数和Like SQL语句 ]使用方法
- 查询图元 Delphi6+mapx4.5+win2000
- delphi+access 执行时间段查询时,直接写SQL和使用filter的不同
- Borland Delphi/C++Builder ToolsAPI
- (转贴)用DELPHI的RTTI实现对象的XML持久化
- Viusal C++, Borland Delphi程序的分析
- [转贴]实现类似于baidu的那种用空格键的分词查询
- (转)用Delphi中的TADOQuery查询Oracle10G中的数据表时,Open时提示"数据类型不被支持"的处理方法
- MySQL字符集中文乱码终极解决方案和mysql查询中文问题解决方法[转贴]
- Borland决定出售Delphi、JBuilder、C++Builder等IDE产品
- 动态语言崛起 Delphi For PHP能否挽救Borland?
- Delphi与SQL模糊查询(转载)
- 第一本ECO的技术专著可以下载了!(delphi2006)