【问题标题】:Sqldeveloper to define variable of RAW typeSqldeveloper 定义 RAW 类型的变量
【发布时间】:2022-10-14 07:01:26
【问题描述】:

我正在使用 SQL 开发人员(Oracle 的 SQL 开发人员)并且有一个表,其列为 raw 类型。此列中的示例值为:

ABE478C1388D9015875646AD16010B13
D78ABC797BC898AA9710BC090913B15C

我想在我的SELECT 语句中使用这些值作为我预先定义的变量:

define carHashId = 'ABE478C1388D9015875646AD16010B13'

当我在WHERE 子句中使用这个变量时: WHERE hid = &&carHashId 我总是收到以下错误:

*Cause:    An identifier with more than 128 bytes was specified,
           or a password identifier longer than 30 bytes was specified.
*Action:   Specify at most 128 bytes for identifiers,
           and at most 30 bytes for password identifiers.

我能做些什么呢?

【问题讨论】:

  • SQL 开发人员,如 Oracle 的 SQL 开发人员?
  • @jarlh 是的,Oracle 的 SQL 开发人员。

标签: sql oracle


【解决方案1】:

使用 HEXTORAW() 从 dual 中选择 HEXTORAW('ABE478C1388D9015875646AD16010B13') ;

注意 utl_raw.cast_to_raw('ABE478C1388D9015875646AD16010B13') 会给 '4142453437384331333838443930313538373536343641443136303130423133' 这可能不是你想要的。

【讨论】:

    【解决方案2】:

    这是一个替换变量,因此在使用时需要包含引号:

    define carHashId = ABE478C1388D9015875646AD16010B13
    
    select '&carHashId' from dual
    

    define 语句中的引号在 SQL Developer 中没有任何作用。您可以使用以下任何一种方法并获得相同的结果:

    define carHashId = ABE478C1388D9015875646AD16010B13
    
    define carHashId = 'ABE478C1388D9015875646AD16010B13'
    
    define carHashId = "ABE478C1388D9015875646AD16010B13"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-01
      相关资源
      最近更新 更多