Skip site navigation (1) Skip section navigation (2)

MS-SQL to PostgreSql

From: Rehan Saleem <pk_rehan(at)yahoo(dot)com>
To: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: MS-SQL to PostgreSql
Date: 2012-03-26 07:49:07
Message-ID: 1332748147.44735.YahooMailNeo@web121604.mail.ne1.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-sql
hi,
i am trying to convert this mssql store procedure to postgresql function but it is not giving me the desired output ,this function is returning a table and you dont need to worry about what it is returning all i concern the body part of the function how to transform the ms-sql code into postgresql code,  i shall be very thankful  if some one convert this procedure into function, 

ALTER PROCEDURE [dbo].[sp_GetSitesByTFID]
@UserDataDetailId varchar(50), 
@KBId  varchar(50),
@bpOverlap varchar(50),
@Chr varchar(50),
@CentreDistance varchar(50)='',
@TotalMatched varchar(50) output
AS
BEGIN

DECLARE @sql nvarchar(500);


if (@CentreDistance='')
set @CentreDistance = 1
set @sql = 'select Chr_U, Start_U, End_U, RegionSize_U, Chr_KB, Start_KB, End_KB, RegionSize_KB, '
set @sql += ' bpOverlap, CentreDistance from vwChrCompareSiteswhere UserDataDetailId=' + @UserDataDetailId  
set @sql += ' and bpOverlap>=' + @bpOverlap 
set @sql += ' AND KBId=' + @KBId 
if @Chr<>'All' and ISNULL(@Chr,'')<>''
set @sql += ' AND Chr_U=''' + @Chr  +''''
if (@CentreDistance<>'') 
set @sql += ' AND (CentreDistance<=' + @CentreDistance + ' or ' + @CentreDistance + '=1) '
set @sql += ' Order by  Chr_U, Start_U'

exec(@sql)
set @TotalMatched = @@ROWCOUNT
END

Responses

pgsql-sql by date

Next:From: Rehan SaleemDate: 2012-03-26 10:01:09
Subject: Postgresql function with temporary tables
Previous:From: Allan KamauDate: 2012-03-24 13:42:59
Subject: Re: how to concatenate in PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group