Вы находитесь на странице: 1из 79

PeopleCode

PeopleCode Introduction

<Insert Picture Here>

What is PeopleCode?
PeopleCode is PeopleSofts own proprietary language.
It is used to incorporate sophisticated business rules into PeopleSoft
applications.
The language is designed specifically to interact with the application processor
,giving the capability to enhance the applications beyond the capability of
PeopleTools.

Purpose/uses

Accessing
PeopleCode

Every PeopleCode program is associated with an object and with an event.


When an event fires on an object, it triggers any PeopleCode program
associated with that object and that event.

PeopleCode Programs

In Application Designer

Record Field

Record Definitions

Page

Page Definitions

Component ,Component Record


,Component Record Field

Component Definitions

Menu

Menu Definitions

Application Engine

Application Engine Program Definitions

Component Interface

Component Interface Definitions

Service Operation

Application package-Application method

Editing PeopleCode

You can edit your PeopleCode using the PeopleCode Editor.


When you save or validate PeopleCode ,the system automatically
formats the code for you.
PeopleCode is case-insensitive , except for the quoted literals.
PeopleCode is non-modal.
It supports standard windows drag-and-drop editing.

PeopleCode Editor
PeopleCode Editor has two Drop Down lists.
1. Object List
2. Event Type
The editor is directly tied with PeopleSoft Object

Record Field

Component
Record Field

Component
Record

Component

FieldChange
FieldDefault
FieldEdit
FieldFormula
PrePopup
RowDelete
RowInit
RowInsert
RowSelect
SaveEdit
SavePostChg
SavePreChg
SearchInit
SearchSave
Workflow

FieldChange
FieldDefault
FieldEdit
PrePopup

RowDelete
RowInit
RowInsert
RowSelect
SaveEdit
SavePostChg
SavePreChg
SearchInit
SearchSave

PostBuild
PreBuild
SavePostChg
SavePreChg
Workflow

Page

Menu

Activate

Item
Selected

Navigations to access definition events

PeopleCode Events
Record Level events takes precedence over the
Component level events.

For Example:
We have some code at both Record Level and Component
Record level. In this case, first Record level code is
executed first and then Component record level code is
executed.

PeopleCode Events
SearchInit Event
Firing:
Search init PeopleCode fires before the search record dialog box displays. to
control processing before the user enters values in the search key and alternate
search key fields.
Purpose:
To assign the default values and change the behavior of the search dialog box.
To change the properties of the S.K and A.S.K fields programmatically.
Description:
Search init is valid only on search key fields and Alt search key fields, not valid for
non search key fields. If we write any code on non search key fields, it will not
execute through out the life time of the application.

PeopleCode Events
SearchInit Event
For example:
Emplid (Field)
SearchInit
Emplid=100 SetSeachDialogBehavior (0);
Emplid (Field)
SearchInit
Emplid=%UserId SetSeachDialogBehavior(0);
Emplid (Field)
SearchInit
Emplid=%EmployeeId; Gray (EmplId);
AllowEmplIdChg(true);

PeopleCode Events
SearchSave Event
Firing:
After entering all the required values into the dialog box when we click the search
button, search save event will Fires.
Purpose:
To restrict the user to access the data from the database to Component unless
knowing the S.K or A.S.K values. It forces the user to enter the values
into the dialog box.
Description:
Search save is nothing but a save edit. Search save also Valid only on search key
fields and alt search key fields, Not valid for non search key fields. If we write
any code on Non search key fields, it will not execute through out the Life time
of the application. Search save does not fire when Values are selected from the
search list.

PeopleCode Events
SearchSave Event Examples

If none (Emplid, Name) then


Error (you cant enter without knowing the key values);
End-if;
IF Not Record Changed (psu_Student_tbl.Student_id) And %Mode <>
A Then
Error (you must enter at least one search value.);
End-if;

PeopleCode Events
RowSelect Event
Recommendation is dont use this event for writing the code. For this PeopleSoft
gave some Built-in functions like scroll select family.
Firing:
The Row Select event fires at the beginning of the Component Build process in
any of the Update action modes (Update, Update/Display All, Correction).
This event also occurs after a Scroll Select or related function is executed.

Purpose:
To filter the data while reading rows from database to component buffer. For
example if we enter any value in search key dialog box it(Application Processor)
will goes to the database and search for the required value if found it displays
the data.

RowSelect Event

PeopleCode Events

Application Processor:
Application processor searches in database for the search record, if found it
displays.
Application processor brings the records from the database and place at buffer
then buffer to the component.
Scroll select is the Built-in function useful to retrieve the data form the buffer to
the scroll.
Example:
If %Page=Component.BEN_PROG_PARTCIPN then
If COBRA_EVENT_ID>0 Then
DiscardRow();
End-If;
End-If;

PreBuild Event

PeopleCode Events

Firing
The Prebuild event fires before the rest of the component build events.
BEFORE DISPLAYING THE COMPONENT
Purpose:
To change the properties of the component and component fields according to
the user requirements.
To define the component variables.
To hide or unhide pages.
Description:
This event is only associated with components.
The PreBuild event is also used to validate data entered in the search dialog,
after a prompt list is displayed.

PeopleCode Events
PreBuild Event
Example :
Component array of array of string &CommentArray;
Local array of string &Min;
/*********************************************/
/*

Load the array

*/

/***************************************************/
&Min = CreateArray(1,100,200,300);

PeopleCode Events
FieldDefault Event

Purpose:
To assign the default values to the field programmatically.
Description:
We can assign default values in 2 ways. One is in Application Designer and
other is by using PeopleCode Field Default event.
If the default value is assigned in the Record field properties then the system
wont execute the PeopleCode default value.
Means The Record field properties will override the PeopleCode.

PeopleCode Events
FieldDefault Event
Example:
Userid
Field default
(Field)
(Event)
------------------------------------------------------------------------------Evaluate %userid
When ABC
Employee Name= srinivas;
Break;
When XYZ
Employee name= nani;
Break;
When-other
Employee Name= NO name;
Break;
End-Evaluate;

PeopleCode Events
FieldDefault Event
Example2:
Maritial Status
Field default
(Field)
(Event)
-------------------------------------------------------------If Age>25 then
MS=Y
Else
MS=N
End-if;

PeopleCode Events
FieldFormula Event
Firing
Field Formula fires after Field default completes successfully, regardless of
whether a field has a value.
Purpose:
For writing the user defined functions in the functional libraries.
Description:
PeopleSoft recommendation is dont use the event for writing the PeopleCode.
Draw back is it will execute for each and every user actions (except save) for
each and every row in the component buffer, so it increase the network traffic
and affects the performance of the Application program.

PeopleCode Events
RowInit Event
Firing
The RowInit event fires the first time the Component Processor encounters a
row of data.
It also occurs when an operator inserts a row (F7),but just on the new row of
data.
Purpose:
RowInit event controls the intial appearance of the fields.
DO CALUCULATIONS.
DATA SECURITY
Description:
Do not use Error or Warning statements in RowInit PeopleCode as it leads to
the cancellation of the component.

PeopleCode Events
RowInit Event
Example:
IF %Component=Component.ABSENCE_HISTORY Then
IF REG_REGION_COUNTRY=NLD Then
ABSENCE_HIST.RETURN_DT.Label=MsgGetText(6524,124,Return Date &Time);
End-If;
End-If;

PeopleCode Events
PostBuild Event
Firing:
The PostBuild event fires after all the other component build events have fired.
Purpose:
To change the properties of the component and component fields according to the
user requirements.
To define the component variables.
To hide or unhide pages.
Description:
This event is only associated with components.
The PostBuild event is also used to validate data entered in the search dialog and
entire component buffer fields

PeopleCode Events
PostBuild Event
Example:
Component Rowset &Ab_Hist_Rs;
&Ab_Hist_Rs=CreateRowset(Record.ABSENCE_HIST);
&Ab_Hist_Rs.Fill(Where Emplid=:1 ,PERSONAL_DATA.EMPLID);

PeopleCode Events

Activate Event

Firing:
Activate PeopleCode event fires every time the page is activated.
Purpose:
To change the Properties of the page and page fields.
Description:
This is only the one event for writing PeopleCode for Page object.

PeopleCode Events
FieldEdit Event

Firing
The FieldEdit event fires on the specific field and row when it changed and the
new value of the field satisfies the standard system edits.
Purpose:
In addition to the system edits we can put some more edits to validate the field
values.
For example: Suppose that salary is one field and is a numeric value, so we
cant enter character values to this field, this will take care by the system
nothing but system edit. Now we want add some more edits in addition to the
system edit like the salary should be >50,000, for this we have to write this
code in the Field Edit event.

PeopleCode Events
FieldEdit Event

Salary (Field)

Field Edit

If Salary< 50000 then


Error (Minimum salary should be > 50000);
End-if;
/* once we get the error message, unless we rectify the error the cursor wont
move to the next. */

PeopleCode Events
FieldChange Event

Firing:
This event occurs when a field is changed ,the standard system edits have been
passed , and the FieldEdit event is completed successfully.
Purpose:
To assign the calculated values to the field by programmatically.
To change the properties of the other field based on this field Value.
To Run Programmes and Processes
Description:
Unless the Field edit executes the Field change will not execute.
It is not used for validation.

PeopleCode Events
FieldChange Event

Example:
Maritial Status
Field Change
(Field)
(Event)
-----------------------------------------------------------If Maritial Staus=N then
Hide (SPOUSE Name);
Hide (NO OF CHILDS);
End-if;

PeopleCode Events
RowInsert Event

Firing
Row Insert event fires when a new row is inserted into Scroll .
Purpose:
To restrict some users to insert new rows into scrolls.
For example: suppose that 15 users are having the permission to access the
component. But I dont want to allow all the users to insert the rows. I want to
allow some users whose permission list is All Panels; it is possible by writing
code under Row insert event.
Description:
It is valid only if the component is having scrolls (means child records). The
program never executes unless there is scrolls, not valid for 0 level records.

PeopleCode Events
RowInsert Event

Example :
IF RecordNew(EMPLID) Then
IF None(BUSINESS_UNIT) Then
&Bus_Unit=Fetchvalue(OPR_DEF_HR_TBL.BUSINESS_UNIT,1);
BUSINESS_UNIT=&Bus_Unit;
End-IF;
END-IF;

PeopleCode Events
RowDelete Event

Firing
Row Delete event fires when a user deletes a row of data.
Purpose:
To restrict some users to delete rows from the scrolls.
To recalculating the field values.
Description:
It is valid only if the component is having scrolls (means child records). The
program never executes unless there is scrolls, not valid for 0 level records.

PeopleCode Events
SaveEdit Event

Firing:
When we click the save button the Save Edit Event will fire.
Purpose:
It works same as Field Edit. Useful to validate the data which is available in the
Component fields.
Description:
Use the Field Edit event when we want to validate one field. But use the Save
Edit event when we want to validate more than one filed.
So that we can increase the performance of the Application.

PeopleCode Events
SaveEdit Event

Example:
If Not ALL(EMPLID,NAME) Then
Error Emplid & Name should not be left blank;
End-IF;

PeopleCode Events
SavePrechange Event

Firing:
After SaveEdit completes successfully, the application processor applies the
SavePrechange event.
Purpose:
It provides one last chance to manipulate the data before the database is
updated.
Description:
Based on the validated values entered into the component ,you may need to
calculate the fields or change the display characteristics.

PeopleCode Events
SavePrechange Event
Example:
If PER_STATUS=E Then
Assign_Employee_ID(EMPLID);
End-If;

PeopleCode Events
Workflow Event
Firing:
Workflow PeopleCode fires immediately after SavePreChange and before the
database update that precedes SavePostChange.
Purpose:
To write the PeopleCode for workflow purpose (Office automation purpose).
Description:
Under this event we can write the PeopleCode that is only related to workflow.
Workflow PeopleCode is not field-specific; it is an application specific means it
executes for all fields and on all rows of data available in the component buffer.

PeopleCode Events
Workflow Event
Example:
We are going to use the below function in the Workflow event
TriggerBusinessevent()

PeopleCode Events
SavePostChange Event
Firing:
This is the last event before the database is committed.
Purpose:
To update the data not in the component buffer , we use this event.
SQLEXEC function is used to update the database fields.
Description:
The system isses an SQL COMMIT when the SavePostChange event completes
successfully. If errors or warnings are rececived before SavePostChange
completes, all updates made to the database are rolled back.

PeopleCode Events
SavePostChange Event
Example:
If &Count=0 Then
SQLEXEC(Update PS_PAYROLL_DATA set company=:1 where
EMPLID=:2,COMPANY,EMPLID);
End-If;

Events Flow

Updat
e

SearchIn
it

SearchSave
RowSelect

Add

PreBuild

FieldDefault

FieldEdit

FieldChange

SaveEdit

FieldFormula

SavePreChange

RowInit

RowInsert

WorkFlow

PostBuild

Activate

RowDelete

SavePostChange

Data Types
1.
2.

Conventional data types.


Object data types.

Conventional Data Types


data types are :

Any : Undeclared local variables are Any by default.

Boolean

Date

DateTime

Float

Integer

Number

Object

String

Time

Data Types Contd..


Object based data types are :
Field
Record
Row
Rowset
Grid
Page
Array
File
SQL
For complete listing People Books
need to be referred

PeopleCode Comments
/* Statement .*/
You can surround comments with /* at the beginning and */ at the end.
Ex: /* ----- Logic for Compensation Change ----- */
/* Recalculate compensation change for next row.
Next row is based on prior value of EFFDT. */
Rem or Remark
You can also use a REM (remark) statement for commenting. Put a
semicolon at the end of a REM comment.
Note: If you do not, everything up to the end of the next statement is
treated as part of the comment.
Ex: REM This is an example of commenting PeopleCode;

PeopleCode Operators
Operators
mathematical

->

comparison

->

logical

->

+,-,*,/,**,|
=,!=,<>,>=,<=,<,>
NOT,AND,OR

Note:- PeopleCode applied NOT operator first ,then


ANDs ,and the ORs. You can use parenthesis to explicitly
define the order of precedence.

PeopleCode Statements
Branching Statements:
Branching statements control program flow based on evaluation of
conditional expressions.

If, Then, and Else


Evaluate
For
Repeat
Conditional Loops
While

PeopleCode Statements
if Statement:

syntax:

break statement:

if <condition>
stmt1;
else
stmt2;
end-if;
syntax:

break;

Evaluate Statement
Evaluate <field or variable>
when = <value1>
stmt1; break;
when = <value2>
stmt2; break;
when-other
stmt3;break;
End-Evaluate;

PeopleCode Statements
Looping Statements
loop type
while

syntax
while <condition>
stmt1;

stmt2;

end-while;
repeat-until

repeat
stmt1; stmt2;
until <condition>;

for

for <&variable> = <start-value> to <end-value>


[Step stepvalue>]
stmt1; stmt2;

end-for;

PeopleCode Statements
Error Statements

Syntax :
Error(<message>);

Warning Statements

Syntax:
warning(<message>);

PeopleCode Variables

Scope
Local Variables
Global Variables
Component Variables
Other Variables
System Variables
Derived/Work Fields

PeopleCode Variables

Naming Rules
must begin with & and max length 18
characters including &
Declarations
always on top .
Can have only comments above it.
Syntax:
<scope> <type> &<variable_name>

PeopleCode Variables
Scope of Variables
Local Variables
existence limited to current PC program runtime assignment.
Also called chameleon variables as they can be assigned
values of any data type within the program.
Global Variables
exist for the complete session and are used to transfer values
between panel groups.
Component Variables
exist for the duration of the current PS
component.
Used to transfer values between programs on the same
component.

Other PeopleCode Variables


System Variables
-internally maintained and can be referred by the peoplecode any time.
-Begin with %.
Ex:

%Date,%Time,%Panel,%Menu etc.

Derived/Work Fields
-used when we need to pass values from one program to another without
the field values being stored in the database.
-Existence limited to the current component.
-They are usually display only fields on a page
or have them as invisible fields on the page.

Functions
User defined functions
Built-in Functions
User defined functions
Internal PC
PeopleCode functions contained within the same program where they are used.
External PC
PeopleCode functions contained in a different program from where they are
used.
Stored as Function Libraries( derived/work records) named
with prefix FUNCLIB_ convention and defined in the FieldFormula Event.
External-Non-PC
These are routines or functions written in other language like C and
loaded from a DLL (Dynamic Link Librabies).
Defined by the statement Declare....... Library .

Functions
Syntax for defining or writing a function
Function <function_name> (<param1,<param2>....)
stmt1;
stmt2;
return <expression>;
End-Function;
Function should be defined in the beginning of the code in FieldFormula event.
We can have only comments lines preceding the function definition.
Syntax for Declaring a Function
Declare Function <function_name> PeopleCode
<Record_name.FieldName> FieldFormula
This should be the first statement in the event where an external function is used.

Built-in Functions
Component Buffer Functions
Used to modify,update,hide fields in the buffer area.
Example: Hide() ,Unhide() , Gray() , ungray()etc
Scroll Buffer Functions
Used to manipulate scroll bar records rather than the entire
components data.
Example: ScrollSelect(), ActiveRowCount() , TotalRowcount()..etc.,

Logical Functions

Used to check if values exist for a field.


Example: None(), All() , OnlyOne(), AllorNone() ,
OnlyoneorNone()

Built-in Functions
Date & Time Functions
Used to calculate and manipulate dates.
AddToDate(date,num_years,num_months,num_days)
String Functions
Used to manipulate character Strings
Substring(Source str,start_pos,length)
Math Functions
Used to perform mathematical calculations
Sine(),abs(),Max(),Min()
Security Functions
Used for security purpose.
Hide(),Unhide(),Gray(),Ungray()

Built-in Functions
Message Catalog and Message Display

Error
MessageBox
MsgGet
MsgGetText
MsgGetExplainText
Warning
WinMessage

Built-in Functions
Message Catalog and Message Display
Error
Syntax:

Error st

Use the Error function in FieldEdit or SaveEdit PeopleCode to stop


processing and display an error message. It is distinct from Warning,
which displays a warning message, but does not stop processing.
Error is also used in RowDelete and RowSelect PeopleCode events.
Errors in Other Events : Do not use the Error function in any of the
remaining events, which include:
FieldDefault
Prepopup
SavePreChange

- RowInit
- RowInsert
- SavePostChange

- FieldChange

Built-in Functions
Message Catalog and Message Display
Warning
Syntax:
Warning str
The primary use of Warning is in Field Edit and SaveEdit PeopleCode. In
FieldEdit, Warning displays a message and highlights the relevant field.
In SaveEdit, Warning displays a message, but does not highlight any
field. You can move the cursor to a specific field using the SetCursorPos
function.
Warnings in Other Events: Do not use the Warning function in any of
the remaining events, which include:
FieldDefault
- RowInit
FieldChange - RowInsert
SavePreChange
- SavePostChange

Built-in Functions
Warning
Example
If All(RETURN_DT, BEGIN_DT) and 8 * (RETURN_DT - BEGIN_DT) <
(DURATION_DAYS * 8 + DURATION_HOURS) then
Warning ( "Duration of absence exceeds standard hours for number of days
absent.");
End-if;

Built-in Functions
Message Catalog and Message Display
WinMessage
Syntax: WinMessage(message [, style] [, title])
The WinMessage function is supported for compatibility with previous
releases of PeopleTools. New applications should use MessageBox
instead.
Use the WinMessage function to display a message in a message box.
Winmessage cannot be used in the following PeopleCode events:
- SavePreChange.
- RowSelect.
- SavePostChange.
Example
&RESULT = WinMessage(MsgGetText(30000, 1, "Message not found."), 4,
"Test Application");

Built-in Functions

MsgGet
Syntax: MsgGet(message_set, message_num, default_msg_txt [,
paramlist])
where paramlist is an arbitrary-length list of parameters of undetermined
(Any) data type to be substituted in the resulting text string, in the form:
param1 [, param2]

Use the MsgGet function to retrieve a message from the PeopleCode


Message Catalog and substitutes in the values of the parameters into
the text message.

Message sets 1 through 19,999 are reserved for use by PeopleSoft


applications. Message sets 20,000 through 32,767 can be used by
PeopleSoft users
Example
&MsgText = MsgGet(30000, 2, "Message not found");

Built-in Functions
Logical

All
AllOrNone
None
OnlyOne
OnlyOneOrNone

Built-in Functions
Logical
All :
All(fieldlist)
Where fieldlist is an arbitrary-length list of field names in the form:
[recordname.]fieldname1 [, [recordname.]fieldname2] ...
Returns: Returns a Boolean value based on the values in fieldlist. The All
function returns True if all of the specified fields have a value; it returns False
if any one of the fields does not contain a value.
Example: The All function is commonly used in SaveEdit PeopleCode to
ensure that a group of related fields are all entered.
example:
If All(RETURN_DT, BEGIN_DT) and 8 * (RETURN_DT - BEGIN_DT)
(DURATION_DAYS * 8 + DURATION_HOURS) Then
Warning MsgGet(1000, 1, "Duration of absence exceeds standard hours for
number of days absent.");
End-if;

Built-in Functions
Logical
AllOrNone:

AllOrNone(fieldlist)

Where fieldlist is an arbitrary-length list of field references in the form:


[recordname.]fieldname1 [, [recordname.]fieldname2] ...
The AllOrNone function takes a list of fields and returns True if either of
these conditions is true:
All of the fields have values OR None of the fields has a value.
For example, if field1 = 5, field2 = "Mary", and field3 = null,
AllOrNone returns False.
Returns a Boolean value: True if all of the fields in fieldlist or none of the
fields in fieldlist has a value, False otherwise.
Example :You could use AllOrNone as follows:
If Not AllOrNone(STREET1, CITY, STATE) Then
WinMessage("Address should consist of at least Street (Line 1), City,
State, and Country.");
End-if;

Built-in Functions
Logical
None :
None(fieldlist)
Description: None returns True if none of the specified fields contain a
value. It returns False if any one of the fields contains a value.
A blank character field, or a zero (0) numeric value in a required numeric
field is considered a null value.
Example: The following example uses None to check whether
REFERRAL_SOURCE has a value:
If None(REFERRAL_SOURCE) or REFERRAL_SOURCE = "EE" Then
Gray(EMP_REFERRAL_ID);
End-if;
The following example uses None with a variable:
&ONETIME = FetchValue(POSN_INCUMB_WS.EMPLID, 1);
If None(&ONETIME) Then
/* do processing */
End-if;

Built-in Functions
Logical
OnlyOne :
OnlyOne(fieldlist)
Description: Use the OnlyOne function to check a list of fields and return
True if one and only one of the fields has a value. If all of the fields are
empty, or if more than one of the fields has a value, OnlyOne returns
False. This function is used to validate that only one of a set of mutually
exclusive fields has been given a value.
A blank character field, or a zero numeric value in a required numeric field is
considered a Null value.
Example:

You typically use OnlyOne as follows:

If OnlyOne(param_one, param_two) Then


value_a = "y";
End-if;

Built-in Functions
Logical
OnlyOneOrNone
Syntax: OnlyOneOrNone (fieldlist)
Where fieldlist is an arbitrary-length list of field names in the form:
[recordname.]fieldname1 [, [recordname.]fieldname2] ...
Use the OnlyOneOrNone function to check a list of fields and return True
if either of these conditions is true:
Only one of the fields has a value (OR) None of the fields has a value

Built-in Functions
Executable Files Functions:
Exec
WinExec
Mailing Functions:
Sendmail

Built-in Functions
Executable Files Functions:
Exec
Syntax: Exec(command_str [, parameter])
where parameter has one of the following formats:
Boolean constant
Exec_Constant + Path_Constant
Exec is a cross-platform function that executes an external program on
either UNIX or Windows
When Exec is used to execute a program synchronously (that is, if its
synch_exec parameter is set to True) it behaves as a think-time function,
which means that it cant be used in any of the following PeopleCode
events:
SavePreChange.
SavePostChange.
Workflow.
RowSelect.

Built-in Functions
Executable Files Functions:
Exec
Syntax: Exec(command_str [, parameter])
where parameter has one of the following formats:
Boolean constant
Exec_Constant + Path_Constant
Exec is a cross-platform function that executes an external program on
either UNIX or Windows
When Exec is used to execute a program synchronously (that is, if its
synch_exec parameter is set to True) it behaves as a think-time function,
which means that it cant be used in any of the following PeopleCode
events:
SavePreChange.
SavePostChange.
Workflow.
RowSelect.

Built-in Functions
Executable Files Functions:
Exec
Syntax: Exec(command_str [, parameter])
where parameter has one of the following formats:
Boolean constant
Exec_Constant + Path_Constant
Exec is a cross-platform function that executes an external program on
either UNIX or Windows
When Exec is used to execute a program synchronously (that is, if its
synch_exec parameter is set to True) it behaves as a think-time function,
which means that it cant be used in any of the following PeopleCode
events:
SavePreChange.
SavePostChange.
Workflow.
RowSelect.

Built-in Functions
SQL

SQLExec
CreateSQL
GetSQL
DeleteSQL

Built-in Functions
SQL Functions
SQLExec: SQLExec({sqlcmd | SQL.sqlname}, bindexprs, outputvars)
where bindexprs is a list of expressions, one for each :n reference within sqlcmd or
the text found in the SQL definition sqlname, in the form:
inexpr_1 [, inexpr_2]. . . and outputvars is a list of variables, record fields, or
record object references, one for each column selected by the SQL command, in
the form:
out_1 [, out_2]. . .
Use the SQLExec function to execute a SQL command from within a
PeopleCode program by passing a SQL command string.
The PeopleSoft record name specified in the SQL SELECT statement must
be in uppercase
SQLExec commands go directly to the database server, not to the
Component Processor

Built-in Functions
SQL Functions
Bind Variables in SQLExec:
Bind variables are references within the sqlcmd string to record fields listed in
bindvars. Within the string, the bind variables are integers preceded by colons
like :1, :2,. . .
The integers need not be in numerical order.
Bind variables can be used to refer to long character (longchar) fields. Long
character fields are represented in PeopleCode as strings
You should use %TextIn() Meta-SQL to ensure these fields are represented
correctly on all database platforms.
Bind variables can be passed as parameters to meta-SQL functions
Example:
SQLExec(". . .%datein(:1). . .", START_DT, &RESULT)
SQLExec("Select sum(posted_total_amt) from PS_LEDGER where deptid
between :1 and :2", DEPTID_FROM, DEPTID_TO, &SUM);

Built-in Functions
SQL
Limitations of SQLExec
SQLExec can only Select a single row of data. If your SQL statement (or
your SQL.sqlname statement) retrieves more than one row of data,
SQLExec sends only the first row to its output variables.Any subsequent
rows are discarded.
If you need to SELECT multiple rows of data, use the CreateSQL or
GetSQL functions and the Fetch SQL class method.
SQLExec statements that result in a database update (specifically,
UPDATE, INSERT, and DELETE) can only be issued in the following events

SavePreChange
WorkFlow
SavePostChange
FieldChange

Вам также может понравиться