Paradox如何管理空值和空值? [英] How does Paradox manage null and empty values?

查看:155
本文介绍了Paradox如何管理空值和空值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过Borland数据库引擎(BDE)使用Paradox表.

I'm using Paradox tables through Borland Database Engine (BDE).

我无法实现在字符串字段(Paradox数据类型"A")中处理 null 空字符串值的方式.

I'm not able to realise the way null and empty string values are handled in string fields (Paradox data type "A").

我的特定问题是如何确定字段值是null还是空字符串.在数据库桌面工具中,它们似乎都是空字符串.

My specific problem is how to determine if a field value is null or empty string. In Database Desktop tool they all seem to be empty strings.

我需要这样做是因为我正在将数据(使用数据库桌面以及编程方式)迁移到Firebird DB,并且似乎是空字符串的字段值都作为空值复制到了Firebird . ..即使是属于索引的字段! 如何区分真正的null和空字符串?它取决于Paradox还是BDE?谢谢!

I need this because I'm migrating data (with Database Desktop and also programmatically) to a Firebird DB and the field values which seem to be empty strings are all copied to Firebird as null values... Even fields belonging to an index! How can I distinguish real null from empty strings? Does it depends from Paradox or BDE? Thanks!

推荐答案

空白为NULL被认为有害

如您所知,现代数据库实现包含"NULL"的概念,这是一个永远不匹配任何其他值(甚至是另一个NULL)的值.

BLANK as NULL Considered Harmful

As you know, modern database implementations include the concept of "NULL", which is a value that never matches any other value, even another NULL.

BDE及其祖先Paradox引擎和Paradox for DOS,不包括NULL 的概念. BDE表中的数据类型均不允许使用NULL之类的排除值.

The BDE, and its ancestors the Paradox engine and Paradox for DOS, do not include the concept of NULL. None of the datatypes in a BDE table allow an exclusionary value like NULL.

BDE 确实包含BLANK的概念,但这只是某些类型的特殊带内值. BLANK与BLANK匹配,仅此而已.在数字字段中,BLANK与0可以区分,但是在字母字段中,BLANK与零长度字符串相同.

The BDE does include the concept of BLANK, but this is just a special in-band value for some types. BLANK matches BLANK and nothing else. In a numeric field, BLANK is distinguishable from 0, but in an alpha field, BLANK is identical to a zero-length string.

很显然,在过去的某个时候,有人被要求创建一个实用程序,以将其从BDE表导入SQL数据库中,但他对此并不完全满意.他可能无法相信没有NULL的数据库,因此他猜测BLANK与NULL相同.从那以后,其他所有人都追随他的领导.

Apparently some time in the dim past, someone was tasked with creating a utility to import from BDE tables into a SQL database, and he wasn't quite up to it. He probably couldn't concieve of a database without NULLs, so he guessed that BLANK was the same as NULL. Since then everyone else has just followed his lead.

将BDE空白转换为SQL NULL是错误的.这样做会更改数据库的体系结构,并破坏任何关联应用程序的体系结构.从BDE表导入的数据绝不能包含NULL.

Translating BDE BLANKs to SQL NULLs is wrong. Doing so changes the architecture of the database, and breaks the architecture of any associated applications. Data that has been imported from a BDE table should never contain NULLs.

要么编写自己的导入过程,要么使用内置的导入,然后仔细地对导入的数据进行后处理,以将所有NULL转换为其他值.

Either write your own import procedure, or use the built-in import and then carefully post-process the imported data to convert all NULLs to other values.

空白的alpha值必须转换为零长度的CHAR或VARCHAR值.

BLANK alpha values must be translated to zero-length CHAR or VARCHAR values.

空白数值必须转换为与自身匹配的选定带内标志值.除非可以使用NaN或某些类似的方法,否则您可能必须保留代表BDE空白的特殊值.在许多情况下,根据应用程序体系结构,您将能够将BDE BLANK转换为SQL 0.

BLANK numeric values must be translated to a selected in-band flag value that matches itself. You may have to reserve a special value to represent the BDE BLANK, unless NaN or some such can be made to work. In many cases, depending on the application architecture, you will be able to translate BDE BLANK to SQL 0.

当然,如果您的SQL实现允许一个与自己匹配的BLANK数值,并且该数值可与NULL区分,那么您的问题就会减少,因为您的数据库至少与BDE一样强大.不过,您可能仍然无法使用内置的导入实用程序.

Of course if your SQL implementation allows a BLANK numeric value that matches itself and is distinguishable from NULL, then your problems are reduced because your database is at least as capable as the BDE. You probably still can't use the built-in import utility, though.

这篇关于Paradox如何管理空值和空值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆