Skip to content

Commit 1f0a19c

Browse files
committed
The enclose patch clarifies and makes a more useful example for the
Global Values in PL/Perl section of the documents. David Fetter
1 parent 3d20578 commit 1f0a19c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

doc/src/sgml/plperl.sgml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.26 2004/07/21 20:44:52 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.27 2004/08/18 03:37:56 momjian Exp $
33
-->
44

55
<chapter id="plperl">
@@ -317,23 +317,25 @@ $$ LANGUAGE plperl;
317317
<sect1 id="plperl-global">
318318
<title>Global Values in PL/Perl</title>
319319
<para>
320-
You can use the %_SHARED to store data between function calls. WHY
321-
IS THIS A HASH, AND NOT A HASH REF?
320+
You can use the %_SHARED to store data between function calls.
322321
</para>
323322
<para>
324323
For example:
325324
<programlisting>
326-
CREATE OR REPLACE FUNCTION set_var(TEXT) RETURNS TEXT AS $$
327-
$_SHARED{first} = 'Hello, PL/Perl!';
328-
return 'ok';
325+
CREATE OR REPLACE FUNCTION set_var(name TEXT, val TEXT) RETURNS TEXT AS $$
326+
if ($_SHARED{$_[0]} = $_[1]) {
327+
return 'ok';
328+
} else {
329+
return "Can't set shared variable $_[0] to $_[1]";
330+
}
329331
$$ LANGUAGE plperl;
330332

331-
CREATE OR REPLACE FUNCTION get_var() RETURNS text AS $$
332-
return $_SHARED{first};
333+
CREATE OR REPLACE FUNCTION get_var(name TEXT) RETURNS text AS $$
334+
return $_SHARED{$_[0]};
333335
$$ LANGUAGE plperl;
334336

335-
SELECT set_var('hello plperl');
336-
SELECT get_var();
337+
SELECT set_var('sample', $q$Hello, PL/Perl! How's tricks?$q$);
338+
SELECT get_var('sample');
337339
</programlisting>
338340

339341
</para>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy