NVARCHAR2表示为十六进制

问题描述 投票:2回答:1

我在Oracle中有一个NVARCHAR2字段,我正在做一个LISTAGG并附加一些文本。

LISTAGG(
  CASE
    WHEN a.is_dead = 'Y' AND a.death_cause IS NOT NULL AND a.death_date IS NOT NULL THEN a.composite_pednum || ' - ' || a.death_cause || ' (' || a.death_date || ')'
    WHEN a.is_dead = 'Y' AND a.death_cause IS NOT NULL THEN a.composite_pednum || ' - ' || a.death_cause
    WHEN a.is_dead = 'Y' THEN a.composite_pednum || ' - Dead'
    WHEN a.is_dead = 'N' THEN a.composite_pednum || ' - Alive'
    ELSE a.composite_pednum || ' - Unknown Status'
  END,
  ';'
) WITHIN GROUP (ORDER BY a.pedigree_number ASC) AS cage_animals

在PHP中,我将explode这个文本转换成一个数组,以便以后处理。

$cage_animals = array();
if(!empty($data['CAGE_ANIMALS'][$i])) {
  $cage_animals = explode(';', $data['CAGE_ANIMALS'][$i]);
}

这给了我类似的东西

["cage_animals"]=>
  array(2) {
    [0]=>
    string(38) "R15-57713-B - Alive"
    [1]=>
    string(40) "R15-57714-RR - Alive"
  }

请注意字符串的长度看起来比实际更多?我想这可能是因为下面的截图(不是完整的截图):

enter image description here

所以我的问题是如何防止这种情况?我试图找到strposAlive,我总是得到false,因为找不到文字。

php string oracle hex nvarchar
1个回答
0
投票

我最后使用CASTTO_CHAR为我的每个THEN条款。

LISTAGG(
  CASE
    WHEN a.is_dead = 'Y' AND a.death_cause IS NOT NULL AND a.death_date IS NOT NULL THEN TO_CHAR(a.composite_pednum || ' - ' || a.death_cause || ' (' || TO_CHAR(a.death_date, 'Mon DD, YYYY') || ')')
    WHEN a.is_dead = 'Y' AND a.death_cause IS NOT NULL THEN TO_CHAR(a.composite_pednum || ' - ' || a.death_cause)
    WHEN a.is_dead = 'Y' THEN TO_CHAR(a.composite_pednum || ' - Dead')
    WHEN a.is_dead = 'N' THEN TO_CHAR(a.composite_pednum || ' - Alive')
    ELSE TO_CHAR(a.composite_pednum || ' - Unknown Status')
  END,
  ';'
) WITHIN GROUP (ORDER BY a.pedigree_number ASC) AS cage_animals
© www.soinside.com 2019 - 2024. All rights reserved.