Concatenate contents of a field from multiple records

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Concatenate contents of a field from multiple records

Postby m2 » Sun Oct 17, 2004 11:32 pm

1) I need to create a report in which all entries in a particular text field are concatenated with a semicolon in between. Example: the field in record 1 reads "green, except on wednesdays". In record 2 the field contains "bleu, blanc et rouge" and in record 3 it contains "red with white spots; green, yellow; purple". The result I seek would be: "green, except on wednesdays; bleu, blanc et rouge; red with white spots; green, yellow; purple".

2) I also want to list the dates from these records with one date per line, and no duplicates. There is a date field in each record. I have it in a tabpanel but that contains duplicates when there was more than one entry on that date. Example:

02/11/2004
02/14/2004
02/24/2004

thanks...
m2
 
Posts: 1
Joined: Fri Sep 10, 2004 6:47 am

Re: Concatenate contents of a field from multiple records

Postby bcusick » Wed Oct 20, 2004 7:55 pm

m2 wrote:1) I need to create a report in which all entries in a particular text field are concatenated with a semicolon in between. Example: the field in record 1 reads "green, except on wednesdays". In record 2 the field contains "bleu, blanc et rouge" and in record 3 it contains "red with white spots; green, yellow; purple". The result I seek would be: "green, except on wednesdays; bleu, blanc et rouge; red with white spots; green, yellow; purple".


Steps:

1) FIND the records you need;

2) LOOP through the records and build up the string you want in a local variable or global.


m2 wrote:2) I also want to list the dates from these records with one date per line, and no duplicates. There is a date field in each record. I have it in a tabpanel but that contains duplicates when there was more than one entry on that date. Example:

02/11/2004
02/14/2004
02/24/2004


STEPS:

1) Find the records (from above)

2) Put the date from the first record into a local variable or global

3) When you go to the next record - see if the global contains that date string or not. If NOT, then add it to the end of the variable.

Hope this points you in the right direction.

Bob Cusick
bcusick
 
Posts: 1255
Joined: Wed Apr 23, 2003 11:27 pm
Location: Thousand Oaks, CA USA


Return to How To

Who is online

Users browsing this forum: No registered users and 5 guests

cron