Wednesday, April 30, 2014

No Auto Select' check box

There was a page which was taking too long to load. The search page was bypassed. The page after load had a search button to display data in grid.

This performance issue was resolved by selecting 'No Auto Select' check box of grid.

Tuesday, April 1, 2014

Upgrade PSQuery after change in Record structure

Open every query, we would be prompted with a message that the record structure has undergone changes and we may just have to follow as recommended.

To test compare the result of old query vs new query.

Avoid using the SqlExec statements in the PeopleCode

Some of the issues with SQL Exec are: 
1. It can select only single row of data. 
2. It surpass the component processor and interacts directly with Database server. 
3. It has to be used in only limited number of events and that too you can cause data consistency problems if not timed properly. 

 #1 is precisely the reason why you'll use SQLExec if your requirements demand it. SQLExec outputs only the first row to its output variables. Any subsequent rows are discarded. This means if you only want to fetch a single row, SQLExec can perform better than the other SQL functions, because only a single row is fetched.

SQL objects for insert/update/delete for all of the above and they are well documented within PeopleBooks. The record object has methods called Update(), Delete(), Insert(). It also has methods called SelectByKey() and SelectByKeyEffdt() which can be used for selecting into the record object.

Disabling paste on an input field (not verified)

A colleague of mine recently had a requirement to place an email address field on a page, and then just below it a ‘confirm email address’ – however the user should not be permitted to copy and paste from the first field to the second, they should retype their email address.

We didn’t think that there was a way of disabling paste via PeopleCode, so resorted to JavaScript. The solution was actually quite straightforward in the end:

1) Place the two input fields on the page and connect them to the records you wish to save to, as usual.

2) Place an HTML Area on the page, making sure it’s beneath the other fields (both on this screen and the order tab).

3) Make the HTML Area contents static, and paste in the following:

<SCRIPT language=JavaScript>
var message = "Paste disabled. Please re-key.";

function disablepaste(){
alert(message);
return false;
}

document.getElementById('DERIVED_TEST_TEXT2')
.onpaste=disablepaste;
</SCRIPT>

4) Swap DERIVED_TEST_TEXT2 in the above code snippet for you Record/Field name (i.e. it’s the record name, then an underscore, then the fieldname. Look in View Source or Chrome Dev Tools/Firebug if you’re not sure.)

5) You might also want to make the alert message a little more user friendly too.

UNION vs UNION ALL

Both UNION and UNION ALL concatenate the result of two different SQLs. They differ in the way they handle duplicates.
-UNION performs a DISTINCT on the result set, eliminating any duplicate rows.

-UNION ALL does not remove duplicates, and it therefore faster than UNION.

In ORACLE: UNION does not support BLOB (or CLOB) column types, UNION ALL does.