如何執行從VBA代碼存儲在PostgreSQL中的名爲Test1
的函數?如何從VBA代碼執行PostgreSQL函數?
例如,我們有一個函數定義如下:
CREATE OR REPLACE FUNCTION "public"."Test1" (
)
RETURNS bit AS
$body$
BEGIN
INSERT INTO test ("name") VALUES ('1');
RETURN 1;
END;
$body$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
現在我試圖執行這個功能是這樣的:
Function TestCall()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim strSQl As String
strSQl = "SELECT * FROM Test1();"
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQl, dbOpenDynaset, dbSeeChanges)
'this doesnt work as well: syntax error'
dbs.Execute strSQl
If Not (rst.BOF And rst.EOF) Then
do some work here
End If
End Function
但我發現了Syntax Error near FROM
。我不知道如何去執行,怎麼辦?
你絕對沒錯。這是正確的一點。 – Dariusz 2010-10-05 13:40:33