Convert Dynmaic SQL from MS SQL procedure to PostgreSQL PL/pgsql function - Mailing list pgsql-general

From annachau
Subject Convert Dynmaic SQL from MS SQL procedure to PostgreSQL PL/pgsql function
Date
Msg-id 1037894307.10065.annachau@hongkong.com
Whole thread Raw
List pgsql-general
I have some problems on MS SQL procedure convert to PostgreSQL PL/pgsql function. Please give me some advice.  Can I
dynmaicdeclare 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.

pgsql-general by date:

Previous
From: "Mihai Gheorghiu"
Date:
Subject: Migrating data from MSAccess
Next
From: "Ron St.Pierre"
Date:
Subject: 7.3RC1 ?? Re: PostgreSQL compilation with custom table name length