SelectNew method: Rowset class
Syntax
SelectNew([parmlist], RECORD.selrecord [, wherestr, bindvars])
Where paramlist is a list of child rowsets, given in the following form:
SCROLL.scrollname1 [, SCROLL.scrollname2] . . .
The first scrollname must be a child rowset of the rowset executing the method, the second scrollname must be a child of the first child, and so on.
Description
The SelectNew method is similar to the Select method, except that all rows read into the rowset are marked new so they are automatically inserted into the database at Save time. This capability can be used, for example, to insert new rows into the database by selecting data using a view of columns from other database tables.
Note:
This method is valid only when used with rowsets that reference data from the Component buffers. You cannot use this method with a message rowset, a rowset from an Application Engine state record, and so on. You can’t use this method with rowsets created using the CreateRowset function (use the Fill method instead.)
Parameters
| Parameter | Description |
|---|---|
|
paramlist |
An optional parameter list, for specifying children rowsets of the rowset executing the method, as the rowset to be selected into. The first scrollname in paramlist must be a child rowset of the rowset executing the method, the second scrollname must be a child of the first child, and so on. |
|
RECORD.selrecord |
Specifies the select record. The selrecord record must be defined in Application Designer and be a build SQL table (using Build, Project) as a table or a view, unless selrecord is the same record as the primary database record associated with the rowset. selrecord can contain fewer fields than the primary record associated with the rowset, although it must contain any key fields to maintain dependencies with other records. |
|
wherestr |
Contains a WHERE clause to restrict the rows selected from selrecord and/or an ORDER BY clause to sort the rows. The WHERE clause can contain the PeopleSoft meta-SQL functions such as %DateIn() or %CurrentDateIn. It can also contain inline bind variables. |
|
bindvars |
A list of bind variables to be substituted in the WHERE clause. The same restrictions that exist for SQLExec exist for these variables. See SQLExec for further information. |
Returns
The number of rows read (optional.) This counts only the lines read into the specified rowset. It does not include any additional rows read into any child rowsets of the rowset.
Example
The following example selects rows from DATA2 and reads them into a level one scroll. If the user saves the page, these rows are inserted into DATA1.
&LEVEL0.SelectNew(SCROLL.DATA1, RECORD.DATA2, "Where SETID = :1 and CUST_ID =:2",⇒
CUSTOMER.SETID, CUSTOMER.CUST_ID);
If you use the same WHERE clause in more than one Select, you may want to use the SQL repository to store the SQL fragment. That way, if you ever want to change it, you will have to change it in only one place.
&LEVEL0.SelectNew(SCROLL.DATA1, RECORD.DATA2, SQL.Select_New);
Related Topics