Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 9EF281337B5C for ; Tue, 16 Nov 2010 13:05:08 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 99599-06 for ; Tue, 16 Nov 2010 17:05:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from web57613.mail.re1.yahoo.com (web57613.mail.re1.yahoo.com [66.196.100.96]) by mail.postgresql.org (Postfix) with SMTP id 49B691337B5B for ; Tue, 16 Nov 2010 13:05:00 -0400 (AST) Received: (qmail 2049 invoked by uid 60001); 16 Nov 2010 17:04:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1289927099; bh=O43hQSo8vip2QImbn6UT68XlQhRQwAeM27o/OT+4V+c=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=UKtNq9x0RNylU73CPtTQ44m0P7rPO1+BTdf2oGDel/eTOwFo3sTylMO8AOfTa/csmSm8PLlUr2HwMtxH71BHk65KIopUXJsxhBGrDg00M2FfL5Qh/1kp1gupTcifIghS/OiTWAu0uyyEHq5UubX8LnRFiERVpEBz+ohqGvwadSY= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=df+BMWuhgDqbYJ+UR1t3o9F1FEoJU5QTdPvk//D2SCr9iZH5SovrovaUFeQ0RGGaLYc9cGHmLFcRIJFPfiX/T2Hb9KZwnCxvyHh8VlWF4NH4t9OpwlqDI5OFn9JATxTv6C5fLzzkwZrO/rlMyax12I6d4YBJr4AeJc7xxnnw6TM=; Message-ID: <237745.519.qm@web57613.mail.re1.yahoo.com> X-YMail-OSG: m1cqpmgVM1m_KHdFc4xiD409p1Xk24eZ84h_eS_WAndyJjj qdV_QVREYPTlh86Dc2gFOQ3SNDx88Rx4bP_WWUDyueawy4R2DgTs2niXppfL 52BVjeBhJouMAj2qdWK7fAhzBSyZmuKHK7cRobV.MJwRV5muatBoHqK_ZISc 5KJKI_inqO9iotNxen1uaqiihr2SGVBJyL7BM4GRDwsI_Fp2YnAslKrbjSUa 2pA5TgdgSpxZSlYUCzJwcloejJYEPqan6jm2zULQq8eMuBoCZkmoABK_Sh.L c.NPAPvA0e.1NX81jxOHYb2UjvY2Dv9FJIDJArW1Erlv572prjPN.ysEvRY5 xgB_eXSOpx86qm4vK Received: from [198.22.122.4] by web57613.mail.re1.yahoo.com via HTTP; Tue, 16 Nov 2010 09:04:59 PST X-Mailer: YahooMailRC/504.5 YahooMailWebService/0.8.107.285259 References: <201011131850.oADIonok007767@wwwmaster.postgresql.org> <8645.1289675026@sss.pgh.pa.us> <212447.11179.qm@web57612.mail.re1.yahoo.com> Date: Tue, 16 Nov 2010 09:04:59 -0800 (PST) From: vince maxey Subject: Re: BUG #5753: Existing Functions No Longer Work To: tgl@sss.pgh.pa.us, pgsql-bugs@postgresql.org Cc: Me Yahoo In-Reply-To: <212447.11179.qm@web57612.mail.re1.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RFC_ABUSE_POST=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/111 X-Sequence-Number: 28691 Tom, or anyone else working with this dB, can you respond to my question:= =0A=0AHow should the syntax for a function be formulated to return a refcur= sor =0Acontaining one or more records?=A0 =0A=0A=0AI have many years SQL de= velopment experience and work with Oracle in my current =0Aposition.=A0 I'm= not a novice programmer.=0A=0AMy functions all worked prior to switching t= o 9.0 and I can excute functions =0Afrom the pgAdminIII UI which return an = individual result, such as an integer, =0Abut cannot test/troubleshoot thos= e which use refcursors in the same manner; and =0Athey are not working with= in my application.=A0 They used to work.=0A=0AI've provided test data and f= unctions for your inspection and validation.=A0 Even =0Apointing me to some= substantial documentation (white paper or actual book) that =0Acontains bo= nafide examples of how to write postgresql functions would probably =0Ahelp= .=A0 But simply providing syntax segments is not working,=A0 I've not come = =0Aacross any examples that I can translate or compare with my existing eff= orts.=0A=0AAccording to your documentation, new releases should be backward= compatible; =0Aother than for specific elements.=A0 I would think this par= ticular functionality =0Ashould be backward compatible but as I'm finding i= t not to be, please take some =0Atime to investigate and validate for yours= elves what I have communicated.=0A=0AI really do think postgreSQL is a grea= t database from a development =0Aperspective.=A0 If I can get over this iss= ue, perhaps I can provide some =0Adocumentation which others can use to cre= ate their own functions.=0A=0Athank you for your assistance.=0A=0A=0A----- = Original Message ----=0AFrom: vince maxey vamax27@yahoo.com =0ATo: Tom Lane= =0ACc: Me Yahoo ; pgsql-bugs@postgre= sql.org=0ASent: Sat, November 13, 2010 3:44:03 PM=0ASubject: Re: [BUGS] BUG= #5753: Existing Functions No Longer Work=0A=0AThanks for your response, To= m.=0A=0AI guess my question would be, what needs to change in my syntax to = expect to get =0A=0Aone row returned?=0A=0AHere are a couple of examples th= at do work in my existing application prior to =0Amy recent computer switch= and re-build=A0(and I have well over 100 of these types =0Aof functions de= fined, some more complex than others, but I figured a simple =0Aexample wou= ld help someone else to most easily be able to help me).=0A=0A=0A-- Functio= n: dimension.get_location_holiday(bigint)=0A-- DROP FUNCTION dimension.get_= location_holiday(bigint);=0ACREATE OR REPLACE FUNCTION dimension.get_locati= on_holiday(bigint)=0A=A0 RETURNS refcursor AS=0A$BODY$ =0ADECLARE=0A=A0=0A= =A0loc refcursor;=0ABEGIN=0A=A0open loc for =0A=A0=A0select * from dimensio= n.location_holiday where holidayid =3D $1;=A0=0A=A0return loc;=0AEND;=0A$BO= DY$=0A=A0 LANGUAGE plpgsql VOLATILE=0A=A0 COST 100;=0AALTER FUNCTION dimens= ion.get_location_holiday(bigint) OWNER TO postgres;=0AGRANT EXECUTE ON FUNC= TION dimension.get_location_holiday(bigint) TO public;=0AGRANT EXECUTE ON F= UNCTION dimension.get_location_holiday(bigint) TO postgres;=0A=0A=0A-- Func= tion: dimension.get_location_list(character varying, character varying, =0A= integer)=0A-- DROP FUNCTION dimension.get_location_list(character varying, = character =0Avarying, integer);=0ACREATE OR REPLACE FUNCTION dimension.get_= location_list(character varying, =0Acharacter varying, integer)=0A=A0 RETUR= NS refcursor AS=0A$BODY$ =0ADECLARE=0A=A0loc refcursor;=0ABEGIN=0A=A0IF $3 = =3D 1 THEN=0A=A0=A0open loc for =A0=A0=0A=A0=A0select a.locationid, a.locat= ionname, a.partnerid, b.partnername, =0Aa.phone1,a.phone2,=A0=A0 =0A=0A=A0= =A0a.fax1, a.fax2,a.physaddress1, a.physaddress2, a.physcityid, e.city||', = =0A'||e.statecode||'=A0 '||e.zipcode,=0A=A0=A0a.contact1, a.contact2, a.ema= il1, a.email2, a.activestatus, a.timezone, =0Aa.taxrate, e.statecode,a.faxf= lag,=0A=A0=A0a.ticklerflag,case when a.ticklerflag =3D 't' then 'YES' else = 'NO' end, e.city=0A=A0=A0from dimension.location_base a, dimension.partner = b, postal.us_zip e =0A=A0=A0where a.partnerid =3D b.partnerid and a.physcit= yid =3D e.zipid and e.statecode =3D =0A$2 order by a.locationname;=0A=A0ELS= E=0A=A0=A0IF $3 =3D 0 THEN=0A=A0=A0=A0open loc for =A0=A0=0A=A0=A0=A0select= a.locationid, a.locationname, a.partnerid, b.partnername, =0Aa.phone1,a.ph= one2,=A0=A0 =0A=0A=A0=A0=A0a.fax1, a.fax2,a.physaddress1, a.physaddress2, a= .physcityid, e.city||', =0A'||e.statecode||'=A0 '||e.zipcode,=0A=A0=A0=A0a.= contact1, a.contact2, a.email1, a.email2, a.activestatus, a.timezone, =0Aa.= taxrate, e.statecode,a.faxflag,=0A=A0=A0=A0a.ticklerflag,case when a.tickle= rflag =3D 't' then 'YES' else 'NO' end, e.city=0A=A0=A0=A0from dimension.lo= cation_base a, dimension.partner b, postal.us_zip e =0A=A0=A0=A0where a.par= tnerid =3D b.partnerid and a.physcityid =3D e.zipid and e.statecode =3D =0A= $2 =0A=0A=A0=A0=A0and lower(a.locationname) like $1||'%' order by a.locatio= nname;=A0=0A=A0=A0ELSE=0A=A0=A0=A0open loc for =A0=A0=0A=A0=A0=A0select a.l= ocationid, a.locationname, a.partnerid, b.partnername, =0Aa.phone1,a.phone2= ,=A0=A0 =0A=0A=A0=A0=A0a.fax1, a.fax2,a.physaddress1, a.physaddress2, a.phy= scityid, e.city||', =0A'||e.statecode||'=A0 '||e.zipcode,=0A=A0=A0=A0a.cont= act1, a.contact2, a.email1, a.email2, a.activestatus, a.timezone, =0Aa.taxr= ate, e.statecode,a.faxflag,=0A=A0=A0=A0a.ticklerflag,case when a.ticklerfla= g =3D 't' then 'YES' else 'NO' end, e.city=0A=A0=A0=A0from dimension.locati= on_base a, dimension.partner b, postal.us_zip e =0A=A0=A0=A0where a.partner= id =3D b.partnerid and a.physcityid =3D e.zipid and a.partnerid =3D =0A$1;= =0A=A0=0A=A0=A0END IF;=0A=A0END IF;=0A=A0return loc;=0AEND;=0A$BODY$=0A=A0 = LANGUAGE plpgsql VOLATILE=0A=A0 COST 100;=0AALTER FUNCTION dimension.get_lo= cation_list(character varying, character varying, =0A=0Ainteger) OWNER TO p= ostgres;=0AGRANT EXECUTE ON FUNCTION dimension.get_location_list(character = varying, =0Acharacter varying, integer) TO public;=0AGRANT EXECUTE ON FUNCT= ION dimension.get_location_list(character varying, =0Acharacter varying, in= teger) TO postgres;=0AGRANT EXECUTE ON FUNCTION dimension.get_location_list= (character varying, =0Acharacter varying, integer) TO "eMenuAdmin";=0A=0A= =0AI am running my test procs from the pgAdminIII GUI.=A0 Is my syntax wron= g to =0Aexecute the function?=A0 If I run select test_proc1(3), I do get th= e correct =0Aresult which is a column header (test_proc1 integer) and a val= ue (2).=A0 So why =0Awouldn't I get a 6-column result set when running sele= ct test_proc(2) ?=0A=0AMy java code=A0syntax is as follows:=0A=0A=A0public = Collection getLocationList(String pname, String ste, int type) {=A0=A0=A0= =0A=A0=A0PartnerDAO ef =3D new PartnerDAO();=0A=A0=A0CallableStatement proc= =3D null;=0A=A0=A0Connection conn =3D ef.getConnection();=0A=A0=A0Collecti= on locations =3D new ArrayList();=A0=A0=A0=A0=A0=A0=0A=A0=A0try {=A0=A0=A0= =0A=A0=A0=A0proc =3D conn.prepareCall("{ ?=3D call dimension.get_location_l= ist(?,?,?) }");=0A=A0=A0=A0proc.registerOutParameter(1, Types.OTHER);=0A=A0= =A0=A0=A0=A0 proc.setString(2, pname.toLowerCase().trim());=0A=A0=A0=A0=A0= =A0 proc.setString(3, ste);=0A=A0=A0=A0=A0=A0 proc.setInt(4, type);=A0=A0 = =0A=A0=A0=A0=A0=A0 conn.setAutoCommit(false);=0A=A0=A0=A0=A0=A0 proc.execut= e();=A0=A0=A0=A0 =A0=0A=A0=A0=A0=A0=A0 ResultSet rs =3D (ResultSet) proc.ge= tObject(1);=0A=A0=A0=A0=A0=A0 while (rs.next()) {=0A=A0=A0=A0=A0=A0 =A0Loca= tionVO eRec =3D new LocationVO();=A0=A0=A0=A0=A0 =A0=A0=A0=A0=A0=A0 =A0=0A= =A0=A0=A0=A0=A0 =A0eRec.setLocationId(rs.getInt(1));=0A=A0=A0=A0=A0=A0 =A0e= Rec.setLocationName(rs.getString(2));=0A=A0=A0=A0=A0=A0 =A0eRec.setPartnerI= d(rs.getInt(3));=0A=A0=A0=A0=A0eRec.setPartnerName(rs.getString(4));=0A=A0= =A0=A0=A0eRec.setPhone1(rs.getString(5));=0A=A0=A0=A0=A0eRec.setDbphone1(rs= .getString(5));=0A=A0=A0=A0=A0eRec.setPhone2(rs.getString(6));=0A=A0=A0=A0= =A0eRec.setDbphone2(rs.getString(6));=0A=A0=A0=A0=A0eRec.setFax1(rs.getStri= ng(7));=0A=A0=A0=A0=A0eRec.setDbfax1(rs.getString(7));=0A=A0=A0=A0=A0eRec.s= etFax2(rs.getString(8));=0A=A0=A0=A0=A0eRec.setDbfax2(rs.getString(8));=0A= =A0=A0=A0=A0eRec.setAddress1(rs.getString(9));=0A=A0=A0=A0=A0eRec.setAddres= s2(rs.getString(10));=0A=A0=A0=A0=A0eRec.setCityId(rs.getInt(11));=0A=A0=A0= =A0=A0eRec.setCityName(rs.getString(12));=0A=A0=A0=A0=A0eRec.setContact1(rs= .getString(13));=0A=A0=A0=A0=A0eRec.setDbcontact1(rs.getString(13));=0A=A0= =A0=A0=A0eRec.setContact2(rs.getString(14));=0A=A0=A0=A0=A0eRec.setDbcontac= t2(rs.getString(14));=0A=A0=A0=A0=A0eRec.setEmail1(rs.getString(15));=0A=A0= =A0=A0=A0eRec.setDbemail1(rs.getString(15));=0A=A0=A0=A0=A0eRec.setEmail2(r= s.getString(16));=0A=A0=A0=A0=A0eRec.setDbemail2(rs.getString(16));=0A=A0= =A0=A0=A0eRec.setStatus(rs.getInt(17));=0A=A0=A0=A0=A0eRec.setDbstatus(rs.g= etString(17));=0A=A0=A0=A0=A0eRec.setTimeZone(rs.getString(18));=0A=A0=A0= =A0=A0eRec.setTaxRate(rs.getDouble(19));=0A=A0=A0=A0=A0eRec.setDbtaxRate(rs= .getDouble(19));=0A=A0=A0=A0=A0eRec.setStateCode(rs.getString(20));=0A=A0= =A0=A0=A0eRec.setFaxFlag(Boolean.parseBoolean(rs.getString(21)));=0A=A0=A0= =A0=A0eRec.setDbfaxFlag(Boolean.parseBoolean(rs.getString(21)));=0A=A0=A0= =A0=A0eRec.setTicklerFlag(Boolean.parseBoolean(rs.getString(22)));=0A=A0=A0= =A0=A0eRec.setTicklerFlagText(rs.getString(23));=0A=A0=A0=A0=A0eRec.setScNa= me(rs.getString(24));=0A=A0=A0=A0=A0eRec.setCopyMenuSourceId(0);=0A=A0=A0= =A0=A0=A0 =A0locations.add(eRec);=A0=A0=A0=A0=0A=A0=A0=A0=A0=A0 }=A0=A0=A0= =0A=A0=A0=0A=A0=A0} catch (Exception e) {=0A=A0=A0=A0e.printStackTrace();= =0A=A0=A0}finally {=0A=A0=A0=A0clearResources(conn, proc);=0A=A0=A0}=0A=A0= =A0return locations;=A0=A0=0A=A0}=0A=0AIf I am not including something spec= ific required to actually display a result =0Aset, can you enlighten me?=A0= How would you write a function to return a row from =0Athe test data I pro= vided?=A0 I'm stumped.=0A=0ASincerely,=0A=0AVince Maxey=0A=0A=0A=0A----- Or= iginal Message ----=0AFrom: Tom Lane =0ATo: Vince Maxey = =0ACc: pgsql-bugs@postgresql.org=0ASent: Sat, November 1= 3, 2010 1:03:46 PM=0ASubject: Re: [BUGS] BUG #5753: Existing Functions No L= onger Work=0A=0A"Vince Maxey" writes:=0A> Recently I up= graded a personal application built a number of years ago,=0A> including ja= va, eclipse, struts and postgresql and now face an issue with=0A> postgresq= l in that application functions no longer work, specfically as=0A> related = to refcursors.=A0 The original application was based on postgresql 8.4=0A> = I believe.=0A> ...=0A> But when I try to call the function: select test_pro= c(2); I get a column=0A> header: test_proc refcursor and the value in this = column is simply: portal n>, where n seems to indicate how man= y times I have run a cursor from=0A> the SQL window.=0A=0AThe example you g= ive acts exactly as I would expect, ie, it returns the=0Agenerated name of = a cursor.=A0 And it does so in every release back to at=0Aleast 8.0, not ju= st 9.0.=A0 So I think you've simplified your example to=0Athe point that it= no longer demonstrates whatever problem you're=0Aactually having.=0A=0A=A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 regards, tom lane