<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Forum PostgreSQL - MS SQL ekwiwalent:  Cast( Reverse(0D0A......) as varbinary(max)) -]]></title>
	<link rel="self" href="http://forum.postgresql.org.pl/extern.php?action=feed&amp;tid=14301&amp;type=atom"/>
	<updated>2016-06-20T06:13:29Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.postgresql.org.pl/viewtopic.php?id=14301</id>
		<entry>
			<title type="html"><![CDATA[Odp: MS SQL ekwiwalent:  Cast( Reverse(0D0A......) as varbinary(max)) -]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=17774#p17774"/>
			<content type="html"><![CDATA[Zerknij na poniższy przykład. Oczywiście nie musisz używać reverse ale dla zachowania twoich wymagań zostawiłem tą funkcje w zapytaniu

with d (ciag) as (values(E'123456789\n\tA'),(E'\x41\x42\x43\x44\x0c'))
,db as (select  ciag,decode(reverse(ciag),'escape') as binarnie from d)
select ciag,binarnie,reverse(encode(binarnie,'escape')) as rozkodowane from db;]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2016-06-20T06:13:29Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=17774#p17774</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: MS SQL ekwiwalent:  Cast( Reverse(0D0A......) as varbinary(max)) -]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=17771#p17771"/>
			<content type="html"><![CDATA[[quote=c_michal]jeśli dobrze zrozumiałem chcesz odwrócić bitowo jakąś dużą liczbę

[/quote]

W zasadzie jest to BLOB zawierający jakiś plik zapisany w formie HEX
powiedzmy że plik zawiera taki tekst
1234567890
chcę żeby w bazie zapisało się jako wartość binarna ale odwrócona czyli
w bazie ma być tekst
0987654321
ale zapisany binarnie

Chodzi o to że w ten sposób przechowywane są pliki PDF RTF JPG .....]]></content>
			<author>
				<name><![CDATA[mLipok]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=3803</uri>
			</author>
			<updated>2016-06-17T10:53:23Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=17771#p17771</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Odp: MS SQL ekwiwalent:  Cast( Reverse(0D0A......) as varbinary(max)) -]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=17770#p17770"/>
			<content type="html"><![CDATA[jeśli dobrze zrozumiałem chcesz odwrócić bitowo jakąś dużą liczbę

Poniżej przykład z PostgreSQL

select reverse((liczba::bit(16))::text)::BIT(16)::BIGINT AS LICZBA_REVERSE ,reverse((liczba::bit(16))::text)::bit(12) AS BITE_REVERSE,liczba::bit(16) AS LICZBA_BITOWO,LICZBA
from (values (1::int)) d(liczba)

wynik:
LICZBA_REVERSE | BITE_REVERSE   | LICZBA_BITOWO       | LICZBA
32768                  |  100000000000 |  0000000000000001 | 1]]></content>
			<author>
				<name><![CDATA[c_michal]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=627</uri>
			</author>
			<updated>2016-06-17T07:13:48Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=17770#p17770</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[MS SQL ekwiwalent:  Cast( Reverse(0D0A......) as varbinary(max)) -]]></title>
			<link rel="alternate" href="https://forum.postgresql.org.pl/viewtopic.php?pid=17769#p17769"/>
			<content type="html"><![CDATA[Dotychczas na MS SQL używałem takiej składni:

.... Cast( Reverse(0D0A5B54657374315D0D0A313D50696F726B6F0D0A323D506) as varbinary(max))

Jak osiągnąć taki sam efekt w PostgreSQL ?

mLipok]]></content>
			<author>
				<name><![CDATA[mLipok]]></name>
				<uri>https://forum.postgresql.org.pl/profile.php?id=3803</uri>
			</author>
			<updated>2016-06-16T14:26:51Z</updated>
			<id>https://forum.postgresql.org.pl/viewtopic.php?pid=17769#p17769</id>
		</entry>
</feed>
