Calling a stored procedure in Postgresql through F# and Npgsql

妖精的绣舞 提交于 2019-12-01 18:11:58

I know this question was asked along time ago, but I thought I would add a reference to the SqlProvider. This has recently had support for PostgreSQL added to it and it includes support for SPROCS.

 [<Literal>]
 let connStr = "User ID=postgres;Password=password;Host=POSTGRESQL;Port=9090;Database=hr;"

 [<Literal>]
 let resolutionFolder = @"D:\Downloads\Npgsql-2.1.3-net40\"

 type HR = SqlDataProvider<ConnectionString=connStr,DatabaseVendor=Common.DatabaseProviderTypes.POSTGRESQL, ResolutionPath = resolutionFolder>
 let ctx = HR.GetDataContext()

 ctx.Procedures.ADD_JOB_HISTORY(100, DateTime(1993, 1, 13), DateTime(1998, 7, 24), "IT_PROG", 60)


 //Support for sprocs that return ref cursors
 let employees =
     [
       for e in ctx.Functions.GET_EMPLOYEES().ReturnValue do
           yield e
     ]

Where the resolution folder points to the location of the NPGSQL .NET assemblies.

From the look at you are seeing, it looks like this is not supported somewhere between npgsql, f#, and npgsqltypes. The chance of you getting a good answer here is very low because it would require someone with a strong understanding of this language, the architecture of it, and where exactly each piece of the puzzle relies. It might also require debugging to see what is going wrong.

The previous suggestions were:

  1. Since PostgreSQL doesn't really have stored procedures per se, F# might not recognize them, and

  2. npgsqltypes might be missing some important aspects on the mapping.

I would expect that npgsql would not be where I would start looking at this because, in theory, the type provider should be able to do the lookups itself.

So I would recommend getting on relevant email lists and asking about this assuming it to be a problem with your type provider. Anyone who knows enough to troubleshoot will probably be on those email lists.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!