You should NOT be relying on column names UNLESS you set them yourself.
-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:[email protected]] Im
Auftrag von petern
Gesendet: Samstag, 08. Juli 2017 21:37
An: SQLite mailing list <[email protected]>
Betreff: [sqlite] VALUES clause quirk or bug?
Why does the choice of data value quotation mark influence the output column
name of the inline VALUES clause? [This quirk was the origin of a recent bug in
a current project.]
sqlite> .version
SQLite 3.19.3 2017-06-08 14:26:16
0ee482a1e0eae22e08edc8978c9733a96603d4509645f348ebf55b579e89636b
sqlite> .header on
sqlite> .mode csv
sqlite> SELECT * FROM (VALUES (1,2),(3,4));
"",:1
1,2
3,4
sqlite> SELECT * FROM (VALUES ("1",2),(3,4));
1,""
1,2
3,4
sqlite> SELECT * FROM (VALUES ('1',2),(3,4));
"",:1
1,2
3,4
I am aware that a less quirky "column<i>" output column naming is available if
the VALUES clause is evaluated directly. See below. However, this form is not
applicable for task at hand, specifying inline constant tables within a query.
sqlite> VALUES ("1",2),(3,4);
column1,column2
1,2
3,4
Yes, I also thought carefully about the WITH clause. See below. While the
WITH clause is natural for brief queries in a few columns, the wordiness an
unnatural order is not helpful for local constant representation in the very
lengthy queries needed for by this particular project.
sqlite> WITH Constants(c1,c2) AS (VALUES ("1",2),(3,4)) SELECT * FROM
Constants;
c1,c2
1,2
3,4
Is there anything I missed? Are there other undocumented tricks of the VALUE
clause that could help or hinder my quest?
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
___________________________________________
Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: [email protected]
This communication (including any attachments) is intended for the use of the
intended recipient(s) only and may contain information that is confidential,
privileged or legally protected. Any unauthorized use or dissemination of this
communication is strictly prohibited. If you have received this communication
in error, please immediately notify the sender by return e-mail message and
delete all copies of the original communication. Thank you for your cooperation.
_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users