473,854 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VALUES statement

Hi!

With VALUES you can do something like:
SELECT * FROM (VALUES ('A', 1), ('B', 2), ('C', 2)) AS TEMP(LETTER, NUMBER)
which will give you:
LETTER NUMBER
------ ------
A 1
B 2
C 2

It there some way with VALUES that would give me:
LETTER NUMBER
------ ------

So no results, empty result set?
So SELECT COUNT(*) FROM VALUES..... returns 0.

Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Mar 9 '07
13 38567
Serge Rielau wrote:
Gregor Kovač wrote:
>Serge Rielau wrote:
>>SELECT * FROM (VALUES (NULL, NULL), -- Fixed
(1, 'a'), (2, 'b'), ... -- generated
) AS X(c1, c2) WHERE NOT (c1 IS NULL AND c2 IS NULL)

Hi!

This wouldn't work since the part (1, 'a'), (2, 'b'), ... will not be
generated (the GUI table is empty, remember ?)
and SELECT * FROM (VALUES
(NULL, NULL)) AS X(c1, c2) WHERE NOT (c1 IS NULL AND c2 IS NULL) yields
[Error Code: -584, SQL State: 42608] Invalid use of NULL or DEFAULT.
All to need is to cast the NULLs.
(CAST(NULL AS INT), CAST(NULL AS VARCHAR(10)), ...
Yep, I'm doing just that. Thanks. :))))
>I like the EXCEPT ALL more. :))))
Anything that works...

Cheers
Serge

--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Mar 9 '07 #11
Lennart wrote:
On Mar 9, 3:36 pm, Gregor Kovač <gregor.ko...@m ikropis.siwrote :
[...]
>Because the query itself is written by the user. And if the user does:
SELECT * FROM {GET_TABLE(GUI_ TABLE)} WHERE LETTER = 'A'
then the application would generate
SELECT * FROM (VALUES ('A', 1), ('B', 2), ('C', 2)) AS TEMP(LETTER,
NUMBER) WHERE 1=0 WHERE LETTER = 'A'
which is an invalid SQL. Do you agree?

Absolutely. How about (I'm using python):

if (s.find('WHERE' ) 0):
s = s + ' AND '
That's not reliably. First, WHERE can be a column/table name or be in a
nested subquery. Next, AND binds stronger that OR. So adding "AND 1= 0"
to a where clause like this doesn't have the desired effect:

SELECT ... FROM ... WHERE a = 1 OR b = 2
--
Knut Stolze
DB2 z/OS Admin Enablement
IBM Germany
Mar 12 '07 #12
Knut Stolze wrote:
[...]
That's not reliably. First, WHERE can be a column/table name or be in a
nested subquery. Next, AND binds stronger that OR. So adding "AND 1= 0"
to a where clause like this doesn't have the desired effect:

SELECT ... FROM ... WHERE a = 1 OR b = 2
Yes, you are right but since the users are entitled to write there own
queries there are much worse problems to worry about. Let's say someone
writes a query like:

select * from old table (
delete from the_very_import ant_table
) X where ...

/Lennart
Mar 12 '07 #13
Lennart wrote:
Knut Stolze wrote:
[...]
>That's not reliably. First, WHERE can be a column/table name or be in a
nested subquery. Next, AND binds stronger that OR. So adding "AND 1= 0"
to a where clause like this doesn't have the desired effect:

SELECT ... FROM ... WHERE a = 1 OR b = 2

Yes, you are right but since the users are entitled to write there own
queries there are much worse problems to worry about. Let's say someone
writes a query like:

select * from old table (
delete from the_very_import ant_table
) X where ...
Sure. Not to mention GROUP BY, HAVING, ORDER BY etc.

--
Knut Stolze
DB2 z/OS Admin Enablement
IBM Germany
Mar 12 '07 #14

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

Similar topics

3
17131
by: Matt | last post by:
When the ASP statement end with a _ character, then the next line cannot have comment ' character. Is that correct? Since I encountered the following error: Microsoft VBScript compilation (0x800A0400) Expected statement sqlStmt = "insert into TimeSlot (WeekDay, BeginTime, EndTime) VALUES (" _ ' & 2 & "," _ & beginhour & "," _
1
7139
by: mirth | last post by:
I would like to update a decimal column in a temporary table based on a set of Glcodes from another table. I search for a set of codes and then want to sum the value for each row matching the Glcodes. The problem is I keep getting multiple rows returned errors. "Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been...
22
1774
by: Alan | last post by:
I have many OR in the if statement, any method to simplify? if (val == 5 | val == 9 | val == 34 | val == 111 | val == 131 | .......) // .... thank you
7
11451
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And #11/2/2003# And VehicleID='00000000' And BattID='LKO500HF'. I need to use the records returned to populate text boxes, but the data requires further manipulation. I attempting to use expressions in the control source
9
3345
by: khan | last post by:
on sale report I want to make a check if customer doesnot pay full amount then his dues go in to his account recieveable table. I am trying this in vba and when I complie it on RunSQL it gives me error "wrong number of argments", Can any one help plzzz If Val(Me.Due) > 0 Then DoCmd.RunSQL "Insert into (customerID,reciept#,amountDue) values(" & _ , , & ")"
15
2819
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
2
2300
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared those values as date datatypes and assigned their values with the # signs in front and back. When I click the submit I get the following error message: Data type mismatch in criteria expression cmdSelect1 = New OleDbCommand("Select Count(*) from ...
41
2797
by: Gary Wessle | last post by:
Hi often I need to read numbers and only keep the highest or lowest. so I do something like int uLimit = 0; int lLimit = 999999999999; //hoping the compiler will not complain uLimit = val_read uLimit ? val_read : uLimit; lLimit = val_read < lLimit ? val_read : lLimit;
3
7705
by: Joshepmichel | last post by:
Please to help me to following problem I want to do this 1. create Table Name MEMBER on the Database Name "mytestdb", 2. Add the Values to the Table through the Key board Inputs during running the My Java Application.; Therefore I used this following codes, It Consists the seperate parts for the Raede and Member Class for the purposely I craetes. 3. I have problem to Parsing the values to SQL statement, that Consists on the Run Time...
0
9752
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
11031
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10685
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...
0
10371
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
9518
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 projectplanning, coding, testing, and deploymentwithout 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
7918
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...
0
5750
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4162
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3188
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.