EXECUTing QUERY: - Mailing list pgsql-sql

From Sumita Biswas
Subject EXECUTing QUERY:
Date
Msg-id 003501c3f9e7$a8699840$2a154d0a@apac.cisco.com
Whole thread Raw
In response to Re: Postgres DB  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
I had the following code in an MSSQL Stored Procedure:
SET @QueryToPopulateTemp= "INSERT INTO
#Tmp_Conference(ConferenceType, CallManagerId, ClusterId,
DestConversationId, ConnectDate, FinalDestination)"        +" SELECT 1, Global_CallId_CallManagerId,
globalCallId_ClusterID, DestConversationID, StartDate = MIN
(Connect_Date), Final_Destination "        +" FROM Tbl_Billing_Data WHERE (connect_date
BETWEEN '"+        cast(@ld_FromDate as NVARCHAR) +"' AND '"+           cast(@ld_ToDate as NVARCHAR) +"' OR
disconnect_date BETWEEN '"+            cast(@ld_FromDate as NVARCHAR)+"' AND
'"+cast(@ld_ToDate as NVARCHAR)+"')  AND DestConversationID <> 0 AND
Call_Type='" + @lv_Adhoc_Conf + "'"        +" GROUP BY Global_CallId_CallManagerId,
globalCallId_ClusterID, DestConversationID, Final_Destination order by
startdate";            EXEC sp_executesql @QueryToPopulateTemp;

------------------------------------------------------------------------
-------------------------------------------------

I have changed it to the following in the Postgres Function:

QueryToPopulateTemp := ''INSERT INTO Tmp_Conference(ConferenceType,
CallManagerId, ClusterId, DestConversationId, ConnectDate,
FinalDestination)''        +'' SELECT 1, Global_CallId_CallManagerId,
globalCallId_ClusterID, DestConversationID, StartDate = MIN
(Connect_Date), Final_Destination ''        +'' FROM Tbl_Billing_Data WHERE (connect_date
BETWEEN ''''+        cast(ld_FromDate as NVARCHAR) +'''' AND ''''+        cast(ld_ToDate as NVARCHAR) +'''' OR
disconnect_date BETWEEN ''''+        cast(ld_FromDate as NVARCHAR)+'''' AND
''''+cast(ld_ToDate as NVARCHAR)+'''')  AND DestConversationID <> 0 AND
Call_Type='''' + lv_Adhoc_Conf + ''''''        +'' GROUP BY Global_CallId_CallManagerId,
globalCallId_ClusterID, DestConversationID, Final_Destination order by
startdate'';
    PERFORM QueryToPopulateTemp;


------------------------------------------------------------------------
-------------------------------------------------

Does this look fine?

Regards,
Sumita



pgsql-sql by date:

Previous
From: "Sumita Biswas"
Date:
Subject: DATEADD
Next
From: "Sumita Biswas"
Date:
Subject: Re: Postgres DB