X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id 6E68811F68E8 for ; Fri, 14 Apr 2006 09:48:59 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: 1.508 X-Spam-Level: * X-Spam-Status: No, score=1.508 required=5 tests=[BAYES_00=-2.599, FROM_HAS_ULINE_NUMS=0.291, SPF_HELO_SOFTFAIL=2.432, SPF_SOFTFAIL=1.384] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id cfrVYulsVR8W for ; Fri, 14 Apr 2006 09:48:41 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web52501.mail.yahoo.com (web52501.mail.yahoo.com [206.190.48.184]) by postgresql.org (Postfix) with SMTP id 0685711F6C54 for ; Fri, 14 Apr 2006 09:48:38 -0300 (ADT) Received: (qmail 63097 invoked by uid 60001); 14 Apr 2006 12:48:34 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=PwyxUP47qxSvNfGvH2dzBo0xHH3dn1mUZ0MAKZRwgRRfJ2knfn2C7hxF35uMNuHlenR8XEUA8EmpCHnLl9e+yjK/UWDpDyZzc3RR+uJkVUzFiOLahrtKHnrKdw4eoqdad+NuPXKmiYlm9qN4Z7M0l+9ah8V8bEruCN1C0m/kDZg= ; Message-ID: <20060414124834.63095.qmail@web52501.mail.yahoo.com> Received: from [141.157.126.150] by web52501.mail.yahoo.com via HTTP; Fri, 14 Apr 2006 05:48:34 PDT Date: Fri, 14 Apr 2006 05:48:34 -0700 (PDT) From: Ash Grove Subject: stored function, multiple queries, best practices To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200604/103 X-Sequence-Number: 15037 Hello, I'd like to learn how other people approach this kind of situation: Say you want to do an insert on three tables and all of your data is coming into the db from your application. You do the first insert and a primary key is generated. You grab that primary key and insert it (along with some other data) into the two other tables. Finally, you return the primary key to the application. If something goes wrong, you want to everything to rollback. I currently do this by building a delimited string in the application containing all data to be inserted and then sending it, via callablestatement, to a stored function. The function parses the string, does the inserts and returns the primary key via a registered out parameter. Are there glaring errors with this approach? How would you do this? Thanks in advance, Ash __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com