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