2014-06-06 49 views
0

繼執行功能是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上述功能我Function

 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

'LANGUAGE plpgsql' - 不要引用語言名稱(不是主q的答案)。 –

回答

0

您需要使用SELECT語句創建命令。

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

它不起作用 –

+0

@ hector怎麼這樣? –