1

Oracle 11gを使用すると、次のLDAP文字列があります。これは、ここで説明しようとしているもののサブセットにすぎません。

基本的に、「文字列リテラルが長すぎる」という問題を引き起こしている非常に長い文字列があり、基本的にこの文字列内で、不要なビットを削除するか、さらに良いことに、私は欲しい。

これは、文字列の内容/長さの短いバージョンにすぎません。

メンバー=CN= aTIGERAdmin-Admin、CN = D0902498、CN = ea90045052、CN = aTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall -管理者、CN = DAaTIGERCall-管理者、CN = DAaTIGERCall-管理者、CN = DAaTIGERCall-管理者、CN = DAaTIGERCall-管理者、CN = aTIGERAdmin-管理者、CN = ea90045052、CN = DAaTIGERCall-管理者、CN = DAaTIGERCall-管理者、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = aTIGERCall-Admin、CN = aTIGERAdmin-Admin、CN = D0902498 、CN = ea90045052、CN = aTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall -管理者、CN = DAaTIGERCall-管理者、CN = DAaTIGERCall-管理者、CN = aTIGERAdmin-管理者、CN = ea90045052、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = DAaTIGERCall-Admin、CN = aTIGERCall-管理者、

上記の長さが4000文字を超えると仮定します。

私の問題は、OracleSQLとPL/ SQLおよび上記の「メンバー」文字列を使用して、「CN = aTIGER%」のようなビットのみを何らかの方法で除外し、「CN = DAaTIGER%」のようなエントリを完全に無視する必要があることです。 'これは、文字列リテラルの問題を解決すると信じていますが、元の文字列の長さがすでに4000文字を超えているため、最初にこれを除外することはできません。

pl / sqlを使用して、「CN = aTIGER%」のような「member of」内のエントリのみを返し、同時に「CN = DAaTIGER%」のようなエントリを完全に無視するアプローチを探しています。結果の最後にもコンマがあります。

これをCLOBに割り当ててから、必要なエントリを処理する必要がありますか?

4

1 に答える 1

2

次のコードでは、サンプルのような大量のデータをCLOB「 」に事前入力しました。c対象となる各エントリで何をしたいのかわかりません。私はそれだけDBMS_OUTPUTです。

それをすべて考えると、ここにそれを突き刺します:

SET SERVEROUTPUT ON
DECLARE
    c                   CLOB;
    l_offset            POSITIVE := 1;
    l_ldap_component    LONG;
    l_counter           NATURAL := 0;
BEGIN
    -- Set up the CLOB.  In real life, this data will come
    -- from some other source.
    c := 'Member of = CN=aTIGERAdmin-Admin'
      || ', CN=D0902498'
      || ', CN=ea90045052'
      || ', CN=aTIGERCall-Admin'
      || ', CN=DAaTIGERCall-Admin'
--- Lots of additional data excised for the sake of brevity....
      || ', CN=aTIGERCall-Admin,';
    DBMS_OUTPUT.PUT_LINE('Length of CLOB = ' || TO_CHAR(DBMS_LOB.GETLENGTH(c)));

    -- Search for commas within the CLOB, and extract each subsequent
    -- inter-comma string, including the trailing comma.
    WHILE (DBMS_LOB.INSTR(c,',',l_offset) > 0)
    LOOP
        l_ldap_component :=
            TRIM (
                DBMS_LOB.SUBSTR(c
                ,               DBMS_LOB.INSTR(c
                                ,              ','
                                ,              l_offset) - l_offset + 1
                ,               l_offset)
        );
        IF (l_ldap_component LIKE 'CN=aTIGER%,') THEN
            -- I'm printing the qualified entries to the screen, but you
            -- can add them to a collection or whatever....
            DBMS_OUTPUT.PUT_LINE(l_ldap_component);
        END IF;
        l_offset := DBMS_LOB.INSTR(c,',',l_offset) + 1;
    END LOOP;    
END;
/

私が使用したデータを使用して、このコードは次の出力を生成しました。

Length of CLOB = 5127
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,
CN=aTIGERAdmin-Admin,
CN=aTIGERCall-Admin,

PL/SQL procedure successfully completed.

SQL>

これがお役に立てば幸いです。

于 2012-07-03T03:00:37.103 に答える