Answer the question
In order to leave comments, you need to log in
How to parse records using PostgreSQL?
I pull out information about the PC using PowerShell. I write information to PostgreSQL. You need to parse the Description field (to normalize the database).
The field looks like this:
Login: 06789-ivanov; IP 10.1.222.34; Time: 06/23/2015 19:43:35 It is
necessary to divide this record into three parts and save it to another table
Answer the question
In order to leave comments, you need to log in
For example,
CREATE OR REPLACE FUNCTION process_data(
s_input text
)
RETURNS void
AS $function$
DECLARE
a_data text[];
BEGIN
a_data := regexp_matches(s_input, '^Login: ([^;]+); IP ([\d\.]+); Time: ([\d\:\.\s]+)$');
raise notice 'Login %', a_data[1];
raise notice 'IP %', a_data[2];
raise notice 'Time %', to_timestamp(a_data[3], 'DD.MM.YYYY HH24:MI:SS');
END;
$function$
LANGUAGE plpgsql STABLE SECURITY DEFINER;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question