how to overcome string at most 65534 characters long

Hi,

I have formula in my CR 2008. It was working okay when there was less data.

However now I get message "a string can be at most 65534 characters long".

Please revise my existig formula to overcome this error.

Formula name: RESULT

stringvar prefix;
stringvar country;
stringvar route;
stringvar Type;
stringvar output;
prefix:={Sheet3_.Access};
country:={Sheet3_.Country} ;
route:= {Sheet3_.Routes};
type:="4";

numbervar x;
numbervar ub;
stringvar array Routes;
routes:=split(route,",");
ub:= ubound(routes);
for x:=1 to ub-1 do

output:= output & "Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('"&Prefix&"',"&"'"&mid(country,1,15)&"',"&"'"&routes[x]&"',"&"'"&totext(x-1,0,"")&"',"&"'0');"& chr(13)& chr(10);

output:= output & "Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('"&Prefix&"',"&"'"&mid(country,1,15)&"',"&"'"&routes[ub]&"',"&"'"&totext(x-1,0,"")&"',"&"'4');"&chr(13)& chr(10);

If you want I can attach report and datasource (in Excel).

Thanks in advance for your help.
NickHowardAsked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
I missed why you had the line outside the loop

mlmcc
testRev2.rpt
0
 
JayConverseCommented:
You need to have less data.  Or, break it up into multiple stringvars and multiple outputs.
0
 
NickHowardAuthor Commented:
Data can not be less and may increase.

Can you show how to breakup into multiple outputs?

Thanks.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
JayConverseCommented:
How are you writing or executing the "output" variable?
0
 
NickHowardAuthor Commented:
In Detail section I put my above formula.

If u want I can attach CR report and excel backend data.
0
 
JayConverseCommented:
Just the report.
0
 
NickHowardAuthor Commented:
Report attached
test.rpt
0
 
JayConverseCommented:
I think your basic problem is "when all you have is a hammer, everything looks like a nail".  Crystal may not be the tool for this.  

So, what exactly are you trying to do with this output?  

0
 
tickettCommented:
I wonder if you could make the output variable a string array? Then instead of setting storing the concatenated result in a variable store each iteration in it's own element of the array. Then at the end return the whole array?

L
0
 
NickHowardAuthor Commented:
Well said. Actually I am using CR report to create sql insert.

May bit strange for you, but it was doing the great job unless data was less.

Hope you can look at formula and can suggest multiple outputs.

Thanks.
0
 
tickettCommented:
Yes- you can simply have a SQL statement:

SELECT 'INSERT INTO mytable (field1, field2) VALUES (''' + fielda + ''', ''' + fieldb + ''')' FROM someothertable

You could even do the insert all in one if all you're intending to do is copy/paste the INSERT statements?

L
0
 
NickHowardAuthor Commented:
tickett,

Sorry for not being understood.

Looks like no solution to avoid  65534 long characters for my existing requirement.

Shall I close the question?
0
 
JayConverseCommented:
But how are you getting from the Crystal report to the SQL statement?  Exporting to a text file?
0
 
NickHowardAuthor Commented:
Yeah into CSV file and running from SQL DTS.
0
 
tickettCommented:
Wow- that seems seriously long winded. I think i may have already answered "this question" about how to get around the error.

I think you need to post a new question with regard to the task you are trying to achieve with this current crystal/dts solution? Some of us experts can probably suggest smarter ways to attack it.

L
0
 
mlmccCommented:
YOu can use an array of strings but the handling would be difficult.

Basic idea
NumberVar StringIndex := 1;
StringVar Array MyStrings[1];

for x:=1 to ub-1 do
If Length(MyStrings[StringIndex]) >= 65000 then
(
    StringIndex := StringIndex + 1;
    ReDim Preserve MyStrings[StringIndex];
)
MyStrings[StringIndex] := MyStrings[StringIndex] & "Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('"&Prefix&"',"&"'"&mid(country,1,15)&"',"&"'"&routes[x]&"',"&"'"&totext(x-1,0,"")&"',"&"'0');"& chr(13)& chr(10);

You would then need separate formulas to print/display each member of the MyStrings array

mlmcc
0
 
NickHowardAuthor Commented:
mlmcc,

Thanks for the tip. I tried to impment but I guess I am doing something wrong.

Can you check my report and suggest complete formula1, formula2 so that I adopt it?

Sorry for being so naive.
0
 
mlmccCommented:
If you can upload the report, I will be happy to try and fix it.

You could also just copy and paste the formulas.

mlmcc
0
 
NickHowardAuthor Commented:
Thanks mlmcc. Actually I am fan of yours. You did help me in past.

Formula my report is: "output"

stringvar prefix;
stringvar country;
stringvar route;
stringvar Type;
stringvar output;
prefix:={Sheet3_.Access};
country:={Sheet3_.Country} ;
route:= {Sheet3_.Routes};
type:="4";

numbervar x;
numbervar ub;
stringvar array Routes;
routes:=split(route,",");
ub:= ubound(routes);
for x:=1 to ub-1 do

output:= output & "Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('"&Prefix&"',"&"'"&mid(country,1,15)&"',"&"'"&routes[x]&"',"&"'"&totext(x-1,0,"")&"',"&"'0');"& chr(13)& chr(10);
output:= output & "Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('"&Prefix&"',"&"'"&mid(country,1,15)&"',"&"'"&routes[ub]&"',"&"'"&totext(x-1,0,"")&"',"&"'4');"&chr(13)& chr(10);


I am attaching report with data saved in it.

Let me know if data source (excel file also required).

Thanks.
test.rpt
0
 
mlmccCommented:
Check this revision

mlmcc
test1rev.rpt
0
 
NickHowardAuthor Commented:
Hi mlmcc,

I tried your revised report but it was only bringing last record from datasource and was repeating 3 times.

I think using sql statements as output is getting this difficult to solve.

You have helped me in past check:
http://www.experts-exchange.com/Database/Reporting_/Crystal_Reports/Q_25010605.html

I have same thing now but my data grew and therefore getting limitations.

I am attaching new report with data in excel to test it.

Hope it is easier know to look at output.

Thanks in advance.
Prefixes-Routing.xls
test.rpt
0
 
mlmccCommented:
Does this report do what you want?

mlmcc
testRev1.rpt
0
 
NickHowardAuthor Commented:
Checking and thanks.
0
 
NickHowardAuthor Commented:
mlmcc,

You almost solved it. Only change required is that for at end of each array, value of Type should be '4' instead of '0'

For instance, select prefix 0032:

Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','14','0','0');
Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','19','1','0');
Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','2','2','0');
Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','15','3','0');
Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','4','4','0');
Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','13','5','0');
Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','6','6','0');
Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','17','7','0');
Insert into dbo.s_route_vs_tmp (prefix, country, route, Priority, Type) VALUES('0032','Belgium','22','8','4');

You can see that for each prefix last entry ends with type '4'.
I tried to achieve it by modifying output formula but no luck.
Thanks and already grateful for your assistance.


0
 
NickHowardAuthor Commented:
mlmcc ROCKS !!!

This solved the issue.

I wish I can raise points from 500 to 1000.

Bundle of thanks for this help,
0
 
NickHowardAuthor Commented:
No match with mlmcc. When no one there to help, mlmcc steps in and solve most difficulet tasks. God Bless.
0
 
mlmccCommented:
Thanks for the kind words.  

mlmcc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.