Is it possible to define operators which have, as their parameters, relations of any type? Below is my naive attempt to define such an operator.
OPERATOR test ( P RELATION, Q RELATION ) RETURNS RELATION;
return P JOIN Q;
END OPERATOR ;
Relation valued parameters
Re: Relation valued parameters
Hello Chris,
I'd be very surprised if you could do something like that:) But you could create operators (and their overloads) dynamically (using EXECUTE).
Best,
steve dassin
I'd be very surprised if you could do something like that:) But you could create operators (and their overloads) dynamically (using EXECUTE).
Best,
steve dassin
-
- Posts: 76
- Joined: Sat Aug 18, 2012 2:13 pm
Re: Relation valued parameters
Could you possibly expand on your suggestion a little - would the syntax simply be execute.......(the listing of my statement)? I am finding that I am writing quite a lot of boilerplate code such as:
VAR Dir VIEW WITH (
A := ( sys.Catalog WHERE Owner <> "Rel" ) { Name, Definition },
B := ( EXTEND Relvar_predicate :
{ Name := TREAT_AS_CHARACTER ( name ),
Predicate := TREAT_AS_CHARACTER ( predicate ) }
{ ALL BUT name, predicate } ),
***Begin Boilerplate***
C := A { Name } NOT MATCHING B { Name },
D := EXTEND A : { Predicate := "" },
E := A JOIN B, F := C JOIN D ):
E { Name, Predicate, Definition } UNION F;
***End Boilerplate***
While part of my investigating this possibility is sheer laziness (I don't like all the repetitive typing), in the past repetition of definitions or part definitions (as here) has been a warning sign of poor design and/or a potential source of error and version problems.
VAR Dir VIEW WITH (
A := ( sys.Catalog WHERE Owner <> "Rel" ) { Name, Definition },
B := ( EXTEND Relvar_predicate :
{ Name := TREAT_AS_CHARACTER ( name ),
Predicate := TREAT_AS_CHARACTER ( predicate ) }
{ ALL BUT name, predicate } ),
***Begin Boilerplate***
C := A { Name } NOT MATCHING B { Name },
D := EXTEND A : { Predicate := "" },
E := A JOIN B, F := C JOIN D ):
E { Name, Predicate, Definition } UNION F;
***End Boilerplate***
While part of my investigating this possibility is sheer laziness (I don't like all the repetitive typing), in the past repetition of definitions or part definitions (as here) has been a warning sign of poor design and/or a potential source of error and version problems.
Re: Relation valued parameters
There's been some discussion about being able to define generics -- they would be very handy for defining your own relational operators, for example -- but nothing has, to my recollection, yet made it into the Tutorial D specification. For now, using EXECUTE is certainly a way forward. Take a look at the Rel backup script, DatabaseToScript.d (found in the Scripts folder) for an example.
-
- Posts: 76
- Joined: Sat Aug 18, 2012 2:13 pm
Re: Relation valued parameters
Thanks for the pointer to an example - I'll pursue that.
-
- Posts: 124
- Joined: Sat May 24, 2008 4:49 pm
Re: Relation valued parameters
See TTM Very Strong Suggestion 6.
Business System 12, an interpreter, supported such operators back in 1980.
Hugh
Business System 12, an interpreter, supported such operators back in 1980.
Hugh