It is know that SQL Server offers some extensibility mechanisms like user-defined functions, stored procedures, triggers...
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 exec dbo.SP_Analysis 'MyTable','Colum1,Column2',300,0
command is used to get the results in SQL Server 2008) defined as:
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
}
}
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.
Now my question is what is the analog to all this in Postgres?
- What language is available to extend the functionality of Postgres?
- What is the analog of Visual Studio to have the possibility to deploy a UDF in Postgres?
- What is the analog of
exec dbo.UDF
in Postgres?
I was reading that Postgres uses C language to define UDFs maybe C++ but the others I have no idea...