[Mulgara-dev] Problem w/ "insert select ..."

Andrae Muys andrae at netymon.com
Thu Mar 29 08:33:05 UTC 2007


On 29/03/2007, at 5:45 PM, Eric Brown wrote:
> Hm. Well, using the shorter form of what I need isn't as verbose...  
> so maybe I jumped the gun. Anyway, just looking for a way to reduce  
> the verbosity (just as aliases do in a small way). In my limited  
> experience itql does seem quite a bit more verbose than sql which  
> maybe isn't a big deal for a developer, but IMO is an issue for  
> system-admins that need to maintain and manage production systems.
>
> define replace(p, old, new, model)
>   delete select $s $p $old from $model where $s $p $old from $model;
>   insert select $s $p $new from $model where $s $p $new into $model;
> end
>
> replace <pred> <old1> <new1> <model>;
> replace <pred> <old2> <new2> <model>;
> replace <pred> <old3> <new3> <model>;
> replace <pred> <old4> <new4> <model>;
> replace <pred> <old5> <new5> <model>;

That replace function seems a little bizarre - the insert/select is  
idempotent.  I'm pretty certain you meant:

define replace(p, old, new, model)
   setautocommit off ;
   insert select $s ?p ?new from ?model where $s ?p ?old into ?model ;
   delete select $s ?p ?old from ?model where $s ?p ?old from ?model ;
   setautocommit on ;
end

and are you sure you want to 'update' _every_ instance with property ? 
p ?old to ?p ?new - I must admit I would have thought a more common  
problem would be

define update(s, p, new, model)
   setautocommit off ;
   delete select ?s ?p $old from ?model where ?s ?p $old from ?model ;
   insert ?s ?p ?new into ?model ;
   setautocommit on ;
end

or possibly

define update(pkey, pval, p, new, model)
   setautocommit off ;
   delete select $s ?p $old from ?model where $s ?pkey ?pval from ? 
model ;
   insert select $s ?p ?new from ?model where $s ?pkey ?pval into ? 
model ;
   setautocommit on ;
end

and of course you could also define update(pkey, pval, p, new, old,  
model) - and that's ultimately the reason why we are discussing a new  
query language for Mulgara at this point - and no this sort of  
customisation cannot be provided by a Resolver.

Personally I would love to be working on a new query language for  
Mulgara, these examples only scratch the surface of what can be  
offered by adding new abstractions and combinators to an iTql-like  
core.  For the moment however, my focus has to be on XA2.

Andrae

-- 
Andrae Muys
andrae at netymon.com
Principal Mulgara Consultant
Netymon Pty Ltd





More information about the Mulgara-dev mailing list