Search Postgresql Archives

Looking for information on PostgreSQL Stored Procedures

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This could be an old conversation for most.  I've used PostgreSQL for a
while but I haven't fully use the Procedure/Functions to it fullest
until now.  I need to migrate a MS-SQL 2000 database to PostgreSQL.
I've read as much as I could find but I seem to be missing something.

I did see last week something on PLPGSQL and read through that.  But
there has to be something out there that goes in depth on the
SQL/Function command set(Speaking of functions/procedures).

The biggest hole that I have; seems to be on Cursors; define and
opening.  I think the fetching and closing is pretty straight forward.
But the Define and opening is causing some grief.  Either I'm making to
far too hard or I'm really have missing something silly.

Simple example in MS-2000:

CREATE PROCEDURE dbo.sp_RemoveDups AS
SET NOCOUNT ON
DECLARE @err int, @LastName varchar(255), @Name varchar(255), @id
bigint, @LineNum bigint
DECLARE NewListCursor CURSOR LOCAL FAST_FORWARD FOR
	SELECT	Name, id
	FROM	MailingList
	ORDER BY id
OPEN NewListCursor
SELECT @LineNum = 0
SELECT @LastName = ""
FETCH NEXT FROM NewListCursor INTO @Name, @id
WHILE (@@FETCH_STATUS = 0)
	BEGIN
		SELECT @LineNum = @LineNum + 1
		IF @LastName = @Name
			DELETE FROM MailingList WHERE id = @id
		SELECT @LastName = @Name
		FETCH NEXT FROM NewListCursor INTO @LastName, @id
	END
CLOSE NewListCursor
DEALLOCATE NewListCursor
RETURN (0)
GO

This is an example of the simple stored procedures like the ones I'm
trying to migrate.  PLPGSQL is ok but I thought it would run better in
SQL.  Just not C, Perl or TK/TCL.  Those are not being used with this
application and no plans to use them in the future.

Thanks for any help;

Lee Foster 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date:
12/9/2005
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux