Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 223AB2E011E for ; Wed, 26 Dec 2007 20:18:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 05348-10 for ; Wed, 26 Dec 2007 20:18:30 -0400 (AST) Received: from 21cn.com (send.forptr.21cn.com [202.105.45.50]) by postgresql.org (Postfix) with SMTP id 881BA2E011A for ; Wed, 26 Dec 2007 20:18:30 -0400 (AST) Received: from 21cn.com([59.36.102.12]) by 21cn.com(AIMC 3.1.0.0) with SMTP id jm144773633a; Thu, 27 Dec 2007 08:21:38 +0800 Received: from asgw3-web (dgproxy3.inner-hermes.com [10.27.2.3]) by 21cn.com (HERMES) with ESMTP for ; Thu, 27 Dec 2007 08:18:27 +0800 (CST) Received: from webmail1([10.27.6.1]) by asgw3-web(Knowledge-based Antispam Gateway 2.126i5n(2007-12-23)) with ESMTP id mx28263.1198714707 for ; Thu, 27 Dec 2007 08:18:27 +0800 X-Original-MailFrom: liuzg2@21cn.com Message-ID: <32397810.2081198714707668.JavaMail.root@webmail1> Date: Thu, 27 Dec 2007 08:18:27 +0800 (CST) From: liuzg2@21cn.com To: pgsql-sql@postgresql.org Subject: how to use pgsql like mssql MIME-Version: 1.0 HMM_WEBCLN_IP: 220.168.73.4 X-AIMC-AUTH: (null) X-AIMC-MAILFROM: liuzg2@21cn.com X-AIMC-Msg-ID: 45Q5gHTB X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=4.295 tagged_above=0 required=5 tests=BAYES_50=0.001, FH_HAS_XAIMC=2.696, HTML_IFRAME_SRC=0.043, HTML_MESSAGE=0.001, HTML_MIME_NO_HTML_TAG=0.097, MIME_HTML_ONLY=1.457 X-Spam-Level: **** Content-Type: text/html;charset=UTF-8 Content-Transfer-Encoding: 7bit X-Archive-Number: 200712/138 X-Sequence-Number: 29830

in the pgadmin edit
i want use
declare ...
if exists ...
insert something if @@rowcout>0 then do something
if ....
like in mssql and not use function
how to
sorry for my english






From pgsql-sql-owner@postgresql.org Wed Dec 26 21:10:06 2007 Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id E07D92E0120 for ; Wed, 26 Dec 2007 21:09:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 48730-08 for ; Wed, 26 Dec 2007 21:09:36 -0400 (AST) Received: from web31812.mail.mud.yahoo.com (web31812.mail.mud.yahoo.com [68.142.207.75]) by postgresql.org (Postfix) with SMTP id 8F0D32E0118 for ; Wed, 26 Dec 2007 21:09:41 -0400 (AST) Received: (qmail 80108 invoked by uid 60001); 27 Dec 2007 01:09:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Message-ID; b=BQHkVrUyiGu5rHNCDoh8olG9EDDMQdh82uxRwP5Y3fxGhCtxfogW0NpnhZgPZTqcapNZgs0Npyr8MqqetqWAjucjOT5t1B+ilcM0p9SoAFE4D8m2Mm9J7bHlxfhmTZ0jeKlZTGv1Ai2iK8OQsQyeMZrCkx4VaJ8A/nyrYgTwjgQ=; X-YMail-OSG: bDmEMBAVM1nYNv65tRePQXSziYXN9idS023faEEbU6tZ2VMjTlDVWxPSBbBYc4BYtPsDHdu3Uh8tOgpu2iz371oxE19mHAyMjMn_wjL8hkTcp5pvz_8sjLTQdeO68w-- Received: from [75.84.89.248] by web31812.mail.mud.yahoo.com via HTTP; Wed, 26 Dec 2007 17:09:39 PST X-Mailer: YahooMailWebService/0.7.162 Date: Wed, 26 Dec 2007 17:09:39 -0800 (PST) From: Richard Broersma Jr Subject: Re: how to use pgsql like mssql To: pgsql-sql@postgresql.org, liuzg2@21cn.com In-Reply-To: <32397810.2081198714707668.JavaMail.root@webmail1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <695505.80013.qm@web31812.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/139 X-Sequence-Number: 29831 --- On Wed, 12/26/07, liuzg2@21cn.com wrote: > in the pgadmin edit > i want use > declare ... > if exists ... > insert something if @@rowcout>0 then do something > if .... > like in mssql and not use function I take it that you are looking to create stored procedures? In postgresql they are called "stored functions" or more correctly "functions." First you will need to load a procedural language into your database if one isn't already installed. http://www.postgresql.org/docs/8.2/interactive/sql-createlanguage.html You should probably use PLpgSQL since it is available across OS all platforms and is easy to learn and use. http://www.postgresql.org/docs/8.2/interactive/plpgsql.html There are some nice examples in this documentation. Your PGadmin will also have features to help the create these functions also. Regards, Richard Broersma Jr.