How do I fill a field in #dataTable# with underscores
Posted: Wed Jun 19, 2013 6:25 am
Hi,
I have a 1 page report that has about 40 fields in it. I select the original data from various tables and create #dataTable#. Since I have to use some logic to manipulate the data in #dataTable# before using it in the report, I have added many of these 40 fields to #dataTable# and have created corresponding variables for those 40 fields.
As I read the rows in #dataTable#, I check to see if the column has data. If it has data, I copy the data to the variable. If the column is empty, I want to fill the variable with underscores so it shows as an underline in the report wherever there is no data. I have tried the following code, which works fine:
As you can see I check to see if 'peo_company' is empty or not. If it is not empty, I move the contents from the column to the variable '$own_company'. If the column is empty, I fill the variable '$own_company' with underscores. Although this code works, it means I have to carefully figure out how many underscores to put into the variable.
The only other option I could find was to fill the variable with underscores using LPAD or RPAD. I tried the following code but there must be something wrong with it because, it will no longer create the report.
I need to have someone tell me what is wrong with the syntax for RPAD (or LPAD) or offer an alternative. The research I have done on RPAD and LPAD always has examples using a SELECT statement. Can I not use RPAD or LPAD in my example?
Thanks,
John
I have a 1 page report that has about 40 fields in it. I select the original data from various tables and create #dataTable#. Since I have to use some logic to manipulate the data in #dataTable# before using it in the report, I have added many of these 40 fields to #dataTable# and have created corresponding variables for those 40 fields.
As I read the rows in #dataTable#, I check to see if the column has data. If it has data, I copy the data to the variable. If the column is empty, I want to fill the variable with underscores so it shows as an underline in the report wherever there is no data. I have tried the following code, which works fine:
Code: Select all
if (!empty($row->peo_company))
$own_company = $row->peo_company;
else
$own_company = '_____________________________';
The only other option I could find was to fill the variable with underscores using LPAD or RPAD. I tried the following code but there must be something wrong with it because, it will no longer create the report.
Code: Select all
if (!empty($row->peo_company))
$own_company = $row->peo_company;
else
$own_company = RPAD('_', 25, '_');
Thanks,
John