Last active
September 15, 2016 11:53
-
-
Save orx0r/cf4bbc1156ad8a8e8104627e366cd596 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```pl/pgsql | |
do $$ | |
declare | |
item text; | |
BEGIN | |
DELETE FROM table_realtion | |
WHERE rel1 = 2; | |
FOREACH item IN ARRAY string_to_array('1#2#5#', '#') | |
LOOP | |
RAISE INFO '%', pg_typeof(item); | |
if item <> '' then | |
INSERT INTO table_realtion (rel1_id, rel1_id) | |
VALUES (2, item::int); -- или: ... , CAST(item AS integer); | |
end if; | |
END LOOP; | |
end; | |
$$ | |
language plpgsql; | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment