Using SQLExec and Record Objects

使用SQLExec填充记录对象
本文介绍了一种使用SQLExec来填充记录对象的方法,这种方法不依赖于记录的关键字段。通过示例展示了如何为特定员工ID查找PSOPRDEFN记录,并自动加载所有字段,即使表结构发生变化也不影响代码的适用性。

Using SQLExec and Record Objects

Here is a quick code snippet to show how to use SQLExec to pull data into a record object not using the key fields of the record. It is not clear in PeopleBooks how to use Record objects with SQLExec. I use record objects all over the place in my peoplecode. Here is a quick way to do a select to populate a record object NOT using key fields.

In this example we will populate a record object for PSOPRDEFN for the user profile that has the employee id of “EE2343.” The only key field on PSORPDEFN is OPRID which we are trying to find.

Local Record &recO;
&recO = CreateRecord(Record.PSOPRDEFN);
SQLExec("%selectall(:1) WHERE PSOPRDEFN.EMPLID = :2", &recO, "EE2343", &recO);

The great thing about this is that it automatically pulls all the fields. If you later add or remove fields from the record you are selecting from you do not have to touch this code because “%selectall” will dynamically figure out the fields based on the record definition.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值