CREATE OR REPLACE FUNCTION updateattention(dm citext)
RETURNS void AS
$BODY$
--函数体略 参数dm 的类型是citex,一个自定义的数据类型,使用它来作为函数参数或者变量的类型,在进行数据查询的时候可以不区分大小写,它的定义是:
CREATE OR REPLACE FUNCTION citext(character)
RETURNS citext AS
'rtrim1'
LANGUAGE internal IMMUTABLE STRICT
COST 1;
ALTER FUNCTION citext(character) OWNER TO postgres; 下面是调用使用C#调用updateattention存储过程的代码:
//获取PostgreSQL的数据访问对象
PWMIS.DataProvider.Data.AdoHelper db = MyDB.GetDBHelperByConnectionName("PostgreSQL");
//获取PostgreSQL的参数对象
IDataParameter para = db.GetParameter();
para.ParameterName = "@dm";
para.DbType = DbType.AnsiString;
para.Value = "KF0355";
db.ExecuteNonQuery("updateattention",
System.Data.CommandType.StoredProcedure,
new System.Data.IDataParameter[] { para }); 程序使用PDF.NET(PWMIS数据开发框架)的数据访问对象AdoHelper来进行相关的数据访问操作,它采用反射工厂模式,根据系统的配置实例化具体的数据访问类,这里使用的是PostgreSQL数据访问类。
运行该程序,出现下面的错误:
Supported data types
Npgsql supports the following data types:
Postgresql Type
NpgsqlDbType
System.DbType Enum
.Net System Type
int8
Bigint
Int64
Int64
bool
Boolean
Boolean
Boolean
Box, Circle, Line, LSeg, Path, Point, Polygon
Box, Circle, Line, LSeg, Path, Point, Polygon
Object
Object
bytea
Bytea
Binary
Byte[]
date
Date
Date
DateTime, NpgsqlDate
float8
Double
Double
Double
int4
Integer
Int32
Int32
money
Money
Decimal
Decimal
numeric
Numeric
Decimal
Decimal
float4
Real
Single
Single
int2
Smallint
Int16
Int16
text
Text
String
String
time
Time
Time
DateTime, NpgsqlTime
timetz
Time
Time
DateTime, NpgsqlTimeTZ
timestamp
Timestamp
DateTime
DateTime, NpgsqlTimestamp
timestamptz
TimestampTZ
DateTime
DateTime, NpgsqlTimestampTZ
interval
Interval
Object
TimeSpan, NpgsqlInterval
varchar
Varchar
String
String
inet
Inet
Object
NpgsqlInet, IPAddress
(there is an implicity cast operator to convert NpgsqlInet objects into IPAddress if you need to use IPAddress and have only NpgsqlInet)
bit
Bit
Boolean
Boolean, Int32
(If you use an Int32 value, odd values will be translated to bit 1 and even values to bit 0)
uuid
Uuid
Guid
Guid
array
Array
Object
Array
In order to explicitly use array type, specify NpgsqlDbType as an 'OR'ed type: NpgsqlDbType.Array | NpgsqlDbType.Integer for an array of Int32 for example.