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 1038210444.279.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: "annachau"
Date:
Subject: Please Help on MS SQL7.0 Procedure to PostgreSQL
Next
From: Stephan Szabo
Date:
Subject: Re: Calculated fileds in pg