Using SQLExec and Record Objects

By Chris Malek | Mon, Jul 11, 2011

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 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.

Article Categories
Author Info
Chris Malek

Chris Malek is a PeopleTools® Technical Consultant with two decades of experience working on PeopleSoft enterprise software projects. He is available for consulting engagements.

About Chris Work with Chris
Looking for pain-free PeopleSoft web services? 😀
PeopleSoft Simple Web Services (SWS)

Introducing a small but powerful PeopleSoft bolt-on that makes web services very easy. If you have a SQL statement, you can turn that into a web service in PeopleSoft in a few minutes.

Integration Broker - The Missing Manual

I am in the process of writing a book called "Integration Broker - The Missing Manual" that you can read online.