Received: from bologna.nettuno.it (bologna.nettuno.it [193.43.2.1]) by hub.org (8.9.3/8.9.3) with ESMTP id EAA99874; Tue, 7 Dec 1999 04:53:45 -0500 (EST) (envelope-from jose@sferacarta.com) Received: from proxy.sferacarta.com (mail@sfcabop1.nettuno.it [193.207.10.213]) by bologna.nettuno.it (8.9.3/8.9.3/NETTuno 4.1) with ESMTP id KAA27863; Tue, 7 Dec 1999 10:53:37 +0100 (MET) Received: from rosso.sferacarta.com (sferacarta.com) [10.20.30.5] by proxy.sferacarta.com with esmtp (Exim 2.05 #1 (Debian)) id 11vI6E-000829-00; Tue, 7 Dec 1999 10:44:02 +0000 Message-ID: <384CD795.4F163169@sferacarta.com> Date: Tue, 07 Dec 1999 10:47:01 +0100 From: jose soares X-Mailer: Mozilla 4.5 [it] (Win95; I) X-Accept-Language: it MIME-Version: 1.0 To: hackers postgres , interfaces Subject: Re: [HACKERS] TRANSACTION "WARNINGS" References: <199909170445.AAA07310@candle.pha.pa.us> <3844FE1A.9E48AF93@sferacarta.com> Content-Type: multipart/alternative; boundary="------------BFA2687FDAB6B9DFC492C35F" --------------BFA2687FDAB6B9DFC492C35F Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, Its me again, I'm trying to use transactions thru ODBC but it seems to be impossible. I'm populating my tables using transactions thru ODBC and before to INSERT a row to a table I check if such row already exist in that table. if result is FALSE I insert the row into the table otherwise I skip the INSERT operation. I have a log in which ODBC checks for an unexistent row but when I try to INSERT the row I cannot insert it, there's a duplicate index error. I have only two index in that table and only one of them is UNIQUE and I know there is no other row with the same index in that table. If I use the same program without transactions it works fine. Any ideas? here the log: conn=61438304, SQLDriverConnect(out)='DSN=PostgreSQL;DATABASE=hygea;SERVER=verde conn=61438304, query='SELECT "utenti"."azienda","utenti"."inizio_attivita" FROM "utenti" WHERE ("azienda" = '01879540308' ) ' [ fetched 0 rows ] conn=61438304, SQLDisconnect conn=61284284, query='INSERT INTO "utenti" ("azienda","ragione_sociale","istat","cap","indirizzo","partita_iva","istat_nascita","distretto","data_aggiornamento") VALUES ('01879540308','FONZAR PAOLO-LUCA-LUCIANO E DANIELA','030120','33050','VIA PROVINCIALE N.4','01879540308','000000','G10500','1999-11-17 00:00:00')' ERROR from backend during send_query: 'ERROR: Cannot insert a duplicate key into a unique index' conn=61284284, query='ABORT' and here the table structure: Table = utenti +----------------------------------+----------------------------------+-------+ |Field |Type | Length| +----------------------------------+----------------------------------+-------+ | azienda | char() not null | 16 | | ragione_sociale | varchar() not null | 45 | | istat | char() not null | 6 | | cap | char() | 5 | | indirizzo | char() | 40 | | civico | char() | 10 | | distretto_interno | char() | 3 | | frazione | char() | 25 | | telefono | char() | 15 | | fax | char() | 15 | | email | char() | 15 | | codice_fiscale | char() | 16 | | partita_iva | char() | 11 | | cciaa | char() | 8 | | data_ccia | date | 4 | | data_nascita | date | 4 | | istat_nascita | char() | 6 | | stato_attivita | char() | 2 | | fuori_usl | char() default 'N' | 1 | | assegnazione_codice | date | 4 | | inizio_attivita | date not null default date( 'cur | 4 | | fine_attivita | date | 4 | | dpr317 | char() default 'N' | 1 | | distretto | char() | 6 | | data_aggiornamento | timestamp default now() | 4 | | aggiornato_da | char() default CURRENT_USER | 10 | | data_esportazione | date | 4 | | data_precedente_esp | date | 4 | +----------------------------------+----------------------------------+-------+ Indices: utenti_pkey utenti_ragione_idx Thanks for any help. Jose' jose soares ha scritto: > Hi all, > > I have again a problem about TRANSACTIONS. > I had some answers about this matter some time ago, but unfortunately the solution wasn't yet found. > Transaction are essentials for a relational database but in the case of PostgreSQL some times it's > impossible > to use them. Right now I'm in a middle of a work and I need to use transactions but I can't go on because > there are some "warnings" that I would like to avoid but I can't. > > Problem: > > PostgreSQL automatically ABORTS at every error, even a syntax error. > I know that a transaction is a sequence of operations which either all succeed, or all fail, and > this behavior is correct for batch mode operations, but it is not useful in interactive mode where > the user > could decide if the transaction should be COMMITed or ROLLBACKed even in presence of errors. > Other databases have such behavior. > > What about to have a variable to set like: > > SET TRANSACTION MODE TO {BATCH | INTERACTIVE} > > where: > BATCH: the transaction ROLLBACK at first error and COMMIT only if all operations > succeed. > INTERACTIVE: leaves the final decision to user to COMMIT or ROLLBACK even if some error occurred. > > Comments... > > Jose' > > ************ --------------BFA2687FDAB6B9DFC492C35F Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Hi,

Its me again,

I'm trying to use transactions thru ODBC but it seems to be impossible.
I'm populating my tables using transactions thru ODBC and before to INSERT a row to a table
I check if such row already exist in that table.
if result is FALSE I insert the row into the table otherwise I skip the INSERT operation.
I have a log in which ODBC checks for an unexistent row but when I try to INSERT the row
I cannot insert it, there's a duplicate index error.
I have only two index in that table and only one of them is UNIQUE and I know there is no
other row with the same index in that table.
If I use the same program without transactions it works fine.

Any ideas?

here the log:

<DELETED>
conn=61438304, SQLDriverConnect(out)='DSN=PostgreSQL;DATABASE=hygea;SERVER=verde
conn=61438304, query='SELECT "utenti"."azienda","utenti"."inizio_attivita"
FROM "utenti" WHERE ("azienda" = '01879540308' ) '
    [ fetched 0 rows ]
conn=61438304, SQLDisconnect
conn=61284284, query='INSERT INTO  "utenti" ("azienda","ragione_sociale","istat","cap","indirizzo","partita_iva","istat_nascita","distretto","data_aggiornamento")
VALUES ('01879540308','FONZAR PAOLO-LUCA-LUCIANO E DANIELA','030120','33050','VIA PROVINCIALE N.4','01879540308','000000','G10500','1999-11-17 00:00:00')'
ERROR from backend during send_query:  'ERROR:  Cannot insert a duplicate key into a unique index'
conn=61284284, query='ABORT'
<DELETED>

and here the table structure:

Table    = utenti
+----------------------------------+----------------------------------+-------+
|Field                             |Type                              | Length|
+----------------------------------+----------------------------------+-------+
| azienda                          | char() not null                  |    16 |
| ragione_sociale                  | varchar() not null               |    45 |
| istat                            | char() not null                  |     6 |
| cap                              | char()                           |     5 |
| indirizzo                        | char()                           |    40 |
| civico                           | char()                           |    10 |
| distretto_interno                | char()                           |     3 |
| frazione                         | char()                           |    25 |
| telefono                         | char()                           |    15 |
| fax                              | char()                           |    15 |
| email                            | char()                           |    15 |
| codice_fiscale                   | char()                           |    16 |
| partita_iva                      | char()                           |    11 |
| cciaa                            | char()                           |     8 |
| data_ccia                        | date                             |     4 |
| data_nascita                     | date                             |     4 |
| istat_nascita                    | char()                           |     6 |
| stato_attivita                   | char()                           |     2 |
| fuori_usl                        | char() default 'N'               |     1 |
| assegnazione_codice              | date                             |     4 |
| inizio_attivita                  | date not null default date( 'cur |     4 |
| fine_attivita                    | date                             |     4 |
| dpr317                           | char() default 'N'               |     1 |
| distretto                        | char()                           |     6 |
| data_aggiornamento               | timestamp default now()          |     4 |
| aggiornato_da                    | char() default CURRENT_USER      |    10 |
| data_esportazione                | date                             |     4 |
| data_precedente_esp              | date                             |     4 |
+----------------------------------+----------------------------------+-------+
Indices:  utenti_pkey
          utenti_ragione_idx
 

Thanks for any help.
Jose'
 

jose soares ha scritto:

Hi all,

I have again a problem about TRANSACTIONS.
I had some answers about this matter some time ago, but unfortunately the solution wasn't yet found.
Transaction are essentials for a relational database but in the case of PostgreSQL some times it's
impossible
to use them. Right now I'm in a middle of a work and I need to use transactions but I can't go on because
there are some "warnings" that I would like to avoid but I can't.

Problem:

    PostgreSQL automatically ABORTS at every error, even a syntax error.
    I know that a transaction is a sequence of operations which either all succeed, or all fail, and
    this behavior is correct for batch mode operations,  but  it is not useful in interactive mode where
the user
    could decide if the transaction should be COMMITed or ROLLBACKed even in presence of  errors.
    Other databases have such behavior.

What about to have a variable to set like:

SET TRANSACTION MODE TO {BATCH | INTERACTIVE}

where:
        BATCH:              the transaction ROLLBACK at first error and COMMIT only if all operations
succeed.
        INTERACTIVE:  leaves the final decision to user to COMMIT or ROLLBACK even if some error occurred.

Comments...

Jose'

************

--------------BFA2687FDAB6B9DFC492C35F--