Subject: | Re: Local SQL
| Date: | Sat, 30 May 2020 00:53:31 +1000
| From: | Bernie van't Hof <onrequest@somewhere>
| Newsgroups: | pnews.paradox-programming
|
Good question. What use is SELECT NULL?
e.g. MySQL:
SELECT null as myField; => field type NULL (!?)
SELECT '' as myField; => field type VARCHAR
SELECT '3.14' as myField; => field type VARCHAR
SELECT 3.14 as myField; => field type DECIMAL
SELECT date('2009-12-12') as myField; => field type DATE
The column type is inferred from the literal.
Unlike paradox, SQL has no concept of "BLANK".
In SQL NULL means undefined, but that is not the same thing as say an
empty string.
mySQL > create table `Fredd` AS select null as fred;
Query OK, 1 row affected (0.0080 sec)
Records: 1 Duplicates: 0 Warnings: 0
mySQL > select * from fredd;
+------+
| fred |
+------+
| NULL |
+------+
1 row in set (0.0005 sec)
mySQL > show columns from fredd;
+-------+-----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+-----+---------+-------+
| fred | binary(0) | YES | | NULL | |
+-------+-----------+------+-----+---------+-------+
1 row in set (0.0015 sec)
mySQL > insert into fredd set fred='abc';
ERROR: 1406 (22001): Data too long for column 'fred' at row 1
MySQL > insert into fredd set fred='';
Query OK, 1 row affected (0.0025 sec)
MySQL > select * from fredd;
+------+
| fred |
+------+
| NULL |
| |
+------+
2 rows in set (0.0005 sec)
No idea where this might be useful. There are others here much more
skilled in this. Maybe they will chime in.
- Bernie
On 29/5/20 8:44 pm, Kevin Baker wrote:
> Been playing around with this over the last few days. And getting
> stumped on how to convert a calc blank as MyField. When I use the QBE,
> then use ShowSQL, it converts to NULL as MyField, but I don't think I
> have a say in what kind of field myField is (field type)
|