pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how to use pgsql like mssql
4+ messages / 2 participants
[nested] [flat]

* how to use pgsql like mssql
@ 2007-12-27 00:18 liuzg2@21cn.com
  0 siblings, 0 replies; 4+ messages in thread

From: liuzg2@21cn.com @ 2007-12-27 00:18 UTC (permalink / raw)
  To: pgsql-sql

<br>
<br><pre wrap="">in the pgadmin edit<br>i want use<br>declare  ...<br>if exists ...<br>insert something if @@rowcout&gt;0 then do something<br>if ....<br>like in mssql and not use function<br>how to<br>sorry for my english</pre><br><br><br><br><span id="spnSignFirst"></span><span id="spnSign"></span><br><br><iframe name=mail001 marginwidth=0 marginheight=0 src="http://news.21cn.com/shtml.21cn.com/2007/11/13/mail_bottom.html"; width=90% scrolling=no height=50 designtimesp="1840" frameborder="0"></iframe>
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 <pgsql-sql-postgresql.org@postgresql.org>; 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 <pgsql-sql-postgresql.org@postgresql.org>;
 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 <pgsql-sql@postgresql.org>; 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 <rabroersma@yahoo.com>
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 <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.




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how to use pgsql like mssql
@ 2007-12-27 02:05 liuzg2@21cn.com
  2007-12-27 04:54 ` Re: how to use pgsql like mssql Pavel Stehule <pavel.stehule@gmail.com>
  2007-12-27 04:55 ` Re: how to use pgsql like mssql Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: liuzg2@21cn.com @ 2007-12-27 02:05 UTC (permalink / raw)
  To: pgsql-sql

<br>
<br>but&nbsp; i do not&nbsp;&nbsp; want use function&nbsp; or&nbsp; procedure&nbsp; <br><br>wish this features<br><br><br><span id="spnSignFirst"></span><span id="spnSign"></span><br><br><iframe name=mail001 marginwidth=0 marginheight=0 src="http://news.21cn.com/shtml.21cn.com/2007/11/13/mail_bottom.html"; width=90% scrolling=no height=50 designtimesp="1840" frameborder="0"></iframe>
From pgsql-sql-owner@postgresql.org  Wed Dec 26 22:35:24 2007
Received: from localhost (unknown [200.46.204.184])
	by postgresql.org (Postfix) with ESMTP id 2C2792E0153
	for <pgsql-sql-postgresql.org@postgresql.org>; Wed, 26 Dec 2007 22:35:19 -0400 (AST)
Received: from postgresql.org ([200.46.204.71])
 by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024)
 with ESMTP id 54870-04 for <pgsql-sql-postgresql.org@postgresql.org>;
 Wed, 26 Dec 2007 22:35:05 -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 0433C2E0174
	for <pgsql-sql@postgresql.org>; Wed, 26 Dec 2007 22:35:13 -0400 (AST)
Received: (qmail 38447 invoked by uid 60001); 27 Dec 2007 02:35:12 -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=llmjoOS7WCYllBvh7vjZS3PpUl08v/fuO2xjer5gtW/V02S9FhloDMcVJIS0gUZj7iyJ4ZRXWhTdXLwy7LtJJS5dT6C5r5oAYsWAMSg6MAFYZU8nSoSZl6JfS2FZxJqdNJ6i9USOQUy5hx1PVi8yirdFev/g4brdiqU8MWY2P0Y=;
X-YMail-OSG: IQ4D6YsVM1mz6ArfuSqYGKWc9DWpzOzS3PhHC3LK0GNHuSvLgcbEcniubb49_iv0JzmmMsRfZQ--
Received: from [75.84.89.248] by web31812.mail.mud.yahoo.com via HTTP; Wed, 26 Dec 2007 18:35:12 PST
X-Mailer: YahooMailWebService/0.7.162
Date: Wed, 26 Dec 2007 18:35:12 -0800 (PST)
From: Richard Broersma Jr <rabroersma@yahoo.com>
Subject: Re: how to use pgsql like mssql
To: "pgsql-sql@postgresql.org" <pgsql-sql@postgresql.org>, liuzg2@21cn.com
In-Reply-To: <30781358.9441198721119056.JavaMail.root@webmail5>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Message-ID: <536502.37602.qm@web31812.mail.mud.yahoo.com>
X-Virus-Scanned: Maia Mailguard 1.0.1
X-Archive-Number: 200712/141
X-Sequence-Number: 29833

--- On Wed, 12/26/07, liuzg2@21cn.com <liuzg2@21cn.com> wrote:

> but  i do not   want use function  or  procedure  


Are you sure?  I thought that:

DECLARE
IF --control structures
@@rowcount

where only usable in a store procedure.  Am I incorrect, or are these keywords accessible from the SQL prompt?

Regards,
Richard Broersma Jr.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how to use pgsql like mssql
  2007-12-27 02:05 Re: how to use pgsql like mssql liuzg2@21cn.com
@ 2007-12-27 04:54 ` Pavel Stehule <pavel.stehule@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Pavel Stehule @ 2007-12-27 04:54 UTC (permalink / raw)
  To: Richard Broersma Jr <rabroersma@yahoo.com>; +Cc: pgsql-sql; liuzg2@21cn.com

On 27/12/2007, Richard Broersma Jr <rabroersma@yahoo.com> wrote:
> --- On Wed, 12/26/07, liuzg2@21cn.com <liuzg2@21cn.com> wrote:
>
> > but  i do not   want use function  or  procedure
>
>
> Are you sure?  I thought that:
>
> DECLARE
> IF --control structures
> @@rowcount
>
> where only usable in a store procedure.  Am I incorrect, or are these keywords accessible from the SQL prompt?
>

You can use outside procedure in T-SQL.

Pavel

> Regards,
> Richard Broersma Jr.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org
>



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: how to use pgsql like mssql
  2007-12-27 02:05 Re: how to use pgsql like mssql liuzg2@21cn.com
@ 2007-12-27 04:55 ` Pavel Stehule <pavel.stehule@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Pavel Stehule @ 2007-12-27 04:55 UTC (permalink / raw)
  To: liuzg2@21cn.com <liuzg2@21cn.com>; +Cc: pgsql-sql

Hello

On 27/12/2007, liuzg2@21cn.com <liuzg2@21cn.com> wrote:
>
>
> but  i do not   want use function  or  procedure
>
> wish this features
>

PostgreSQL doesn't support this feature. You can use procedural
construct only in functions.

Regards
Pavel Stehule

>
>
>
>



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2007-12-27 04:55 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-12-27 00:18 how to use pgsql like mssql liuzg2@21cn.com
2007-12-27 02:05 Re: how to use pgsql like mssql liuzg2@21cn.com
2007-12-27 04:54 ` Pavel Stehule <pavel.stehule@gmail.com>
2007-12-27 04:55 ` Pavel Stehule <pavel.stehule@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox