Postgres stored procedures

Status
Not open for further replies.

KarlShea

Ars Tribunus Militum
2,277
Subscriptor++
Can I return multiple columns and rows with Postgres stored procedures?

Example:
code:<HR>
Code:
CREATE PROCEDURE dbo.getStyle @name VARCHAR(255) AS
 
SELECT styleID,css,description,formalName,page FROM styles
WHERE name = @name
GO

This works with sql server 2000 but we want to move to unix and want to know if this is going to work.
 

dmcnaught

Ars Scholae Palatinae
684
The example above (MikeApp's) is for the SQL embedded language, which is very limited.

Most people use PL/pgSQL (which is a lot like Oracle's PL/SQL) for user-defined functions. Unfortunately, you can't return a recordset directly from a PL/pgSQL function. What you can do (as of version 7.2 which just came out) is return an open cursor, which lets you do the same stuff--the syntax is a little different.

BTW, if you want migration help, look on tecdocs.postgresql.org--there's some info there on migrating from MS SQL Server. Also, the PG mailing lists are by far the best place to get help--they're truly excellent.
 
Status
Not open for further replies.