From abprusty@cisco.com Sun Sep 23 14:41:17 2012 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TFnMy-00037z-Vs for pgsql-sql@postgresql.org; Sun, 23 Sep 2012 14:41:17 +0000 Received: from rcdn-iport-8.cisco.com ([173.37.86.79]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TFnMv-0004k4-OI for pgsql-sql@postgresql.org; Sun, 23 Sep 2012 14:41:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=3838; q=dns/txt; s=iport; t=1348411273; x=1349620873; h=from:to:subject:date:message-id:mime-version; bh=ebpglCoIB/kRuo6/IVoNkYW3IA7VK7HoB/tbZJWqh/o=; b=boQME9gGcxeau3Vrma9bVTT5WzuQiCLmxBB6jwiDXqq3ETRXXCm0l+3M jBtEHDJaAFoPFc4QcXbfaETPlPzqHvtx4c0l9Jf9eulOI3pHNE+qA84Tk NizGyrL6wLpIhwyN2AzLWt4C8dEjfhQ0L7gc+Y82YR22a/tmzzKC3z7K/ Q=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av4EADgeX1CtJV2c/2dsb2JhbABFgku7YoEIgiIBBBIBGl4BDB5WJgEEGxqHY5ckgSifF5BmYAOkH4FpgmeCFw X-IronPort-AV: E=Sophos;i="4.80,470,1344211200"; d="scan'208,217";a="124420874" Received: from rcdn-core-5.cisco.com ([173.37.93.156]) by rcdn-iport-8.cisco.com with ESMTP; 23 Sep 2012 14:41:10 +0000 Received: from xhc-aln-x06.cisco.com (xhc-aln-x06.cisco.com [173.36.12.80]) by rcdn-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id q8NEfAdR028453 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Sun, 23 Sep 2012 14:41:10 GMT Received: from xmb-aln-x03.cisco.com ([169.254.6.113]) by xhc-aln-x06.cisco.com ([173.36.12.80]) with mapi id 14.02.0298.004; Sun, 23 Sep 2012 09:41:10 -0500 From: "Abhijit Prusty -X (abprusty - UST Global at Cisco)" To: "pgsql-sql@postgresql.org" Subject: HOw to convert unicode to string Thread-Topic: HOw to convert unicode to string Thread-Index: Ac2ZmXapoHvzQs7LTn6th6sq2Pkt0A== Date: Sun, 23 Sep 2012 14:41:09 +0000 Message-ID: <8A2A33BFAA5E2F408D0BBB80844412720487D0@xmb-aln-x03.cisco.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.65.80.236] x-tm-as-product-ver: SMEX-10.2.0.1135-7.000.1014-19204.004 x-tm-as-result: No--32.140800-8.000000-31 x-tm-as-user-approved-sender: No x-tm-as-user-blocked-sender: No Content-Type: multipart/alternative; boundary="_000_8A2A33BFAA5E2F408D0BBB80844412720487D0xmbalnx03ciscocom_" MIME-Version: 1.0 X-Pg-Spam-Score: -15.3 (---------------) X-Archive-Number: 201209/56 X-Sequence-Number: 36858 --_000_8A2A33BFAA5E2F408D0BBB80844412720487D0xmbalnx03ciscocom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi, I have a query in oracle like this mentioned below Insert into TEST (TEMPLATE_ID, TEMPLATE_NAME, CREATED_BY, CREATED_DT, UPDATED_BY, UPDATED_DT, TEMPLATE_KEY) Values (1, UNISTR('\D3C9\BA85\B3C4 \B514\C2A4\D50C\B808\C774'), 'dmin', SYSDATE= , 'admin', SYSDATE ,'FLOOR'); Now the oracle uses the UNISTR function to convert and insert the Unicode t= o string and store in database. But, how can we achieve the same using the PostgreSql .Can you please help = me with the query Thanks, Abhijit --_000_8A2A33BFAA5E2F408D0BBB80844412720487D0xmbalnx03ciscocom_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi,

 

I have a query in oracle like this mentioned below

 

Insert into TEST

   (TEMPLATE_ID, TEMPLATE_NAME, CREATED_BY= , CREATED_DT, UPDATED_BY,

    UPDATED_DT, TEMPLATE_KEY)

Values

   (1, UNISTR('\D3C9\BA85\B3C4 \B514\C2A4\= D50C\B808\C774'), 'dmin', SYSDATE, 'admin',

    SYSDATE ,'FLOOR');

 

Now the oracle uses the UNISTR function to convert a= nd insert the Unicode to string and store in database.

 

But, how can we achieve the same using the PostgreSq= l .Can you please help me with the query

 

 

Thanks,

Abhijit

--_000_8A2A33BFAA5E2F408D0BBB80844412720487D0xmbalnx03ciscocom_-- From jasen@xnet.co.nz Wed Sep 26 13:01:20 2012 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TGrEu-0004Yh-R8 for pgsql-sql@postgresql.org; Wed, 26 Sep 2012 13:01:20 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TGrEr-0002w2-FV for pgsql-sql@postgresql.org; Wed, 26 Sep 2012 13:01:20 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TGrEs-0003Ft-8L for pgsql-sql@postgresql.org; Wed, 26 Sep 2012 15:01:18 +0200 Received: from ip-118-90-16-232.xdsl.xnet.co.nz ([118.90.16.232]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 26 Sep 2012 15:01:18 +0200 Received: from jasen by ip-118-90-16-232.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 26 Sep 2012 15:01:18 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Jasen Betts Subject: Re: HOw to convert unicode to string Date: 26 Sep 2012 12:50:53 GMT Organization: Dis (not Dat) Organisation Lines: 49 Message-ID: References: <8A2A33BFAA5E2F408D0BBB80844412720487D0@xmb-aln-x03.cisco.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-16-232.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201210/1 X-Sequence-Number: 36872 On 2012-09-23, Abhijit Prusty -X (abprusty - UST Global at Cisco) wrote: > --_000_8A2A33BFAA5E2F408D0BBB80844412720487D0xmbalnx03ciscocom_ > Content-Type: text/plain; charset="us-ascii" > Content-Transfer-Encoding: quoted-printable > > Hi, > > I have a query in oracle like this mentioned below > > Insert into TEST > (TEMPLATE_ID, TEMPLATE_NAME, CREATED_BY, CREATED_DT, UPDATED_BY, > UPDATED_DT, TEMPLATE_KEY) > Values > (1, UNISTR('\D3C9\BA85\B3C4 \B514\C2A4\D50C\B808\C774'), 'dmin', SYSDATE= > , 'admin', > SYSDATE ,'FLOOR'); > > Now the oracle uses the UNISTR function to convert and insert the Unicode to > string and store in database. oracle uNISTR-like UTF-16 can be written like this: U&'\D3C9\BA85\B3C4 \B514\C2A4\D50C\B808\C774' it's not a function, it a way of writing strings... if you need a it probably wouldn't be hard to write. but you can also write in UTF-8 (literal or escaped) or unicode escaped see docs: u&'\+021502' -- unicode u&'\D845\DD02' -- utf16 (docs tell methis is legal with recent versions) e'\xF0\xA1\x94\x82' -- utf8 hex escape e'\360\241\224\202' -- utf8 octal escape '𡔂' -- utf8 string literal the first 2 can be intermixed as can the last three forms. http://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html select length('𡔂'), octet_length( '𡔂' ), length('test'), octet_length('test'); length | octet_length | length | octet_length --------+--------------+--------+-------------- 1 | 4 | 4 | 4 -- ⚂⚃ 100% natural