Appending data fields to text [message #517953] |
Fri, 29 July 2011 16:27 |
|
TX_developer
Messages: 46 Registered: July 2011
|
Member |
|
|
hi,
I know how to append fields to text, but how do I deal with the variable length? I want to place text on a report and inside the text I have data from two different fields. It works great except that my fields are 35 characters long. If the data fills the entire field it looks great, if the data is only 10 characters long, I have a huge gap between the end of the data and the text that follows. How do I fix this?
Thanks,
tx_developer
|
|
|
Re: Appending data fields to text [message #517958 is a reply to message #517953] |
Sat, 30 July 2011 01:24 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
As you didn't say HOW you do that, here are two options I use.
The first one is "&field_name" notation. For example, this is part of the text that includes someone's name and job:
My name is &employee_name and I work as &employee_job in a huge factory.
Another one requires you to store the whole text into the database (for example this can be used when dealing with contracts that are several pages long, have numerous sections and include any number of fields that are included in different sections). A report query selects text from a table. Text that should be replaced by column values (employee name, job, ...) have to be distinguished from other text, somehow. I do that by using "<<field_name>>" notation. For example, this is how one section looks like:
insert into contracts (id, section_id, text) values
(1, 1, 'This is a contract between Our Prosperous Company and <<employee_name>> who works as <<job_name>>. Blablabla bla bla');
Now, in a query, you have to replace all those "placeholders" with exact value:
select c.id,
c.section_id,
replace(replace(c.text, '<<employee_name>>', e.ename), '<<job_name>>', e.job) text
from contracts c,
employees e
where ...
I hope you got the idea. If none of these works for you, could you explain what you did so far, and how?
|
|
|
|
|