473,721 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to solve Complex Query Error !

Query is too complex
--------------------------------------------------------------------------------

Hi, I was trying to solve this problem since last two days but couldn't
find any solution.

I wanted to execute a query which is retrieving the records from table1
by
checking the condition for a long long string .
I'm using where clause and checking the condition as-

where (citycode=B and order_no=18900) or (citycode=B and
Order_no=18901) .
.......so on upto (citycode=B and order_no=18950)
I'm assigning the string as follows

For i = 18900 To 18950
If i = 18900 Then
ord_string = Trim(ord_string ) & "(ctCodOrd = 'B' and ord_no = " & i &
")"
Else
ord_string = Trim(ord_string ) & " or (ctCodOrd = 'B' and ord_no = " & i
& ")"
End If
Next i

the query string is as follows-

sqlstr = "select * from track_det2 where " + Trim(ord_string )
Set dy = db.OpenRecordse t(sqlstr, dbOpenDynaset)

After executing it is giving the error message " Query is too complex
!" .

I've also tried to solve it by giving the -

db.QueryTimeout = 100 (more than 60)
To give the database enough time to execute this query but it's not
worked.

Plz solve my problem.

amritesh

Oct 12 '06 #1
1 2667
"arun" <ar***********@ gmail.comwrote in message
<11************ **********@c28g 2000cwb.googleg roups.com>:
Query is too complex
--------------------------------------------------------------------------------

Hi, I was trying to solve this problem since last two days but
couldn't find any solution.

I wanted to execute a query which is retrieving the records from
table1 by
checking the condition for a long long string .
I'm using where clause and checking the condition as-

where (citycode=B and order_no=18900) or (citycode=B and
Order_no=18901) .
......so on upto (citycode=B and order_no=18950)
I'm assigning the string as follows

For i = 18900 To 18950
If i = 18900 Then
ord_string = Trim(ord_string ) & "(ctCodOrd = 'B' and ord_no = " & i &
")"
Else
ord_string = Trim(ord_string ) & " or (ctCodOrd = 'B' and ord_no = " &
i & ")"
End If
Next i

the query string is as follows-

sqlstr = "select * from track_det2 where " + Trim(ord_string )
Set dy = db.OpenRecordse t(sqlstr, dbOpenDynaset)

After executing it is giving the error message " Query is too complex
!" .

I've also tried to solve it by giving the -

db.QueryTimeout = 100 (more than 60)
To give the database enough time to execute this query but it's not
worked.

Plz solve my problem.

amritesh
This seems a tad hardcoded, and gives a rather long SQL statement.

Another hardcoded version, could be

ord_string = "ctCodOrd = 'B' and ord_no Between 18900 and 18950"
sqlstr = "select * from track_det2 where " & ord_string

Or if a bit of dynamic is needed

For i = 18900 To 18950
' if some condition?
ord_string = ord_string & "," & cstr(i)
' end if
Next i
If Len(ord_string) Then
ord_string = "ctCodOrd = 'B' AND ord_no IN(" & _
mid$(ord_string , 2) & ")"
Else
ord_string = "ctCodOrd = 'B'"
End If

--
Roy-Vidar
Oct 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

39
7879
by: | last post by:
I am trying to run the following agregate function in a parameterized query on Access2000: Min(.*sqr(./.)/) The query saved OK, but an attempt to run it results in the message: The expression is typed incorrectly or it is too complex to be evaluated If the sintax correct? Perhaps it is, otherwise it would not save. What can be done about it?
4
8971
by: Starbuck | last post by:
OK, first let me say that I am no DB person. But I have a user here who keeps getting this error whenever she does, whatever it is she does, with databases... A google search takes me to various forums where I am forced to sign up before I can read any answers. Interesting note here is that the guy in the office next
2
6074
by: Mikel | last post by:
I am trying to get around the problem "The expression you have entered is too complex" for a select query. (The example below is not the expression that is giving me headaches.) So I am thinking that I just need to do the parsing and calculating in an event procedure for an "On Click" event. My question is: If I have a query field in access97 that parses date (in format
4
2020
by: ED | last post by:
I am attempting to to write a query that has a numerous nested IIf statements. The problem that I am having is that it is to long of a query to be built in design mode and when I build it in sql mode after a certain point it give me the error message that the expression is to complex. Below is the sql code that I am using (this works so far, anything added to the code will give me the to complex error message.) SELECT .WONUM, .,...
8
5066
by: Matt | last post by:
Hi all, Thank you for taking the time. I have a database with 45 tables on it. 44 tables are linked to a main table through a one to one relationship. My question is, is there no way i can have a query that will pull a single field from all the tables. In other words i should have 44 fields. when i try to do that same, i get an error message saying "Query is too complex"
102
5694
by: Skybuck Flying | last post by:
Sometime ago on the comp.lang.c, I saw a teacher's post asking why C compilers produce so many error messages as soon as a closing bracket is missing. The response was simply because the compiler can't tell where a bracket is missing.... a few weeks have past, I requested a feature for the delphi ide/editor "automatic identation of code in begin/end statements etc" and today when I woke up I suddenly released a very simple solution for this...
19
3634
by: kawaks40 | last post by:
Hi everyone :) I just recently started using access/sql. and right away I ran into this problem "SQL expression too complex" I google'd a lot on what it means, and the only workaround I've seen sofar, is to just rewrite my code/query. Situation: I am sorting forms into the way they are used (print,storage,readonly,etc...).
13
2307
by: DDonnachie | last post by:
Hi folks, The following SQL statment works SELECT StaffHoursTable.EngName, StaffHoursTable.JobNumberShadow, ++++++ AS Norm_Hours, ++++++ AS OT_Hours, wktodate(StaffHoursTable.WeekNo,StaffHoursTable.Year) AS WeekDate, Jobs.ProjectType, Jobs.ProjectDescription, wktodate(.,.) FROM (StaffHoursTable INNER JOIN Jobs ON StaffHoursTable.JobNumberShadow = Jobs.JobNumber) INNER JOIN EngStaff ON StaffHoursTable.EngName = EngStaff.Eng_Staff ...
1
15980
by: Rudolf Bargholz | last post by:
Hi, We have created triggers to log modifications to tables in our application. The triggers work fine, just on one of the tables in our database the triggers fail with the error message <SQL0437W Performance of this complex query may be sub-optimal. Reason code: "1". SQLSTATE=01602>. The same trigger on other tables works fine (the triggers are autogenerated with the same structure for most of the tables used in our application). I...
0
8838
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8728
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9130
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9059
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8005
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6668
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3188
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.