🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #6341

java postgresql y procedures (OT)

#6341
From: [ZoRo]
Date: Wed, 02 Jul 2003 23:37
45 lines
2472 bytes
Hola
nunca he trabajado con procedures.
tengo que hacer en una tabla dos operaciones pero si una de ellas no se
cunple que no se haga ninguna de las dos.
para eso he oido que se usan las procedures pero nunca las he usado ni se
como se hacen.,
mi intencion es usarlas con una clase que tengo de java
en ella hago

public String borrar(int id) throws SQLException{
        Statement stmt = null;
        ResultSet rs = null;
        ResultSetMetaData md = null;
        int noOfRows=0;
        String deleteMaquina="delete from maquinas where id="+id;
             try{
                 stmt=conexion.createStatement();
                    noOfRows = stmt.executeUpdate(deleteMaquina);
             }catch(Exception e ){
                  System.out.println("La exception insertando maquina es : "
+ e);
              }
              finally {
                    try { rs.close(); } catch (Exception ignore) {}
                    try { stmt.close(); } catch (Exception ignore) {}
                    stmt = null;
                    rs = null;
              }
              if(noOfRows==1){
                    return "1";
                }else{
                    return "0";
                }
    }
pero tengo que hacer en este metodo dos deletes y si una de ellas no se hace
bien que no se haga ninguna de las dos, es decir el segundo delete seria:

String deleteMaquina2="delete from maquinas2 where id="+id;



Me podeis ayudar para crear esa procedure en postgresql usando java?
muchas gracias de antemano

Saludos
Technical Details
Message-ID: <bdvqao$1152ss$1@ID-59646.news.dfncis.de>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!217-127-108-221.uc.nombres.ttd.ES!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII-7-bit
X-Google-Thread: f86c8,899a49b561c3a27,start
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2003-07-02 16:36:58 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!217-127-108-221.uc.nombres.ttd.ES!not-for-mail
From: "[ZoRo]" <granbilbao_NOSPAM_@latinmail.com>
Newsgroups: es.comp.os.linux.programacion
Subject: java postgresql y procedures (OT)
Date: Thu, 3 Jul 2003 01:37:01 +0200
Lines: 47
Message-ID: <bdvqao$1152ss$1@ID-59646.news.dfncis.de>
NNTP-Posting-Host: 217-127-108-221.uc.nombres.ttd.es (217.127.108.221)
X-Trace: fu-berlin.de 1057189017 34769820 217.127.108.221 (16 [59646])
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165