From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f59d6c1c0a3dac5f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,CP1252 Path: g2news1.google.com!news3.google.com!news.glorb.com!newspeer1.se.telia.net!se.telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail From: =?windows-1252?Q?Bj=F6rn_Persson?= User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: ada and pl/sql References: <122gh5o729tsfcf@corp.supernews.com> In-Reply-To: <122gh5o729tsfcf@corp.supernews.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Date: Mon, 27 Mar 2006 21:07:22 GMT NNTP-Posting-Host: 83.250.106.90 X-Complaints-To: abuse@telia.com X-Trace: newsb.telia.net 1143493642 83.250.106.90 (Mon, 27 Mar 2006 23:07:22 CEST) NNTP-Posting-Date: Mon, 27 Mar 2006 23:07:22 CEST Organization: Telia Internet Xref: g2news1.google.com comp.lang.ada:3659 Date: 2006-03-27T21:07:22+00:00 List-Id: Jason King wrote: > declare > v1 varchar2(10) := 'Hello'; > v2 varchar2(10) := 'World'; > v3 varchar2(30); > begin > v3 := v1 || ' ' || v2 ; -- || is string concat operator. > -- no error here since 'Hello World' > -- fits. > dbms_output.put_line(v3) ; -- prints "Hello World" [...] > ada.strings.bounded and > ada.strings.unbounded are issues because assignment (:=) doesn't work > for them and concatenation is method not an operator. Assignment and concatenation work just fine. Here's your example in Ada: with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO.Unbounded_IO; procedure Unbounded_Demo is String_1 : Unbounded_String := To_Unbounded_String("Hello"); String_2 : Unbounded_String := To_Unbounded_String("World"); String_3 : Unbounded_String; begin String_3 := String_1 & ' ' & String_2; Ada.Text_IO.Unbounded_IO.Put_Line(String_3); end Unbounded_Demo; (Ada.Text_IO.Unbounded_IO is new in Ada 2005, so it's only present in the newest libraries.) > As far as I can > tell I can't overload the assignment operator or the || operator. That's right. Instead of overloadable assignment, Ada has controlled types. "||" isn't an operator in Ada; the string concatenation operator is "&", and that one is overloadable. > Other than creating a new language is there some way to make a > varchar2-like first-class datatype that has its own operators? It's perfectly possible to create such a type in pure Ada, but you don't need to, because it's already there in the standard library. Bounded or unbounded strings are what you want. I have actually written a string handling package of my own. I got sick of the endless character encoding bugs, so I created an unbounded string type where each string object keeps track of its own encoding. I call it EAstrings � encoding-aware strings. -- Bj�rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu