Article View: borland.public.interbase.sql
Article #831Re: SQL insert into statement
From: delphiprog
Date: Wed, 16 May 2007 01:35
Date: Wed, 16 May 2007 01:35
21 lines
2024 bytes
2024 bytes
On May 15, 12:48 pm, "David" <n...@nowhere.com> wrote:
> Should this work or do I have something wrong:
>
> insert into ORDER_IP ("IP") select DISTINCT SUBSTRING("IPAddress" from 1 for
> 15) from "orders" where "IPAddress" is not NULL
>
> It seems the SubString makes the Distinct not work and without the substring
> the target IP (20) field is smaller than IPAddress (20) field.
I've never used the Interbase SUBSTRING function, didn't know it
existed. I believe you can use a cast statement to do what you're
trying to do:
select DISTINCT cast("IPAddress" as varchar(15)) from "orders" where
"IPAddress" is not NULL
NOTE: this will only work if every IPAddress value in "orders" has an
actual field length <= 15. If you try to cast a field with 20
characters as 15 you'll get an exception.
Doug
Technical Details
Message-ID:
<1179279300.863092.159650@k79g2000hse.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!k79g2000hse.googlegroups.com!not-for-mailReferences:
<Jvl2i.162733$nh4.13092@newsfe20.lga>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,279f5b7c9aace22c X-Google-Attributes: gid114a0e,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!k79g2000hse.googlegroups.com!not-for-mail From: delphiprog@gmail.com Newsgroups: borland.public.interbase.sql Subject: Re: SQL insert into statement Date: 15 May 2007 18:35:00 -0700 Organization: http://groups.google.com Lines: 22 Message-ID: <1179279300.863092.159650@k79g2000hse.googlegroups.com> References: <Jvl2i.162733$nh4.13092@newsfe20.lga> NNTP-Posting-Host: 71.65.101.158 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1179279301 24788 127.0.0.1 (16 May 2007 01:35:01 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 16 May 2007 01:35:01 +0000 (UTC) In-Reply-To: <Jvl2i.162733$nh4.13092@newsfe20.lga> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: k79g2000hse.googlegroups.com; posting-host=71.65.101.158; posting-account=4Oov0g0AAABBVmCjznVadb51EVvd7rBl