文字列を保持するNVARCHAR2データ型の列があるテーブルがあります。 文字列には、カンマ区切りでフェッチする必要のある電子メールIDが含まれています。NVARCHAR2から電子メールアドレスを取得するDATATYPE
は、以下の試験データである -
create table nvarchar2_email (email_reject nvarchar2(1000));
insert into nvarchar2_email values ('com.wm.app.b2b.server.ServiceException: javax.mail.SendFailedException: Invalid Addresses; nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual alias table;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual alias table
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual alias table');
insert into nvarchar2_email values ('com.wm.app.b2b.server.ServiceException: javax.mail.SendFailedException: Invalid Addresses; nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual alias table;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in virtual alias table');
私は、以下のSQLを使用しようとしていますが、それは電子メールのIdsを繰り返しています!
select email_rejetc, listagg(REGEXP_substr (email_rejetc,'[A-Za-z0-9._%+-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}', 1,level), ',') within group (order by email_rejetc) invalid_email
from nvarchar2_email
connect by level <= REGEXP_count (email_rejetc,'[A-Za-z0-9._%+-][email protected][A-Za-z0-9.-]+\.[A-Za-z]{2,4}')
group by EMAIL_REJETC
ここで必要な出力がメールの数は、テーブルの異なる行に変えることができ
[email protected],[email protected],[email protected]
のようなものです。
私のDBは次のとおりです。 Oracle Database 11gのEnterprise Editionのリリース11.2.0.3.0 - 64ビットの生産
すごくうまくいっている – mradul