×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Importing SQL Server Stored Procedure into PostgreSQL

Importing SQL Server Stored Procedure into PostgreSQL

Importing SQL Server Stored Procedure into PostgreSQL

(OP)
Very Difficult To Import SQL Server Stored Procedure

We are in the process of importing a SQL Server database, We could transfter the data tables, but it is a huge challenge to actually rewrite all the stored procedures and they way data is returned. After browsing lots of sites and books, I did not come across how to write a stored procedure in Postgre SQL, We have to write it using a Function. Within Microsoft SQL Server, I can just write a procedure to return a resultset based on various parameters.

In POSTGRESQL I have to create a composite type that defines what columns need to be retrieved and return the data using composite type and again I have to select the data from the function. I have around 500 Stored Procedures, It is a real showstopper for my conversion.

Is there any better way to do this.

I am just posting the stored procedure in SQL Server. Can somebody help me how to achieve this in Postgre SQL.

ALTER PROC [dbo].[uspGetChildForumCategories]
(
@CompanyId int,
@SiteId int,
@DepartmentId int)

AS
BEGIN

SET NOCOUNT ON;

Set @DepartmentId = NULLIF(0, NULL)

If @DepartmentId Is Not Null
Begin
Select ForumCategoryId,
ForumCategoryName,
Count(*) Over() as RecordCount
From tblForumCategory WITH (NOLOCK)
Where ForumCategoryParentId <> 0
And SiteId = @SiteId
And CompanyId = @CompanyId
And DepartmentId = @DepartmentId
End
Else
If @DepartmentId Is Null
Begin
Select ForumCategoryId,
ForumCategoryName,
Count(*) Over() as RecordCount
From tblForumCategory WITH (NOLOCK)
Where ForumCategoryParentId <> 0
And SiteId = @SiteId
And CompanyId = @CompanyId
End


SET NOCOUNT OFF;

END

If I cannot do the above, how come Postgre SQL is so popular. Is it popular just because it is open source and free of cost.

Really Interesting.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close