dbTalk Databases Forums  

how to return a null value in OME?

comp.databases.ingres comp.databases.ingres


Discuss how to return a null value in OME? in the comp.databases.ingres forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
zhenchen17
 
Posts: n/a

Default how to return a null value in OME? - 03-11-2009 , 02:50 AM






Hi everyone,
I wonder how to return a null value in OME. The struture
II_DATA_VALUE used in OME is without a member variable to indicate it
is representing a null value. So how can i do if i want to return a
null in OME?
Thanks.
Chenzhen

Reply With Quote
  #2  
Old   
Martin Bowes
 
Posts: n/a

Default Re: [Info-Ingres] how to return a null value in OME? - 03-11-2009 , 03:20 AM






Hi Chenzhen,

To my knowledge the answer is that you can't return a null from OME.

OME has a few limitations and that's one of them.

Out of curiosity, what are you trying to achieve?

Martin Bowes

-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of
zhenchen17
Sent: 11 March 2009 08:50
To: info-ingres (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] how to return a null value in OME?

Hi everyone,
I wonder how to return a null value in OME. The struture
II_DATA_VALUE used in OME is without a member variable to indicate it
is representing a null value. So how can i do if i want to return a
null in OME?
Thanks.
Chenzhen
_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://www.kettleriverconsulting.com...fo/info-ingres


Reply With Quote
  #3  
Old   
Martin Bowes
 
Posts: n/a

Default Re: [Info-Ingres] how to return a null value in OME? - 03-11-2009 , 04:20 AM



Hi Ian,

Yes OME (and all normal) functions won't take nulls as input parameters,
but what about returning a null value?

Although, other that an aggregate function I couldn't honestly think of
a reason to return a null.

I'm interested in what Chenzen is trying to achieve.

Marty

-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of Ian
Kirkham
Sent: 11 March 2009 10:06
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] how to return a null value in OME?

If you are worried about being passed a NULL parameter then don't as you
won't. The DBMS will short-circuit expressions in general that would
otherwise need to propagate NULLs.
Regards,
Ian
-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of
zhenchen17
Sent: 11 March 2009 08:50
To: info-ingres (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] how to return a null value in OME?

Hi everyone,
I wonder how to return a null value in OME. The struture
II_DATA_VALUE used in OME is without a member variable to indicate it
is representing a null value. So how can i do if i want to return a
null in OME?
Thanks.
Chenzhen
_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://www.kettleriverconsulting.com...fo/info-ingres

_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://www.kettleriverconsulting.com...fo/info-ingres


Reply With Quote
  #4  
Old   
zhenchen17
 
Posts: n/a

Default Re: how to return a null value in OME? - 03-11-2009 , 05:00 AM



Hi Marty and all,
The problem seems easy in OpenAPI because there is a member variable
to indicate.

What i am doing is to return null value. For example, our datatype
st_point either could be a 2-dimension point(x, y) or be a 3-dimension
point(x,y,z). The function get_z_value is trying to fetch the z value
from the point given. But for a 2d point, there is no z value anymore,
so returning any value(such as 0 or -1) will cause confusion because
it will be regarded as a reasonable value. Null is the proper value
to return.

And i find something in adfint.h:

#define ADF_SETNULL_MACRO(v) (*(((u_char *)(v)->db_data) + (v)-
Quote:
db_length - 1) = ADF_NVL_BIT)
/* This macro sets a nullable data value to the null value. It
assumes that
** the data value pointed to by `v' is of a legal nullable type.
*/

I believe this is the internal macro to mark a data value as null. I
have no idea whether it could be used in OME and i am trying to figure
that out.

Thanks
Chenzhen

On 3月11日, 下午6时20分, "Martin Bowes" <martin.bo.... (AT) ctsu (DOT) ox.ac.uk> wrote:
Quote:
Hi Ian,

Yes OME (and all normal) functions won't take nulls as input parameters,
but what about returning a null value?

Although, other that an aggregate function I couldn't honestly think of
a reason to return a null.

I'm interested in what Chenzen is trying to achieve.

Marty



-----Original Message-----
From: info-ingres-boun... (AT) kettleriverconsulting (DOT) com

[mailto:info-ingres-boun... (AT) kettleriverconsulting (DOT) com] On Behalf Of Ian
Kirkham
Sent: 11 March 2009 10:06
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] how to return a null value in OME?

If you are worried about being passed a NULL parameter then don't as you
won't. The DBMS will short-circuit expressions in general that would
otherwise need to propagate NULLs.
Regards,
Ian
-----Original Message-----
From: info-ingres-boun... (AT) kettleriverconsulting (DOT) com
[mailto:info-ingres-boun... (AT) kettleriverconsulting (DOT) com] On Behalf Of
zhenchen17
Sent: 11 March 2009 08:50
To: info-ing... (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] how to return a null value in OME?

Hi everyone,
I wonder how to return a null value in OME. The struture
II_DATA_VALUE used in OME is without a member variable to indicate it
is representing a null value. So how can i do if i want to return a
null in OME?
Thanks.
Chenzhen
_______________________________________________
Info-Ingres mailing list
Info-Ing... (AT) kettleriverconsulting (DOT) comhttp://www.kettleriverconsulting.com/mailman/listinfo/info-ingres

_______________________________________________
Info-Ingres mailing list
Info-Ing... (AT) kettleriverconsulting (DOT) comhttp://www.kettleriverconsulting.com/mailman/listinfo/info-ingres


Reply With Quote
  #5  
Old   
Karl & Betty Schendel
 
Posts: n/a

Default Re: [Info-Ingres] how to return a null value in OME? - 03-11-2009 , 06:31 AM



A few misconceptions here.

First, a null is indicated by the last byte of a nullable value
being nonzero. Nullable types have negative type codes.
So, for example, a nullable i4 would have db_datatype of
-II_INTEGER (using OME style names), a db_length of 5 instead
of the non-nullable 4, and the 5th byte of the value would be
zero for a non-null value and nonzero for NULL.

Second, you can indeed pass nullable parameters to OME functions.
but you need to define the function instance with the
II_FID_F256_NONULLSKIP flag. If you don't use that flag, the
query compiler assumes that the function should be treated like
an operator instead of an ordinary function, and any null
input skips the function call entirely giving a null result.
The NONULLSKIP flag tells it to just pass the parameters,
whatever they are, and let the function worry about it.

Third, simply define the FI with a negative result type, meaning
nullable, and you can return nulls.

Karl



On Mar 11, 2009, at 6:20 AM, Martin Bowes wrote:

Quote:
Hi Ian,

Yes OME (and all normal) functions won't take nulls as input
parameters,
but what about returning a null value?

Although, other that an aggregate function I couldn't honestly
think of
a reason to return a null.

I'm interested in what Chenzen is trying to achieve.

Marty

-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of
Ian
Kirkham
Sent: 11 March 2009 10:06
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] how to return a null value in OME?

If you are worried about being passed a NULL parameter then don't
as you
won't. The DBMS will short-circuit expressions in general that would
otherwise need to propagate NULLs.
Regards,
Ian
-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of
zhenchen17
Sent: 11 March 2009 08:50
To: info-ingres (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] how to return a null value in OME?

Hi everyone,
I wonder how to return a null value in OME. The struture
II_DATA_VALUE used in OME is without a member variable to indicate it
is representing a null value. So how can i do if i want to return a
null in OME?
Thanks.
Chenzhen


Reply With Quote
  #6  
Old   
Roy Hann
 
Posts: n/a

Default Re: how to return a null value in OME? - 03-11-2009 , 06:47 AM



zhenchen17 wrote:

Quote:
Hi Marty and all,
The problem seems easy in OpenAPI because there is a member variable
to indicate.

What i am doing is to return null value. For example, our datatype
st_point either could be a 2-dimension point(x, y) or be a 3-dimension
point(x,y,z). The function get_z_value is trying to fetch the z value
from the point given. But for a 2d point, there is no z value anymore,
so returning any value(such as 0 or -1) will cause confusion because
it will be regarded as a reasonable value. Null is the proper value
to return.
I don't want to distract anyone from answering the question you asked,
but I wonder if a type-mismatch error isn't the more appropriate
response?

It seems you don't want to treat points in two-space as points on the
z=0-plane in three-space, so for consistency, trying to ask for z is
actually a domain error. Allowing it to return null is asking to make
it possible to mix types in a column. We've already experienced the
misery of doing that with the Ingres DATE type.

--
Roy

UK Ingres User Association Conference 2009 will be on Tuesday June 9, 2009
Go to http://www.iua.org.uk/join to get on the mailing list.




Reply With Quote
  #7  
Old   
Martin Bowes
 
Posts: n/a

Default Re: [Info-Ingres] how to return a null value in OME? - 03-11-2009 , 06:53 AM



Well done karl!

That's going to be worth a play with later on!

Marty

-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of Karl
& Betty Schendel
Sent: 11 March 2009 12:31
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] how to return a null value in OME?

A few misconceptions here.

First, a null is indicated by the last byte of a nullable value
being nonzero. Nullable types have negative type codes.
So, for example, a nullable i4 would have db_datatype of
-II_INTEGER (using OME style names), a db_length of 5 instead
of the non-nullable 4, and the 5th byte of the value would be
zero for a non-null value and nonzero for NULL.

Second, you can indeed pass nullable parameters to OME functions.
but you need to define the function instance with the
II_FID_F256_NONULLSKIP flag. If you don't use that flag, the
query compiler assumes that the function should be treated like
an operator instead of an ordinary function, and any null
input skips the function call entirely giving a null result.
The NONULLSKIP flag tells it to just pass the parameters,
whatever they are, and let the function worry about it.

Third, simply define the FI with a negative result type, meaning
nullable, and you can return nulls.

Karl



On Mar 11, 2009, at 6:20 AM, Martin Bowes wrote:

Quote:
Hi Ian,

Yes OME (and all normal) functions won't take nulls as input
parameters,
but what about returning a null value?

Although, other that an aggregate function I couldn't honestly
think of
a reason to return a null.

I'm interested in what Chenzen is trying to achieve.

Marty

-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of
Ian
Kirkham
Sent: 11 March 2009 10:06
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] how to return a null value in OME?

If you are worried about being passed a NULL parameter then don't
as you
won't. The DBMS will short-circuit expressions in general that would
otherwise need to propagate NULLs.
Regards,
Ian
-----Original Message-----
From: info-ingres-bounces (AT) kettleriver...ting (DOT) com
[mailto:info-ingres-bounces (AT) kettleriverconsulting (DOT) com] On Behalf Of
zhenchen17
Sent: 11 March 2009 08:50
To: info-ingres (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] how to return a null value in OME?

Hi everyone,
I wonder how to return a null value in OME. The struture
II_DATA_VALUE used in OME is without a member variable to indicate it
is representing a null value. So how can i do if i want to return a
null in OME?
Thanks.
Chenzhen
_______________________________________________
Info-Ingres mailing list
Info-Ingres (AT) kettleriverconsulting (DOT) com
http://www.kettleriverconsulting.com...fo/info-ingres



Reply With Quote
  #8  
Old   
zhenchen17
 
Posts: n/a

Default Re: how to return a null value in OME? - 03-11-2009 , 07:53 PM



Hi Karl,
In my case, i don't want a null input but actually i want a null
output.
so what i do is:
1. define fi with a negative result value
2. mark the last byte of the return data to nonzero
Is that right?

Thanks
Chenzhen

On 3月11日, 下午8时31分, Karl & Betty Schendel <schen... (AT) kbcomputer (DOT) com>
wrote:
Quote:
A few misconceptions here.

First, a null is indicated by the last byte of a nullable value
being nonzero. Nullable types have negative type codes.
So, for example, a nullable i4 would have db_datatype of
-II_INTEGER (using OME style names), a db_length of 5 instead
of the non-nullable 4, and the 5th byte of the value would be
zero for a non-null value and nonzero for NULL.

Second, you can indeed pass nullable parameters to OME functions.
but you need to define the function instance with the
II_FID_F256_NONULLSKIP flag. If you don't use that flag, the
query compiler assumes that the function should be treated like
an operator instead of an ordinary function, and any null
input skips the function call entirely giving a null result.
The NONULLSKIP flag tells it to just pass the parameters,
whatever they are, and let the function worry about it.

Third, simply define the FI with a negative result type, meaning
nullable, and you can return nulls.

Karl

On Mar 11, 2009, at 6:20 AM, Martin Bowes wrote:



Hi Ian,

Yes OME (and all normal) functions won't take nulls as input
parameters,
but what about returning a null value?

Although, other that an aggregate function I couldn't honestly
think of
a reason to return a null.

I'm interested in what Chenzen is trying to achieve.

Marty

-----Original Message-----
From: info-ingres-boun... (AT) kettleriverconsulting (DOT) com
[mailto:info-ingres-boun... (AT) kettleriverconsulting (DOT) com] On Behalf Of
Ian
Kirkham
Sent: 11 March 2009 10:06
To: Ingres and related product discussion forum
Subject: Re: [Info-Ingres] how to return a null value in OME?

If you are worried about being passed a NULL parameter then don't
as you
won't. The DBMS will short-circuit expressions in general that would
otherwise need to propagate NULLs.
Regards,
Ian
-----Original Message-----
From: info-ingres-boun... (AT) kettleriverconsulting (DOT) com
[mailto:info-ingres-boun... (AT) kettleriverconsulting (DOT) com] On Behalf Of
zhenchen17
Sent: 11 March 2009 08:50
To: info-ing... (AT) kettleriverconsulting (DOT) com
Subject: [Info-Ingres] how to return a null value in OME?

Hi everyone,
I wonder how to return a null value in OME. The struture
II_DATA_VALUE used in OME is without a member variable to indicate it
is representing a null value. So how can i do if i want to return a
null in OME?
Thanks.
Chenzhen


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.