Marc.Graham@SEI.CMU.EDU (09/02/87)
I would like to determine if Ada can be made to handle NULL values in an elegant, efficient way. The problem arises in interfacing a database language (namely SQL) and Ada. In brief, I would like to define a type which properly includes all values and operations of the predefined (package STANDARD, appendix F) type INTEGER and also includes one new value: NULL. The rules of arithmetic remain unchanged for values in INTEGER. The rule extending to NULL is: any operation involving the NULL value returns the NULL value. I want the solution to have the following properties: any expression valid for objects of type INTEGER is valid for objects of the new type. The solution must be ***very efficient at run time*** and reasonable at compile time. Run time efficiency includes: evaluation of arithmetic operations; conversion costs. For the conversion problem: Assume the DBMS delivers (and expects) values in the form of pairs <x,y> where y is an indicator and takes on some special value when the value represented is null; otherwise, the value represented is the value of x. ***Make no assumptions about x and y (e.g. length in bits, encoding scheme, etc)***** Can a solution requiring ****zero**** runtime conversion costs be produced? Mail your solutions to me (marc@sei.cmu.edu) or, more interestingly, post them here for comments.
Marc.Graham@SEI.CMU.EDU (09/06/87)
Date: 2 Sep 1987 12:38:45-EDT I would like to determine if Ada can be made to handle NULL values in an elegant, efficient way. The problem arises in interfacing a database language (namely SQL) and Ada. In brief, I would like to define a type which properly includes all values and operations of the predefined (package STANDARD, appendix F) type INTEGER and also includes one new value: NULL. The rules of arithmetic remain unchanged for values in INTEGER. The rule extending to NULL is: any operation involving the NULL value returns the NULL value. I want the solution to have the following properties: any expression valid for objects of type INTEGER is valid for objects of the new type. The solution must be ***very efficient at run time*** and reasonable at compile time. Run time efficiency includes: evaluation of arithmetic operations; conversion costs. For the conversion problem: Assume the DBMS delivers (and expects) values in the form of pairs <x,y> where y is an indicator and takes on some special value when the value represented is null; otherwise, the value represented is the value of x. ***Make no assumptions about x and y (e.g. length in bits, encoding scheme, etc)***** Can a solution requiring ****zero**** runtime conversion costs be produced? Mail your solutions to me (marc@sei.cmu.edu) or, more interestingly, post them here for comments.