这是一个简单的查询,可以预期输出。
Private Sub ShowInfo(InfoText As String)
' code to query info and show in seperate window
' make sure window doesn't get focus
' I prefer to use non editable text boxes in my main window
Me.TextBox1 = InfoText
End Sub
Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ShowInfo "Mouse is over Label1"
End Sub
Private Sub Label2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ShowInfo "Mouse is over Label2"
End Sub
Private Sub Label3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
ShowInfo "Mouse is over Label3"
End Sub
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
' this is the exit code
' as here we left all labels
ShowInfo "Mouse is not on a label"
End Sub
这里将相同的查询放在函数中。
select 1.1 as x, 1.1 as y;
x | y
-----+-----
1.1 | 1.1
(1 row)
这是输出:
CREATE OR REPLACE FUNCTION foo4(param integer)
RETURNS TABLE(x float, y float) AS
$$
DECLARE var float;
BEGIN
var = 1.1;
RETURN QUERY select var as x, var as y;
END;
$$
LANGUAGE 'plpgsql';
为什么函数以不同方式输出数据?如何将函数输出分为两列?
使用PostgreSQL 10.3和Windows 7/10。
答案 0 :(得分:2)
select * from foo4(4);
应该会为您提供所需的结果。
答案 1 :(得分:0)
试试RETURN QUERY EXECUTE
。这将导致查询是动态的而不是静态的。 https://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#AEN63012