Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Function to take a list of values and add qoutes to each value

Posted on 2009-05-05
Medium Priority
347 Views
Does anyone have a function written that can take a list of values and add quotes around each value.  Example input = 1001,1002,1003 Output '1001','1002','1003' However if they just entered one value it would return '1001' if 1001 was the input.

Thanks in advance for the help,
Montrof
0
Question by:montrof
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 4
• 4

LVL 37

Expert Comment

ID: 24311266
you don't need a function for that
try:

select
case when posstr(list_value, ',') > 0 then ''''|| replace(list_VALUE, ',', ''',''') || ''''
else ''''|| list_value || ''''

from your_table
0

LVL 1

Author Comment

ID: 24313947
Thank you for the suggestion but it does not seem to work because the case statement can only return one vaule.  The case is located in my where clause  and  {?SalesPerson} is a parameter passed from crystal

``````AND
Case
WHEN  '{?Salesperson}' = 'ALL' THEN 1
WHEN '{?Salesperson}' <> 'ALL' AND OASMCD IN (
case when posstr({?Salesperson}, ',') > 0 then
char(39) || replace(char(44),{?Salesperson},  Char(39) || char(44) || char(39)) || char(39)
Else char(39) || {?Salesperson} || char(39)
END )
THEN 1
ELSE 0
END = 1
``````
0

LVL 37

Accepted Solution

momi_sabag earned 2000 total points
ID: 24314563
that won't work with a function either
you can't do what you are trying to do
is OASMCD int or char?
if it's char, try to change the condition to
WHEN '{?Salesperson}' <> 'ALL' AND (
< case comes here > like OASMCD||',%'||
or < case comes here > like ||'%,'||OASMCD||',%'||
or < case comes here > like ||'%,'||OASMCD
or ?Salesperson = OASMCD
)
0

LVL 1

Author Comment

ID: 24314604
The case statement you are refereing to was the one you gave me previously. Just checking.
0

LVL 37

Expert Comment

ID: 24314969
yep
0

LVL 1

Author Comment

ID: 24315567
Still no go.
0

LVL 37

Expert Comment

ID: 24323082
can you post your code here?
0

LVL 1

Author Closing Comment

ID: 31578221
Thanks for the help, I had made a typo that is why it was not working thanks for you help
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
###### Suggested Courses
Course of the Month11 days, 23 hours left to enroll