Category: <span>FAQs and Tips</span>

Q. How can I assign a null value to a table column using embedded SQL? The RPG %Nullind function doesn’t seem to work for an SQL Update or Insert statement.

This procedure will return a variable length text string representing a date. For example:

String = Datetext(D'2010-01-01');     // Returns 'January 1, 2010'
String = Datetext();                  // Returns formatted system date 
String = Datetext(Mydate);            // Returns formatted date in Mydate

Here is the procedure code:

Q. I am trying to find out which user is causing a record lock. I should be able to get some basic information on the record lock by examining the exception data subfield in the Program Status Data Structure (PSDS). But instead of the promised “Record in use by job …” data which actually names the job holding the lock, I get a more generic “Unable to allocate a record…” message.

What’s up with that?

The RPG IV language introduces several powerful built-in functions that simplify string-handling requirements. You can add a few more string-related procedures to come up with a complete toolbox for processing text. The Centertext procedure centers a string field, a function that’s handy for centering headings on reports and displays.