aboutsummaryrefslogtreecommitdiff
path: root/src/pl/plperl/expected/plperl_call.out
blob: c55c59cbceb3b8280a8174e5c199ebaaf91fa452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
CREATE PROCEDURE test_proc1()
LANGUAGE plperl
AS $$
undef;
$$;
CALL test_proc1();
CREATE PROCEDURE test_proc2()
LANGUAGE plperl
AS $$
return 5
$$;
CALL test_proc2();
CREATE TABLE test1 (a int);
CREATE PROCEDURE test_proc3(x int)
LANGUAGE plperl
AS $$
spi_exec_query("INSERT INTO test1 VALUES ($_[0])");
$$;
CALL test_proc3(55);
SELECT * FROM test1;
 a  
----
 55
(1 row)

-- output arguments
CREATE PROCEDURE test_proc5(INOUT a text)
LANGUAGE plperl
AS $$
my ($a) = @_;
return { a => "$a+$a" };
$$;
CALL test_proc5('abc');
    a    
---------
 abc+abc
(1 row)

CREATE PROCEDURE test_proc6(a int, INOUT b int, INOUT c int)
LANGUAGE plperl
AS $$
my ($a, $b, $c) = @_;
return { b => $b * $a, c => $c * $a };
$$;
CALL test_proc6(2, 3, 4);
 b | c 
---+---
 6 | 8
(1 row)

DROP PROCEDURE test_proc1;
DROP PROCEDURE test_proc2;
DROP PROCEDURE test_proc3;
DROP TABLE test1;