title: Postgres analog for c# SQL Server´s stored procedure CLR
body: <p>It is know that SQL Server offers some extensibility mechanisms like user-defined functions, stored procedures, triggers...</p>
  
  <p>I have C# code that runs in SQL Server 2008 (it is a stored procedure that is deployed in the DBMS using Visual Studio 2008, and then a <code>exec dbo.SP_Analysis 'MyTable','Colum1,Column2',300,0</code> command is used to get the results in SQL Server 2008) defined as:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Text;
  using System.Security;
  using System.Runtime.InteropServices;
  using System.Data;
  using System.Data.SqlClient;
  using System.Data.SqlTypes;
  using Microsoft.SqlServer.Server;
  
  public partial class StoredProcedures
  {              
    [Microsoft.SqlServer.Server.SqlProcedure]
    public static void SP_Analysis(
       SqlString table, [SqlFacet(MaxSize = -1)] SqlString columns,
       int Nocustomers,
       Boolean result)
    {
       String query = "";
  
       using (SqlConnection conn = new SqlConnection("context connection=true"))
       {
          conn.Open();
          SqlCommand cmd = conn.CreateCommand();
          query = "SELECT " + (String)columns + " FROM " + (String)table + ";";
          cmd.CommandText = query;
          SqlDataReader reader = cmd.ExecuteReader();
          MyObject _myObject = new Object(Nocustomers);
          while (reader.Read())
             _myObject.read(reader);
          reader.Close();        
          conn.Close();
        } //END SqlConnection conn 
    }        
  }
  
  class MyObject
  {
     int NoCustomers; 
     //some definitions
  
    public MyObject(int NoCustomers)
    {
       this.NoCustomers = NoCustomers;
       //some stuff
    }
  
     public void read(SqlDataReader reader)
     {
       Object[] record = new Object[NoCustomers];
       reader.GetValues(record);
       //more stuff
     }
  }
  </code></pre>
  
  <p>It is clear that I am using .NET c# available language and then deploy it to create a stored procedure in SQL Server 2008, via Visual Studio 2008.</p>
  
  <p>Now my question is what is the analog to all this in Postgres?</p>
  
  <ol>
  <li>What language is available to extend the functionality of Postgres? </li>
  <li>What is the analog of Visual Studio to have the possibility to deploy a UDF in Postgres? </li>
  <li>What is the analog of <code>exec dbo.UDF</code> in Postgres?</li>
  </ol>
  
  <p>I was reading that Postgres uses C language to define UDFs maybe C++
  but the others I have no idea...</p>