Subject | Re: [Firebird-Architect] REPLACE statement |
---|---|
Author | Adriano dos Santos Fernandes |
Post date | 2006-02-11T12:47:53Z |
Dmitry Yemanov wrote:
statement. Like blr_store.
IMO, MERGE and REPLACE can't share a unique verb.
MERGE has <search condition> and don't depend on PK.
Don't you think we can implement MERGE with already existing verbs, i.e.
blr_for, blr_store, blr_modify, blr_leave, and REPLACE with just
blr_replace and construct a RSE internally?
Or do you think we should generate the RSE (constructed based on the PK)
in BLR even for REPLACE?
Adriano
> "Adriano dos Santos Fernandes" <adrianosf@...> wrote:I'd think in the syntax of the new verb as: blr_replace, relation,
>
>> SQL standard has MERGE statement, used to insert a row when a condition
>> is false or update when the condition is true.
>> MERGE is not very user friendly.
>> It's like a INSERT and UPDATE mixed in one statement. You should pass
>> the parameters twice.
>>
>
> Correct. I don't like it much either :-) But it provides more flexibility.
> Imagine that you need to either increment values for an existing record or
> add a new record with the base values.
>
> Could we consider implementation of the SQL-compliant MERGE and then add
> REPLACE (or just a more user-friendly syntax of MERGE) as a shortcut for the
> simplified semantics? I mean to implement them both using a single BLR verb.
>
statement. Like blr_store.
IMO, MERGE and REPLACE can't share a unique verb.
MERGE has <search condition> and don't depend on PK.
Don't you think we can implement MERGE with already existing verbs, i.e.
blr_for, blr_store, blr_modify, blr_leave, and REPLACE with just
blr_replace and construct a RSE internally?
Or do you think we should generate the RSE (constructed based on the PK)
in BLR even for REPLACE?
>I also prefer the INTO syntax.
>> Syntax of REPLACE can be one of these:
>>
>> REPLACE INTO table_name [(column [, column ...])] VALUES (value [,
>> value ...])
>> replace into table (pk, x) values (1, 11);
>> replace into table (values (1, 11);
>>
>> or
>>
>> REPLACE table_name SET column = value [, column = value ...]
>> replace table set pk = 1, x = 11;
>>
>
> MERGE INTO ... VALUES (...) sounds better to me (considering my point
> above). But I may live with your second suggestion as well :-)
>
Adriano