Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I avoid 'SQL: Statement too long (Error 1812)'
Message
From
13/11/2003 12:57:58
 
 
To
12/11/2003 14:40:39
Mike Sue-Ping
Cambridge, Ontario, Canada
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00849187
Message ID:
00849594
Views:
24
Hi Mike,

-----
My string is only 1844 characters and I get the error. Any ideas as to why?


VFP SQL SELECT command have another limit, complexity on the stack of the parser.

This is controlled by
SYS(3055 , nComplexity) && READ HELP
A simple example :
SET TALK OFF
CLEAR 

CREATE CURSOR C1 (Id I DEFAULT RAND()*1000)
FOR K=1 TO 1000
 APPEND BLANK 
NEXT

n=1020   && change this on range 160..1020

* 1 IN() item use 1 stack position
* OR id IN  use 2 stack positions

maxItem =  m.n-14 - 2*INT((m.n-157)/26)

? maxItem
sSelect = ''
FOR k=1 TO m.maxItem 
  sSelect = m.sSelect + " OR ID IN (" + LTRIM(STR(m.k))
  FOR k=m.k+1 TO MIN(m.k+22,m.maxItem -1)
    sSelect = m.sSelect + "," + LTRIM(STR(m.k))
  ENDFOR
  sSelect = m.sSelect + IIF(m.k>m.maxItem,"","," + LTRIM(STR(m.k)))+")"
NEXT
sSelect = STUFF(m.sSelect,1,3,"SELECT id from C1 WHERE")

SYS(3055 , m.n*2)	&& 2x is a VFP error on first implementation choice 160..1020 range x 2

? m.sSelect
&sSelect
Then, try SYS(3055,2040) on your query.

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform