Desktop version

Main > Forum > 1C:Enterprise Platform > Studying 1C:Enterprise platform > NULL vs Undefined

Forum

Search UsersRules
NULL vs Undefined
#1
Just came
Points:: 0
Joined:: Nov 1, 2011

What is the difference between type Undefined and Null?

Profile
#2
Just came
Points:: 1
Joined:: Nov 1, 2011

Null for Requst
Undefined  -for any other

Profile
#3
Just came
Points:: 1
Joined:: Nov 1, 2011

There is a huge difference between them! "Null" is a common type or value that represents the_absence_ of something.While the "undefined" is a value for representing of _existence_ of something but yet not defined, without a certain value.

Profile
#4
Just came
Points:: 1
Joined:: Nov 1, 2011

While the "undefined" is a value for representing of _existence_ of something but yet not defined, without a certain value.

Profile
#5
Just came
Points:: 0
Joined:: Nov 1, 2011

When i have to use Null and when Undefined?

Profile
#6
Just came
Points:: 1
Joined:: Nov 1, 2011

to #5
It's common to happen NULL-values in queries with LEFT JOIN, when the system couldn't find the appropriate records in the right table.
And the value 'Undefined' is usually used in scripts (modules). For example, if you call a function and skip some parameters but use commas then the skipped parameters will be equal 'Undefined' inside the function. Look here:
>> f(1,,3)
>> the second parameter is 'undefined'.

And another sample to consider. Compare the results of "WHERE field = NULL" with "WHERE field = Undefined" when the field contents the NULL and Undefined. In other words, Undefined is equal Undefined because they are the same, but one NULL is not equal another NULL because.. hmm... because they are unknown, absent. But it's true only in queries. In scripts they are equal each other. It's a kind of magic :)

Profile
#7
Just came
Points:: 0
Joined:: Nov 1, 2011

to (6)
so, i don't have to use NULL, but queries return it to me when "with LEFT JOIN, when the system couldn't find the appropriate records in the right table.", why it doesn't return undefined instead of NULL?

Profile
#8
Just came
Points:: 0
Joined:: Nov 1, 2011

#7 undefined != NULL
undefined like a pointer to nowhere
NULL like a normally NULL

Profile
#9
Just came
Points:: 1
Joined:: Nov 1, 2011

#6 Could You comment this:
http://screencast.com/t/T173ci6WvIxG

Doesn't it seem to be contradicting to your words, that "one NULL is not equal another NULL", ha?

Profile
#10
Just came
Points:: 1
Joined:: Nov 1, 2011

to (7) Because NULL is common for this situation (similar to SQL)
And in some cases the system returns the Undefined to you even in queries, e.g. for empty fields of complex types.

Profile
#11
Just came
Points:: 0
Joined:: Nov 1, 2011

#8
nothig != nothig
When i have to use nothing and when i have to use notjing?

Profile
#12
Just came
Points:: 0
Joined:: Nov 1, 2011

#10
U whant to say me, that NULL is not common for 1C, but 1C need to use it?

Profile
#13
Just came
Points:: 1
Joined:: Nov 1, 2011

to #12
NULL is common for SQL and 1C has a query language similar to SQL so it's no wonder that it has NULL too

Profile
#14
Just came
Points:: 0
Joined:: Nov 1, 2011

#13
So, i need to use NULL, cause it comes from SQL and i have to use undefined, cause it comes from 1C, why i cant use NULL instead of udefined?

Profile
#15
Just came
Points:: 1
Joined:: Nov 1, 2011

#14. You may. I have no objection.

Profile
#16
Just came
Points:: 0
Joined:: Nov 1, 2011

#15
thx! I hope, i can do it!

Profile
#17
Just came
Points:: 0
Joined:: Nov 1, 2011

#9
01.11.2011 14:56:35
In english please... you screen with russian words... i don`t undestand )

Profile
#18
Just came
Points:: 0
Joined:: Nov 1, 2011

#17 this table translated as:
expression               |    value
NULL=NULL             |   true
NULL=Undefined       |   false
Undefined=Undefined |   true

:)

Profile
#19
Just came
Points:: 1
Joined:: Nov 1, 2011

#18
It is true only in scripts, not in queries. Please fix it or admit your defeat. :)

NULL=NULL | It's false forever!

Profile
#20
Just came
Points:: 0
Joined:: Nov 2, 2011

SQL: NULL = NULL | NULL
1C: NULL = NULL | True
Undefined = Undifened | True

Profile
#21
Just came
Points:: 1
Joined:: Nov 1, 2011

SQL:
  NULL = NULL  | unknown
1С query:
  NULL = NULL  | false
  Undefined = Undifened | True
1С script:
  NULL = NULL  | true
  Undefined = Undifened | True

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.