Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f0a19c

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 parent3d20578 commit1f0a19c

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)

[8]ページ先頭

©2009-2025 Movatter.jp