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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parse CSV string into numeric array 3

Status
Not open for further replies.

jpsowers

Programmer
Jun 5, 2003
3
US
I have a CR 8.5 report that accepts a string as a parameter.
The string will be a comma seperated list of numbers (1,3,5,1,46,etc).
I need to use these numbers in an 'IN' selection.
{numeric_field_name} in {?CSVStringParameter}

I have tried something like:
{numeric_field_name} in makearray(tonumber(join{?CSVStringParameter},",")))
but it is not correct.
Split and Join do not seem to be the right way to do this.
Any help is appreciated.
Thanks.
 
This won't pass to the database, but it does what you're looking for:
[tt]
StringVar Array parm := Split({?CSVStringParameter},",");
NumberVar Array num;
Redim num[ubound(parm)];
NumberVar i;

For i := 1 to UBound(parm) do(
num := Val(parm));

{numeric_field_name} in num;
[/tt]
If you're dealing with a small amount of data, that might be fine. Otherwise, you'd be better off using a numeric multi-value parameter.

-dave
 
Thanks Vidru,
That gives me a true/false evaluation, but I need each value out of the csv to pass forward and use in the filter of the report.
Do you have any ideas for that?
Also, I am not sure about using the multivalue parameter, we are using the Java SDK and this variable length string is being passed in from a web page.
Thanks again.
 
Hi,
Try:

{numeric_field_name} in '[' + {?CSVStringParameter} +']'

[profile]
 
Thanks TB but the CSV is a string and that give you a 'A numeric value is required here' error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top