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

Commit871e73b

Browse files
committed
Reformat code examples in plpgsql docs for better readability in PDF output
Erik Rijkers
1 parent3efba16 commit871e73b

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

‎doc/src/sgml/plpgsql.sgml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.152 2010/04/03 07:22:55 petere Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.153 2010/04/27 14:32:40 alvherre Exp $ -->
22

33
<chapter id="plpgsql">
44
<title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title>
@@ -481,9 +481,11 @@ $$ LANGUAGE plpgsql;
481481
is with <literal>RETURNS TABLE</>, for example:
482482

483483
<programlisting>
484-
CREATE FUNCTION extended_sales(p_itemno int) RETURNS TABLE(quantity int, total numeric) AS $$
484+
CREATE FUNCTION extended_sales(p_itemno int)
485+
RETURNS TABLE(quantity int, total numeric) AS $$
485486
BEGIN
486-
RETURN QUERY SELECT quantity, quantity * price FROM sales WHERE itemno = p_itemno;
487+
RETURN QUERY SELECT quantity, quantity * price FROM sales
488+
WHERE itemno = p_itemno;
487489
END;
488490
$$ LANGUAGE plpgsql;
489491
</programlisting>
@@ -2154,9 +2156,12 @@ BEGIN
21542156

21552157
-- Now "mviews" has one record from cs_materialized_views
21562158

2157-
PERFORM cs_log('Refreshing materialized view ' || quote_ident(mviews.mv_name) || ' ...');
2159+
PERFORM cs_log('Refreshing materialized view '
2160+
|| quote_ident(mviews.mv_name) || ' ...');
21582161
EXECUTE 'TRUNCATE TABLE ' || quote_ident(mviews.mv_name);
2159-
EXECUTE 'INSERT INTO ' || quote_ident(mviews.mv_name) || ' ' || mviews.mv_query;
2162+
EXECUTE 'INSERT INTO '
2163+
|| quote_ident(mviews.mv_name) || ' '
2164+
|| mviews.mv_query;
21602165
END LOOP;
21612166

21622167
PERFORM cs_log('Done refreshing materialized views.');
@@ -2495,7 +2500,8 @@ OPEN curs1 FOR SELECT * FROM foo WHERE key = mykey;
24952500
<title><command>OPEN FOR EXECUTE</command></title>
24962501

24972502
<synopsis>
2498-
OPEN <replaceable>unbound_cursorvar</replaceable> <optional> <optional> NO </optional> SCROLL </optional> FOR EXECUTE <replaceable class="command">query_string</replaceable> <optional> USING <replaceable>expression</replaceable> <optional>, ... </optional> </optional>;
2503+
OPEN <replaceable>unbound_cursorvar</replaceable> <optional> <optional> NO </optional> SCROLL </optional> FOR EXECUTE <replaceable class="command">query_string</replaceable>
2504+
<optional> USING <replaceable>expression</replaceable> <optional>, ... </optional> </optional>;
24992505
</synopsis>
25002506

25012507
<para>
@@ -2517,7 +2523,8 @@ OPEN <replaceable>unbound_cursorvar</replaceable> <optional> <optional> NO </opt
25172523
<para>
25182524
An example:
25192525
<programlisting>
2520-
OPEN curs1 FOR EXECUTE 'SELECT * FROM ' || quote_ident(tabname) ' WHERE col1 = $1' USING keyvalue;
2526+
OPEN curs1 FOR EXECUTE 'SELECT * FROM ' || quote_ident(tabname)
2527+
|| ' WHERE col1 = $1' USING keyvalue;
25212528
</programlisting>
25222529
In this example, the table name is inserted into the query textually,
25232530
so use of <function>quote_ident()</> is recommended to guard against
@@ -2810,6 +2817,7 @@ BEGIN
28102817
END;
28112818
' LANGUAGE plpgsql;
28122819

2820+
-- need to be in a transaction to use cursors.
28132821
BEGIN;
28142822
SELECT reffunc2();
28152823

@@ -2966,7 +2974,8 @@ RAISE NOTICE 'Calling cs_create_job(%)', v_job_id;
29662974
This example will abort the transaction with the given error message
29672975
and hint:
29682976
<programlisting>
2969-
RAISE EXCEPTION 'Nonexistent ID --> %', user_id USING HINT = 'Please check your user id';
2977+
RAISE EXCEPTION 'Nonexistent ID --> %', user_id
2978+
USING HINT = 'Please check your user id';
29702979
</programlisting>
29712980
</para>
29722981

@@ -3394,7 +3403,8 @@ CREATE UNIQUE INDEX sales_summary_bytime_key ON sales_summary_bytime(time_key);
33943403
--
33953404
-- Function and trigger to amend summarized column(s) on UPDATE, INSERT, DELETE.
33963405
--
3397-
CREATE OR REPLACE FUNCTION maint_sales_summary_bytime() RETURNS TRIGGER AS $maint_sales_summary_bytime$
3406+
CREATE OR REPLACE FUNCTION maint_sales_summary_bytime() RETURNS TRIGGER
3407+
AS $maint_sales_summary_bytime$
33983408
DECLARE
33993409
delta_time_key integer;
34003410
delta_amount_sold numeric(15,2);
@@ -3416,7 +3426,8 @@ CREATE OR REPLACE FUNCTION maint_sales_summary_bytime() RETURNS TRIGGER AS $main
34163426
-- (probably not too onerous, as DELETE + INSERT is how most
34173427
-- changes will be made).
34183428
IF ( OLD.time_key != NEW.time_key) THEN
3419-
RAISE EXCEPTION 'Update of time_key : % -&gt; % not allowed', OLD.time_key, NEW.time_key;
3429+
RAISE EXCEPTION 'Update of time_key : % -&gt; % not allowed',
3430+
OLD.time_key, NEW.time_key;
34203431
END IF;
34213432

34223433
delta_time_key = OLD.time_key;
@@ -3867,7 +3878,7 @@ $$ LANGUAGE plpgsql;
38673878
<para>
38683879
Another good way to develop in <application>PL/pgSQL</> is with a
38693880
GUI database access tool that facilitates development in a
3870-
procedural language. One example of suchasa tool is
3881+
procedural language. One example of such a tool is
38713882
<application>pgAdmin</>, although others exist. These tools often
38723883
provide convenient features such as escaping single quotes and
38733884
making it easier to recreate and debug functions.
@@ -4450,7 +4461,8 @@ BEGIN
44504461

44514462
IF a_running_job_count &gt; 0 THEN
44524463
COMMIT; -- free lock<co id="co.plpgsql-porting-commit">
4453-
raise_application_error(-20000, 'Unable to create a new job: a job is currently running.');
4464+
raise_application_error(-20000,
4465+
'Unable to create a new job: a job is currently running.');
44544466
END IF;
44554467

44564468
DELETE FROM cs_active_job;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp