Convert Dynmaic SQL from MS SQL procedure to PostgreSQL PL/pgsql function

Started by annachauover 23 years ago1 messagesgeneral
Jump to latest
#1annachau
annachau@hongkong.com

I have some problems on MS SQL procedure convert to PostgreSQL PL/pgsql function. Please give me some advice. Can I dynmaic declare cursor out of DECLARATION block and in STATEMENTS BLOCK?

I have many procedure in MS SQL which run dynmaic SQL Example:

if (UPPER(@DBTableName) = 'OT_APPLNCUSTOMER' or UPPER(@DBTableName) = 'OT_APPLTADDRTBL' )

begin
Set @SQLStm = 'Declare Cur_Temp_Attribute Cursor ' +
'For select ' + @DBTableField + ' From ' +
@DBTableName +
' Where APPln_Ref_No = ' + '''' + @Appln_Ref_No + ''''
end
else
begin
Set @SQLStm = 'Declare Cur_Temp_Attribute Cursor ' +
'For select ' + @DBTableField + ' From ' +
@DBTableName +
' Where identity_no = ' + '''' + @identity_no + ''''

end
exec(@SQLstm)
Open Cur_Temp_Attribute

------

Thank you very much.