以下是我在Function
PostgreSQL
CREATE OR REPLACE FUNCTION funcInsert(iacid int,islno int,idate date) RETURNS int AS
$$
declare id_val int;
BEGIN
INSERT INTO GTAB83 (acid,slno,orderdte) VALUES (iacid,islno,idate) RETURNING orderid into id_val;
return id_val;
END;
$$
LANGUAGE 'plpgsql';
我使用vb.net
执行上述功能的代码是
Dim myCmd As PgSqlCommand = New PgSqlCommand("funcInsert", Myconnstr)
myCmd.CommandType = CommandType.StoredProcedure
myCmd.Parameters.Add("iacid", PgSqlType.Int).Value = cboCust.SelectedValue
myCmd.Parameters.Add("islno", PgSqlType.Int).Value = txtOrderNO.Text
myCmd.Parameters.Add("idate", PgSqlType.Int).Value = txtDate.Text
myCmd.ExecuteScalar()
trans.Commit()
错误是
答案 0 :(得分:0)
您需要使用SELECT
语句创建命令。
Dim myCmd As PgSqlCommand = New PgSqlCommand("SELECT funcInsert(@iacid, @islno, @idate)", Myconnstr)