Home How can I convert XML type to integer?
Reply: 0

How can I convert XML type to integer?

user1000 Published in May 27, 2018, 11:32 pm
CREATE OR REPLACE FUNCTION j_f_sync_from_xml_2()
RETURNS boolean AS
myxml    xml;
datafile text := 'ABBATE_EMANUELE_Lvl1F2Va_20160418-1759_3.xml';

myxml := pg_read_file(datafile, 0, 100000000); 

CREATE TABLE public.james_2 AS
SELECT unnest(xpath('//@OPERATORE', t)) as Operatore, 
unnest(xpath('//@DATA', t)) as Data, unnest(xpath('//ObjectSelect/@NOME', 
t)) as Nome, unnest(xpath('//ObjectSelect/@TEMPO', t)) as Tempo, 
unnest(xpath('//ObjectSelect/@X', t)) as X, 
unnest(xpath('//ObjectSelect/@Y', t)) as Y,
unnest(xpath('//ObjectSelect/@Z', t)) as Z
FROM   unnest(xpath('/root/level', myxml)) x(t);
$BODY$ language plpgsql;

This programme creates columns as XML type. How convert XML type to integer format? I tried this code:

select  Tempo::text::int
from    james_2
cross join lateral
unnest(xpath('//ObjectSelect/@TEMPO', Tempo)) xp(T)

but give me an error: < not found

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301524 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO