X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id E1DFE475A80 for ; Sat, 29 Mar 2003 16:04:59 -0500 (EST) Received: from lucifer.akyasociados.com.ar (unknown [200.69.203.237]) by postgresql.org (Postfix) with ESMTP id AF1DD474E42 for ; Sat, 29 Mar 2003 16:04:55 -0500 (EST) Received: from taz.oficina (taz.oficina [192.168.1.197]) (authenticated bits=0) by lucifer.akyasociados.com.ar (8.12.8/8.12.8) with ESMTP id h2TL8wkw032431; Sat, 29 Mar 2003 18:08:59 -0300 (ART) (envelope-from franco@akyasociados.com.ar) From: Franco Bruno Borghesi Organization: AK y Asociados S.R.L. To: "Zodiac" Subject: Re: Stored procedures Date: Sat, 29 Mar 2003 18:05:21 -0300 User-Agent: KMail/1.5 Cc: References: <006301c2f579$d21e8a60$7739e2c2@zodiacfhynm2is> <200303282040.59217.franco@akyasociados.com.ar> <002a01c2f632$c49f09f0$7d39e2c2@zodiacfhynm2is> In-Reply-To: <002a01c2f632$c49f09f0$7d39e2c2@zodiacfhynm2is> MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_Rqgh+dR+fTSHs9B"; charset="koi8-r" Content-Transfer-Encoding: 7bit Message-Id: <200303291805.21844.franco@akyasociados.com.ar> X-Spam-Status: No, hits=-38.8 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES,USER_AGENT autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/641 X-Sequence-Number: 12679 --Boundary-02=_Rqgh+dR+fTSHs9B Content-Type: text/plain; charset="koi8-r" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline As far as I know, you always work with a ResultSet.=20 If you know your stored procedures will always return an Integer and you do= n't=20 wanna deal with the executeQuery and stuff every time, you could create a= =20 class with methods explicitly for accesing your stored procedures, for=20 example: assuming you have a pg function returning an INT, called countPeople(), you= =20 could do public class MyStoredProcs { private static int executeAnyProc(Connection conn, String procName) thro= ws=20 SQLException{ Statement stmt=3Dconn.createStatement(); ResultSet rs=3Dstmt.executeQuery("SELECT * FROM "+procName+"()"); rs.next(); return rs.getInt(1);=20=20=20=20=20=20=20=20=20 } public static int countPeople() throws SQLException{ return executeAnyProc("countPeople"); } }; You could add methods to access every stored procedure in your database (ev= en=20 returning other data types), and you would use it like this in your code: ... int count=3DMyStoredProcs.countPeople(); // do something with the value if (count>100) { ... hope this is what you were looking for.=20=20 =20 On Saturday 29 March 2003 17:35, Zodiac wrote: > Thank you for help. > Just one more question. Have i direct access to stored procedure? > For example, i have procedure which returns Integer and i wanna to have > ability to write such code " int var =3D ANY_CALL". Where ANY_CALL is a my > procedure call. > I meant must i do "executeQuery" only and after then parse Statement > variable? > > Thank you. --Boundary-02=_Rqgh+dR+fTSHs9B Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQA+hgqRz/PwDAvtu7oRAkWDAKCOx02yznhJKZLCN+pAbjqpkZn/LgCePqpM rC5Vp/jWFrWv9chbdBidhTg= =+B0g -----END PGP SIGNATURE----- --Boundary-02=_Rqgh+dR+fTSHs9B--