PL SQL [Err] ORA-12704:字符集不匹配

时间:2016-08-14 18:08:02

标签: oracle plsql

我有两个pl / sql查询,但在(1)个查询中没有两个coulmns。它们是AcademicTitlesManagerialTitles。所以我将它们作为默认值'YOK'给(1) )查询。

我想要UNION(1)和(2)查询。

这是我的查询:

1 -

SELECT
    h1."IL_KODU",
    h1."KURUM_ILI",
    h1.ILCE_KODU,
    h1."KURUM_ILCESI",
    h1."KURUM_KODU",
    h1."KURUM_ADI",
    (
        CASE
        WHEN h1."STATU" = 'K' THEN
            'Devlet'
        END
    ) AS KURUM_STATU,
    h1."KURUM_TUR_ADI",
    br3."Type" AS Unvan,
    br."BranchName" AS Brans,
    'YOK' AS AkademikUnvan,
    'YOK' AS IdariUnvan,
    COUNT (1) AS Total
FROM KAMU_PERSONEL k1
INNER JOIN "SptsBranches" s1 ON s1."CkysBranchCode" = k1.BRANS_KODU
INNER JOIN "Branches" br ON s1."BranchId" = br."BranchId"
INNER JOIN "BranchBranchTypes" br2 ON br."BranchId" = br2."BranchId"
INNER JOIN "BranchTypes" br3 ON br3."BranchTypeId" = br2."BranchTypeId"
INNER JOIN HOSPITALS h1 ON h1.KURUM_KODU = k1.CALIS_BIRIM
GROUP BY
    h1."IL_KODU",
    h1."KURUM_ILI",
    h1.ILCE_KODU,
    h1."KURUM_ILCESI",
    h1."KURUM_KODU",
    h1."KURUM_ADI",
    h1."STATU",
    h1."KURUM_TUR_ADI",
    br3."Type",
    br."BranchName"

2 -

    SELECT
    p3."IL_KODU",
    p3."KURUM_ILI",
    p3.ILCE_KODU,
    p3."KURUM_ILCESI",
    p3."KURUM_KODU",
    p3."KURUM_ADI",
    (
        CASE
        WHEN p3."STATU" = 'O' THEN
            'Özel'
        WHEN p3."STATU" = 'U' THEN
            'Üniversite'
        END
    ) AS KURUM_STATU,
    p3."KURUM_TUR_ADI",
    b2."Type" AS Unvan,
    b1."BranchName" AS Brans,
    u1."Title" AS AkademikUnvan,
    u2."Title" AS IdariUnvan,
    COUNT (1) AS Total
FROM
    "SptsDatas" p1
INNER JOIN "PersonStatus" p2 ON p1."TcKimlik" = p2."Tckn"
INNER JOIN "Branches" b1 ON p1."Brans_BranchId" = b1."BranchId"
INNER JOIN "BranchTypes" b2 ON p1."Unvan_BranchTypeId" = b2."BranchTypeId"
INNER JOIN HOSPITALS p3 ON p2."HospitalCode" = p3."KURUM_KODU"
INNER JOIN "AcademicTitles" u1 ON u1."Id" = p1."AkademikUnvan_Id"
INNER JOIN "ManagerialTitles" u2 ON u2."Id" = p1."IdariUnvan_Id"
WHERE
    p2."Statu" = 1
AND p3."AKTIF" = 1
GROUP BY
    p3."IL_KODU",
    p3."KURUM_ILI",
    p3.ILCE_KODU,
    p3."KURUM_ILCESI",
    p3."KURUM_KODU",
    p3."KURUM_ADI",
    b1."BranchName",
    b2."Type",
    u1."Title",
    u2."Title",
    p3."STATU",
    p3."KURUM_TUR_ADI"

尝试UNION两次查询时发生此错误。

[Err] ORA-12704: character set mismatch

如何解决此错误。

由于

1 个答案:

答案 0 :(得分:0)

如果你在第二个查询中强制转换两列我相信它。

在第二个查询中尝试替换

U1"名称" AS AkademikUnvan,     U2"名称" AS IdariUnvan,

CAST(u1。" Title" AS varchar2(1000))AS AkademikUnvan, CAST(u2。" Title" AS varchar2(1000))AS IdariUnvan

让我知道这是怎么回事。