【问题标题】:Oracle SQL Developer select query blobOracle SQL Developer 选择查询 blob
【发布时间】:2012-12-30 14:54:13
【问题描述】:

有谁知道我如何从表中的列中选择一个 blob(在这种情况下为图像)?我在下面的查询抛出了这个错误:

ORA-00932: inconsistent datatypes: expected - got BLOB
00932. 00000 -  "inconsistent datatypes: expected %s got %s"

SELECT homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft,
       listagg(features.feature_name, ',') WITHIN GROUP (ORDER BY features.feature_name)  features, home_type.type_name, home_photo.photo, home_photo.description
FROM homes
INNER JOIN home_feature
    ON homes.home_id = home_feature.home_id
INNER JOIN home_type
    ON home_type.type_code = homes.type_code
INNER JOIN home_photo
    ON homes.home_id = home_photo.home_id
INNER JOIN features
    ON home_feature.feature_id = features.feature_id
INNER JOIN home_photo
    ON home_photo.home_id = homes.home_id
GROUP BY homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft, home_type.type_name, home_photo.photo, home_photo.description;

谢谢

【问题讨论】:

    标签: sql oracle join oracle11g blob


    【解决方案1】:

    您收到此错误是因为您尝试将 GROUP BY 与 BLOB 列一起使用。这在 Oracle 中是不可能的。

    您应该能够通过在子查询中进行分组并将带有 home_photo 的 JOIN 移动到外部查询来解决此问题:

    select v1.*,
           home_photo.photo,
           home_photo.description
      from (SELECT homes.homes_id,
                   homes.title,
                   homes.description,
                   homes.living_room_count,
                   homes.bedroom_count,
                   homes.bathroom_count,
                   homes.price,
                   homes.sqft,
                   listagg(features.feature_name,
                           ',') WITHIN GROUP(ORDER BY features.feature_name) features,
                   home_type.type_name
              FROM homes
             INNER JOIN home_feature
                ON homes.home_id = home_feature.home_id
             INNER JOIN home_type
                ON home_type.type_code = homes.type_code
             INNER JOIN features
                ON home_feature.feature_id = features.feature_id
             GROUP BY homes.homes_id,
                      homes.title,
                      homes.description,
                      homes.living_room_count,
                      homes.bedroom_count,
                      homes.bathroom_count,
                      homes.price,
                      homes.sqft,
                      home_type.type_name) v1
     INNER JOIN home_photo
        ON home_photo.home_id = v1.home_id
    

    【讨论】:

    • 嘿,非常感谢您的回复,但是当我尝试使用您的查询时,我收到了 oracle 的此错误:ORA-00904: "HOMES"."HOME_ID": invalid identifier
    • 对不起,我忘了修正连接条件;你需要用 v1.home_id 替换 home.home_id (我已经更新了我的答案)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-20
    • 1970-01-01
    • 2021-04-12
    • 2021-03-31
    • 1970-01-01
    • 2014-06-16
    • 2015-04-11
    相关资源
    最近更新 更多