how to use pgsql like mssql

Поиск
Список
Период
Сортировка
Искать

how to use pgsql like mssql

От:
liuzg2@21cn.com
Дата:


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






Re: how to use pgsql like mssql

От:
Richard Broersma Jr <rabroersma@yahoo.com>
Дата:
--- 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.


Re: how to use pgsql like mssql

От:
liuzg2@21cn.com
Дата:


but  i do not   want use function  or  procedure 

wish this features




Re: how to use pgsql like mssql

От:
Richard Broersma Jr <rabroersma@yahoo.com>
Дата:
--- On Wed, 12/26/07, 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.

Re: how to use pgsql like mssql

От:
"Pavel Stehule" <pavel.stehule@gmail.com>
Дата:
On 27/12/2007, Richard Broersma Jr  wrote:
> --- On Wed, 12/26/07, 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
>

Re: how to use pgsql like mssql

От:
"Pavel Stehule" <pavel.stehule@gmail.com>
Дата:
Hello

On 27/12/2007, 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

>
>
>
>

FAQ