From: | PG Doc comments form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-docs(at)lists(dot)postgresql(dot)org |
Cc: | spamsacrime(at)gmail(dot)com |
Subject: | Split_Part w/negative integer does not work |
Date: | 2023-03-24 20:45:47 |
Message-ID: | 167969074745.3349097.2700599411216770547@wrigleys.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-docs |
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/15/functions-string.html
Description:
When n is negative, an error occurs.
Documentation
split_part ( string text, delimiter text, n integer ) → text
Splits string at occurrences of delimiter and returns the n'th field
(counting from one), or when n is negative, returns the |n|'th-from-last
field.
split_part('abc~(at)~def~@~ghi', '~(at)~', 2) → def
split_part('abc,def,ghi,jkl', ',', -2) → ghi
Observation
SELECT split_part('abc,def,ghi,jkl', ',', -1);
generates
ERROR: field position must be greater than zero
SQL state: 22023
Or in code
DO $$
DECLARE
mytxt text;
BEGIN
mytxt = split_part('abc,def,ghi,jkl', ',', -1);
RAISE NOTICE '%', mytxt;
END $$
ERROR: field position must be greater than zero
CONTEXT: SQL statement "SELECT split_part('abc,def,ghi,jkl', ',', -1)"
PL/pgSQL function inline_code_block line 6 at assignment
SQL state: 22023
From | Date | Subject | |
---|---|---|---|
Next Message | PG Doc comments form | 2023-03-25 15:43:56 | Misleading "For more information..." placement |
Previous Message | PG Doc comments form | 2023-03-24 15:10:37 | List Tables |