« Home | Oracle helpful url list » | Oracle B-Tree Index Internals:Rebuilding The Truth(1) » | ORADEBUG - UNDOCUMENTED ORACLE UTILITY » | Of Course it would be fun » | Oracle Diagnostics » | How simple mistake can cripple your database » | The Oracle TimesTen in-memory database is always r... » | Ruby on Rails on Oracle: A Simple Tutorial » | TOC(Table Of Contents:目次) » | Table Functions »

Need to convert...

今日はOracle Technology Network(OTN)のDiscussion
ForumsよりSQLに関する投稿をご紹介します。

今回は少し趣向を変えて投稿された質問から解決する
ためのSQLをみなさんで考えていただければと思います。

投稿者は当初投稿していた質問と状況が変わったことを
追加で投稿しています。


※OTNは無償のユーザ登録を行うことで参照可能です。

■ OTNトップページ
http://www.oracle.com/technology/index.html
■ 引用ページ
http://forums.oracle.com/forums/thread.jspa?threadID=400352&tstart=90

記事本文
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
◆ Need to convert part of a string from lowercase
to uppercase

Hello there,

The facts are changed. Everything what's next
after AAA_ must be in uppercase, except the
extension .pdf:

100000_AAA_20060630_en.pdf
=> 100000_AAA_20060630_EN.pdf

or

abc_100000_AAA_20060630_en.pdf
=> abc_100000_AAA_20060630_EN.pdf

In my update clause I have to search for string
"AAA_".
From this point I have to transform the
lowercase into uppercase, except the extension.
How can I accomplish this?

Regards,
Ronny.


英語の語順に近い解釈
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
◆ Need to convert
変換が必要です。

part of a string
文字列の一部

from lowercase to uppercase
小文字から大文字へ

Hello there,
こんにちは

The facts are changed.
状況が変わりました。

Everything what's next
全ては以下です。

after AAA_ must be in uppercase,
"AAA_"以降の文字は大文字で

except the extension .pdf:
拡張子".pdf"を除き。

100000_AAA_20060630_en.pdf
=> 100000_AAA_20060630_EN.pdf

or

abc_100000_AAA_20060630_en.pdf
=> abc_100000_AAA_20060630_EN.pdf

In my update clause
変更点は

I have to search for string "AAA_".
"AAA_"という文字列を探さなければならないこと

From this point
その位置から

I have to transform
変換しなければなりません。

the lowercase into uppercase,
小文字を大文字に

except the extension.
拡張子を除いて

How can I accomplish this?
どうしたら達成できますか?



解釈のポイント
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
◆ Need to convert part of a string
from lowercase to uppercase

(※)convert = 変換
lowercase = 小文字(abcd...)
uppercase = 大文字(ABCD...)


The facts are changed.
条件が変わりました。

Everything what's next
全ては以下です。

after AAA_ must be in uppercase,
"AAA_"以降の文字は大文字で

except the extension .pdf:

(※)extension = 拡張子


In my update clause

(※)clause = いくつかの単語のあつまり、節


I have to transform

(※)transform = convertの言い換え


How can I accomplish this?

(※)accomplish = 達成する


解説
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄
当初は拡張子pdfを除いて、全て大文字に変換したいという
ことだったのですが、それなりに回答が入った後で
条件が変わったので少し混乱していますね。
最終的な回答としてはinstr関数を使用して、
AAA_の位置を探し、それ以降を一度全て大文字に変換した
後、replace関数でPDFをpdfに変換するという対応に
なったようです。最終的にどんなSQLになったかは
投稿されていませんが、だいたい以下のような
感じではないでしょうか。

create table test1 (col1 varchar(30));
insert into test1 values ('abc_100000_AAA_20060630_en.pdf');
insert into test1 values ('100000_AAA_20060630_en.pdf');

select * from test1;

update test1 set col1=substr(col1,1,instr(col1,'AAA_')-1)
replace(upper(substr(col1,instr(col1,'AAA_'))),'PDF','pdf');

select * from test1;

編集後記
 ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄

今号からご購読いただいた皆様はじめまして。
本日も最後まで読んでいただきありがとうございます。

Forum形式はいかがでしたでしょうか。
このフォーラムはスレッドが登録される度にメール
で通知してもらえることもできるのですが、
正直言って仕事にならなくなります。極端な話
秒単位でメールがやってきます。(^-^;
裏を返せば、もし質問を投稿してもものすごい
勢いで回答してもらえるということです。
多少の文面は気にせず思い切って投稿してみるのも
いいと思います。

それではまた。

About me

  • I'm yaksa
  • From Tokyo, Japan
My profile
にほんブログ村 IT技術ブログへ

blogRanking