如何执行从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