Home » Developer & Programmer » Reports & Discoverer » Appending data fields to text (Oracle Reports Developer 10.1.2.0.2, Unix, 10 G database)
Appending data fields to text [message #517953] Fri, 29 July 2011 16:27 Go to next message
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 Go to previous messageGo to next message
Littlefoot
Messages: 21808
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?
Re: Appending data fields to text [message #518012 is a reply to message #517953] Sun, 31 July 2011 07:11 Go to previous messageGo to next message
TX_developer
Messages: 46
Registered: July 2011
Member
Hi,

Thank you for your suggestions. I eventually figured it out. In the data model, I placed a formula field (report level outside groups). In it I added pl/sql code and placed a select statement "from dual" with my text and appending the two fields with ||. In the report layout I placed a field and referenced the formula column. This works great on three reports and on the fourth report, using the same logic, etc., the text does not wrap properly on one line. Nothing is different in this report that I can tell so I may try concatenating the fields to text with the & as you suggested, although I am not sure where/how to place the ampersand. Or do you have suggestions why the text is not wrapping in my field? It happens on the first line - at the end it cuts of part of a word. I even copied the field from another report and pasted it into this report still it does not work.

So I have a frame and inside this frame I have a text "field" followed by a regular field, followed by a text "field", etc. How do I place the ampersand in front of the text field when I "draw" it in my report layout? Sorry if this is a stupid question or if it does not make sense.

~k
Re: Appending data fields to text [message #518013 is a reply to message #517953] Sun, 31 July 2011 08:27 Go to previous message
TX_developer
Messages: 46
Registered: July 2011
Member
Never mind...figured it out. Thank you for your help.
Previous Topic: rep-1213 & rep-1517
Next Topic: Workbooks in Discoverer
Goto Forum:
  


Current Time: Thu Apr 25 09:43:36 CDT 2024