[firebase-br] RES: Verificar antes do Insert

Leonardo Lima leonardo em softguild.com.br
Seg Out 19 19:00:20 -03 2009


Este comando serve a partir de qual versão do FB?

Jose Aparecido da Silva escreveu:
> Retirado da documentacao do FB
>
> -----------------
> UPDATE OR INSERT statement
> -----------------
>
>   Function:
>     Allow to update or insert a record based on the existence (checked with
> IS NOT DISTINCT) or not of it.
>
>   Author:
>     Adriano dos Santos Fernandes <adrianosf em uol.com.br>
>
>   Syntax rules:
>     UPDATE OR INSERT INTO <table or view> [(<column_list>)]
>         VALUES (<value_list>)
>         [MATCHING <column_list>]
>         [RETURNING <column_list> [INTO <variable_list>]]
>
>   Scope:
>     DSQL, PSQL
>
>   Examples:
>     1. UPDATE OR INSERT INTO T1 (F1, F2) VALUES (:F1, :F2);
>     2. UPDATE OR INSERT INTO EMPLOYEE (ID, NAME) VALUES (:ID, :NAME)
> RETURNING ID;
>     3. UPDATE OR INSERT INTO T1 (F1, F2) VALUES (:F1, :F2) MATCHING (F1);
>     4. UPDATE OR INSERT INTO EMPLOYEE (ID, NAME) VALUES (:ID, :NAME)
> RETURNING OLD.NAME;
>
>   Notes:
>     1. When MATCHING is omitted, the existence of a primary key is required.
>     2. INSERT and UPDATE permissions are needed on <table or view>.
>     3. If the RETURNING clause is present, then the statement is described
> as
>        isc_info_sql_stmt_exec_procedure by the API. Otherwise it is
> described
>        as isc_info_sql_stmt_insert.
>
>   Limitation:
>     1. A singleton error will be raised if the RETURNING clause is present
> and more than
>        one record match the condition.
>
> -----Mensagem original-----
> De: lista-bounces em firebase.com.br [mailto:lista-bounces em firebase.com.br] Em
> nome de Jonas
> Enviada em: segunda-feira, 19 de outubro de 2009 16:18
> Para: lista em firebase.com.br
> Assunto: [firebase-br] Verificar antes do Insert
>
> Olá pessoal, eu gostaria de saber se há a possibilidade de verificar se um
> registro já existe antes de ser feito o insert, sem ter a presença de SP ou
> Triggers, digamos "em uma sql só".
>
> Obrigado a todos.
>
>   





Mais detalhes sobre a lista de discussão lista