CREATE FUNCTION elog_test() RETURNS void AS $$
plpy.debug('debug', detail='some detail')
plpy.log('log', detail='some detail')
plpy.info('info', detail='some detail')
plpy.info()
plpy.info('the question', detail=42);
plpy.info('This is message text.',
detail='This is detail text',
hint='This is hint text.', sqlstate='XX000',
schema_name='any info about schema',
table_name='any info about table',
column_name='any info about column',
datatype_name='any info about datatype',
constraint_name='any info about constraint')
plpy.notice('notice', detail='some detail')
plpy.warning('warning', detail='some detail')
plpy.error('stop on error', detail='some detail', hint='some hint')
$$ LANGUAGE plpython3u;
SELECT elog_test();
DO $$ plpy.info('other types', detail=(10, 20)) $$ LANGUAGE plpython3u;
DO $$
import time; from datetime import date
plpy.info('other types', detail=date(2016, 2, 26))
$$ LANGUAGE plpython3u;
DO $$
basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
plpy.info('other types', detail=basket)
$$ LANGUAGE plpython3u;
-- should fail
DO $$ plpy.info('wrong sqlstate', sqlstate='54444A') $$ LANGUAGE plpython3u;
DO $$ plpy.info('unsupported argument', blabla='fooboo') $$ LANGUAGE plpython3u;
DO $$ plpy.info('first message', message='second message') $$ LANGUAGE plpython3u;
DO $$ plpy.info('first message', 'second message', message='third message') $$ LANGUAGE plpython3u;
-- raise exception in python, handle exception in plpgsql CREATEORREPLACE FUNCTION raise_exception(_message text, _detail text DEFAULTNULL, _hint text DEFAULTNULL,
_sqlstate text DEFAULTNULL,
_schema_name text DEFAULTNULL,
_table_name text DEFAULTNULL,
_column_name text DEFAULTNULL,
_datatype_name text DEFAULTNULL,
_constraint_name text DEFAULTNULL)
RETURNS void AS $$
kwargs = { "message": _message, "detail": _detail, "hint": _hint, "sqlstate": _sqlstate, "schema_name": _schema_name, "table_name": _table_name, "column_name": _column_name, "datatype_name": _datatype_name, "constraint_name": _constraint_name
}
# ignore None values
plpy.error(**dict((k, v) for k, v in iter(kwargs.items()) if v))
$$ LANGUAGE plpython3u;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.