Обсуждение: Changing PL/pgSQL triggers
Hi,
What's the easiest way to modify or view a function written in PL/pgSQL? I've been using pg_dump to get the original function, then dropping and creating the function and trigger after making a change. Is there an easier way?
-James
On Thu, Jun 21, 2001 at 01:30:39PM -0400, James Orr wrote: > Hi, > > What's the easiest way to modify or view a function written in PL/pgSQL? I've been using pg_dump to get the original function,then dropping and creating the function and trigger after making a change. Is there an easier way? pgAcess should make it easier. It lets you look at the definition and lets you modify/drop/recreate it.If you're on windows, you might want to look a pgAdmin (available at greatbridge.org). -Roberto -- +----| http://fslc.usu.edu USU Free Software & GNU/Linux Club |------+ Roberto Mello - Computer Science, USU - http://www.brasileiro.net http://www.sdl.usu.edu - Space Dynamics Lab, Developer *> - | <- Tribble Archery
James, > What's the easiest way to modify or view a function written in > PL/pgSQL? I've been using pg_dump to get the original function, then > dropping and creating the function and trigger after making a change. > Is there an easier way? Well, if you're on Win32 or on Linux, you can install PGAccess (link from postgresql.org). PGAccess has an OK function editor, although it doesn't support cut-and-paste on Xwindows and I've found a few bugs with large and complex functions. Me, I write lots and lots of PL/pgSQL functions. I've found the easiest way to be (I'm on SuSE 7.0/KDE2.1): 1. Create text file, and write and edit function in KEdit. 2. Save text file. 3. Load function using \i in PSQL. 4. Test function. FInd bug(s). 5. Re-edit function using Kedit. Add DROP FUNCTION command at beginning. 6. Re-load function using \i in PSQL. 7. Repeat from 4 until function is debugged. It sounds like a lot of steps, but really it goes quickly. Plus it allows you to save lots of intermediate versions of functions. -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete informationtechnology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco
Greetings, On Thu, 21 Jun 2001, Josh Berkus wrote: >> What's the easiest way to modify or view a function written in >> PL/pgSQL? I've been using pg_dump to get the original function, then >> dropping and creating the function and trigger after making a change. >> Is there an easier way? > Well, if you're on Win32 or on Linux, you can install PGAccess (link > from postgresql.org). PGAccess has an OK function editor, although it > doesn't support cut-and-paste on Xwindows and I've found a few bugs with > large and complex functions. One if the 'features' missing in PGAccess (at least, on the version found in the 'ports-tree' of FreeBSD 4.1) is a simple 'save-without-quit' function. When you're editing a function; and you do save, the windows closes. So, you do some debugging, you find a bug; and you need to re-open the function. Usually (on my workstation), the windows pops up at the wrong place of the screen; and I usually need to do some 'resizing' to get the window in the shape I like. Cheerio! Kr. Bonne -- KB905-RIPE Belgacom IP networking (c=be,a=rtt,p=belgacomgroup,s=Bonne,g=Kristoff) Internet, IP and IP/VPN kristoff.bonne@skypro.be Faxbox : +32 2 2435122
pgAdmin does not let you modify the pl/pgsql triggers. I use PowerDesigner 7.5 to manage Postgresql physical data models and I edit all pl/pgsql triggers and functions through that tool. It's not free but it's the only one I know that I can Design and Generate Databases ranging from DB2 and Oracle to Postgresql and MySQL. Other than that, a simple text editor would do for triggers. ""James Orr"" <james@lrgmail.com> wrote in message news:004d01c0fa77$f64f0580$1600000a@lrg.office... > This is a multi-part message in MIME format. > > ------=_NextPart_000_004A_01C0FA56.5C956540 > Content-Type: text/plain; charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > Hi, > > What's the easiest way to modify or view a function written in PL/pgSQL? I= > 've been using pg_dump to get the original function, then dropping and crea= > ting the function and trigger after making a change. Is there an easier wa= > y? > > -James > > ------=_NextPart_000_004A_01C0FA56.5C956540 > Content-Type: text/html; charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> > <HTML><HEAD> > <META http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1"> > <META content=3D"MSHTML 5.50.4616.200" name=3DGENERATOR> > <STYLE></STYLE> > </HEAD> > <BODY bgColor=3D#ffffff> > <DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV> > <DIV><FONT face=3DArial size=3D2></FONT> </DIV> > <DIV><FONT face=3DArial size=3D2>What's the easiest way to modify or view a= > function=20 > written in PL/pgSQL? I've been using pg_dump to get the original func= > tion,=20 > then dropping and creating the function and trigger after making a change.&= > nbsp;=20 > Is there an easier way?</FONT></DIV> > <DIV><FONT face=3DArial size=3D2></FONT> </DIV> > <DIV><FONT face=3DArial size=3D2>-James</FONT></DIV></BODY></HTML> > > ------=_NextPart_000_004A_01C0FA56.5C956540-- >