Which one represents zero? undef or empty string

I want to insert null in a table column.

Which one represents zero? undef or empty string. ''

Which one should be used and why? I know about defined and can check it out.

But I look more from a database perspective.

Which one is more null ?

Update: I am using the DBI module.

+6
source share
3 answers

DBI uses undef to represent SQL NULL . An empty string is an empty string.

However, some databases do not distinguish between NULL and an empty string. Oracle is a special criminal. DBI can't do anything about it.

+9
source

Assuming Perl is a DBI, undef represents SQL NULL .

An empty string in Perl represents exactly the same (i.e. an empty string) in SQL.

+8
source

Assuming you are using a DBI module and using related arguments (because if you built SQL manually, you would use NULL in the string):

Values

Undefined or undef are used to specify NULL values.

See perldoc for DBI

If you are not using DBI directly (for example, using DBIx :: Class or some other ORM), you will probably find that it inherits DBI behavior for this.

+4
source

Source: https://habr.com/ru/post/926842/


All Articles