>Hi,
>
>I was trying to create cursor for my report using this code:
>
> FOR lni=1 to lnTableCount
> lcCommand=lcCommand+;
> "SELECT '"+laTables[lni]+"' AS TABLE,"+;
> "GROUP,FIELD_NAME,HEADER,"+;
> "ALLTRIM(DEFINITION) AS DESCR,"+;
> "FIELD_TYPE,FIELD_LEN,FIELD_DEC,FIELD_NULL,"+ ;
> laTables[lni] +" AS FIELD_ORDER FROM DATADICT WHERE "+laTables[lni]+">0 "+;
> "INTO CURSOR cur"+alltrim(str(lni))
>
> if lni=lnTableCount
> lcCommand=lcCommand+" ORDER BY 1,10"
> endif
>
> &lcCommand
>
> lcCommand="SELECT * FROM cur" +alltrim(str(lni))+" UNION "
>
> ENDFOR
>
>******************************
> Here lcTableCount=11.
> Unfortunately, on 3rd lni I have an error message "string is too long to fit". How can I resolve this?
>
Break up the statement into a series of separate selects, and rather than doing a UNION, since they all have to have the same structure for a UNION to work, simply append them together into a single cursor after the fact. This is probably the easiest mechanism to implement, and is least affected by changes in the future.
You may also be able to increase the complexity of a SQL Select statement's WHERE expression if that's the cause of your problem with SYS(3055); if the error that you're receiving is error 1308 (insufficient stack space) or 1812 (SQL statement too long) you can increase the complexity support for FOR and WHERE clauses. SYS(3055) accepts a numeric value as a second argumnet, the default is 320, and it can be set between 320 and 2040. the recommendation in the help file regarding this suggests a value 8 * number of fields involved in the target or source tables.