🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.vdbase.data.sql
2 messages
2 total messages Started by Kris Thu, 11 Mar 1999 00:00
2 Sql Problems
#183
Author: Kris
Date: Thu, 11 Mar 1999 00:00
19 lines
1437 bytes
The first sql problem is when I create a tempory table  and link it up with
2 other tables.  When I execute the query and look for infomation in my
report there is none.  It seems that It can't find any data, yet I have
checked and double checked the conditions just to make sure that they are
right which they are.  Any help with this problem would be appreciated.

The next problem that I have is in one of my conditions.  I select
everything from a certain table which has the following conditions:

batch >= " ' + Start + ' " and batch <= " ' + end + ' " '

there is also a few more conditions but they work right.  So when I run my
query without the above condition, I get all of my data, but when I use the
condition above, I get no data showing up.  As for the values that I use for
it, I use the lowest number for the start and the highest number available.
So I should get data, but I don't.  Any help with this problem would be of
some great use too.  Thanks in advance.

Scott
Re: 2 Sql Problems
#184
Author: Steve Koterski
Date: Thu, 11 Mar 1999 00:00
77 lines
4280 bytes
On Thu, 11 Mar 1999 10:51:00 -0500, "Kris" <free_style @ yahoo.com> wrote:

>The first sql problem is when I create a tempory table  and link it up with
>2 other tables.  When I execute the query and look for infomation in my
>report there is none.  It seems that It can't find any data, yet I have
>checked and double checked the conditions just to make sure that they are
>right which they are.  Any help with this problem would be appreciated.

There is nothing in your post that would either indicate the source of the
problem. There are just too many possibilities and you have provided too
little information.

I would suggest you simplify the situation until you find the source of the
problem. Try the SQL statement alone, outside any report or application.
You need to find out whether the SQL statement is producing any data or the
report is not designed correctly and is just not displaying valid data
produced by the query.

Posting the actual SQL statement here in the newsgroup might help. Perhaps
there is some obvious faux pas in the statement that would suggest an easy,
simple fix.

>The next problem that I have is in one of my conditions.  I select
>everything from a certain table which has the following conditions:
>
>batch >= " ' + Start + ' " and batch <= " ' + end + ' " '
>
>there is also a few more conditions but they work right.  So when I run my
>query without the above condition, I get all of my data, but when I use the
>condition above, I get no data showing up.  As for the values that I use for
>it, I use the lowest number for the start and the highest number available.
>So I should get data, but I don't.  Any help with this problem would be of
>some great use too.  Thanks in advance.

Back up a step from what you have now. Instead of using memory variables in
building the SQL statement, try putting the values in the statement
explicitly. Does the SQL statement work under those conditions?

Regarding just the construction of a string value, what does your command
line produce? For example, your Start and End variable appear to be string
values (you are embedding quotation marks around them) and the values in
them might not be trimmed (i.e., contain trailing spaces). Viewing the
string produced by your command line just to see what it contains would
make a problem like this very apparent. There is a difference between the
two string values below when used as a condition in an SQL statement.

  batch >= "AAA   " and batch <= "ZZZ   "
  batch >= "AAA" and batch <= "ZZZ"

Also, if you look at your example statement, it appears that it is actually
embedding extra spaces before and after both the Start and End variable
values. Your statement is currently:

  'batch >= " ' + Start + ' " and batch <= " ' + end + ' " '

I believe it should be:

  'batch >= "' + Start + '" and batch <= "' + end + '"'

Is the problem resolved by use of the BETWEEN predicate to establish a
range of values for comparison with the field Batch?

  'Batch BETWEEN "' + Start + '" AND "' + End + '"'

Since you are using multiple conditions in the WHERE clause of this
statement, does enclosing mutually exclusive and dependent conditions in
parenthesis make any difference in its results?

  WHERE (Condition 1) OR
    (Condition 2) OR
    ((Condition 3) AND (Condition 4))

//////////////////////////////////////////////////////////////////////////
Steve Koterski                    "My problem lies in reconciling my gross
Technical Publications            habits with my net income."
INPRISE Corporation                             -- Errol Flynn (1909-1959)
http://www.borland.com/delphi
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads