通过代码执行功能时显示语法错误

时间:2014-06-06 15:49:57

标签: vb.net postgresql ado.net

以下是我在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()

错误是

enter image description here

1 个答案:

答案 0 :(得分:0)

您需要使用SELECT语句创建命令。

Dim myCmd As PgSqlCommand = New PgSqlCommand("SELECT funcInsert(@iacid, @islno, @idate)", Myconnstr)