Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a Comma seperated String based on all Rows values of a Column

Status
Not open for further replies.

khan007

Programmer
Jun 10, 2003
103
CA
Hello Gurus,

I am facing a problem to keep "all values of one column as one
string".

Example: I have a column "JOB ID", which contains five rows. I want to
keep all five rows as one string seperated by commas, like
"10010,10011,10012,10013, 10014".

If would appreciate that if anyone help me out as early as possible.

I can't create an external SQl object, else I know how to create afunction or stopred procedure to achieve that task.


Thank you,
Khan
 
You can insert a group on Job ID and then create the following formulas:

//{@reset} for the Job ID group header:
whileprintingrecords;
stringvar jobs;
if not inrepeatedgroupheader then
jobs := "";

//{@accum} to be placed in the detail section and suppressed:
whileprintingrecords;
stringvar jobs := jobs + totext({table.jobID},0,"")+",";

If jobID is already a string, remove the totext(,0,"").

//{@display} to be placed in the gorup footer:
whileprintingrecords;
stringvar jobs;
if len(jobs)>1 then
left(jobs,len(jobs)-1)

Then suppress the group header and the details section.

-LB
 
Thanks a lot LB.

Let me repeat it, what I understand.

First Create a group of Job ID.
Then create three formulas.
{@reset} -- to be placed in Job ID group header and suppressed
{@accum} -- to be placed in the detail section and suppressed
{@display} -- to be placed in the gorup footer

Is it the correct order?
Let me do it now.
Thanks again.

 
Hello LB,

I created following:

//{@reset}
whileprintingrecords;
stringvar jobs;
if not inrepeatedgroupheader then
jobs := "";


//{@accum}
whileprintingrecords;
stringvar jobs := jobs + {table.jobID}+",";

{@display}
whileprintingrecords;
stringvar jobs;
if len(jobs)>1 then
left(jobs,len(jobs)-1)


I am getting only one Job iD.
Can you help me with that, please.

Thanks in advance
 
Please review my original post and place the formulas in the locations I indicated.

-LB
 
I'm sorry, I see I misspoke. You don't need a group on Job ID if you don't have any duplicates, and you appear not to, and if you are not doing this within some group, you don't need the reset formula. Just place {@accum} in the detail section, and place {@display} in the report footer.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top