item_type,
item_form,
quality,
- FIRST(COALESCE(LTRIM(SUBSTR( value, COALESCE(SUBSTRING(ind2 FROM '\\\\d+'),'0')::INT + 1 )),'zzzzzzzz')) AS title
+ FIRST(COALESCE(LTRIM(SUBSTR( value, COALESCE(SUBSTRING(ind2 FROM E'\\\\d+'),'0')::INT + 1 )),'zzzzzzzz')) AS title
FROM (
SELECT rd.record,
rd.item_type,
if (lc($sort) eq 'pubdate') {
$rank = <<" RANK";
( FIRST ((
- SELECT COALESCE(SUBSTRING(frp.value FROM '\\\\d+'),'9999')::INT
+ SELECT COALESCE(SUBSTRING(frp.value FROM E'\\\\d+'),'9999')::INT
FROM $metabib_full_rec frp
WHERE frp.record = f.record
AND frp.tag = '260'
} elsif (lc($sort) eq 'title') {
$rank = <<" RANK";
( FIRST ((
- SELECT COALESCE(LTRIM(SUBSTR( frt.value, COALESCE(SUBSTRING(frt.ind2 FROM '\\\\d+'),'0')::INT + 1 )),'zzzzzzzz')
+ SELECT COALESCE(LTRIM(SUBSTR( frt.value, COALESCE(SUBSTRING(frt.ind2 FROM E'\\\\d+'),'0')::INT + 1 )),'zzzzzzzz')
FROM $metabib_full_rec frt
WHERE frt.record = f.record
AND frt.tag = '245'
if (lc($sort) eq 'pubdate') {
$rank = <<" RANK";
( FIRST ((
- SELECT COALESCE(SUBSTRING(frp.value FROM '\\\\d+'),'$number_default_sort')::INT
+ SELECT COALESCE(SUBSTRING(frp.value FROM E'\\\\d+'),'$number_default_sort')::INT
FROM $metabib_full_rec frp
WHERE frp.record = mr.master_record
AND frp.tag = '260'
} elsif (lc($sort) eq 'title') {
$rank = <<" RANK";
( FIRST ((
- SELECT COALESCE(LTRIM(SUBSTR( frt.value, COALESCE(SUBSTRING(frt.ind2 FROM '\\\\d+'),'0')::INT + 1 )),'$string_default_sort')
+ SELECT COALESCE(LTRIM(SUBSTR( frt.value, COALESCE(SUBSTRING(frt.ind2 FROM E'\\\\d+'),'0')::INT + 1 )),'$string_default_sort')
FROM $metabib_full_rec frt
WHERE frt.record = mr.master_record
AND frt.tag = '245'
my $secondary_sort = <<" SORT";
( FIRST ((
- SELECT COALESCE(LTRIM(SUBSTR( sfrt.value, COALESCE(SUBSTRING(sfrt.ind2 FROM '\\\\d+'),'0')::INT + 1 )),'$string_default_sort')
+ SELECT COALESCE(LTRIM(SUBSTR( sfrt.value, COALESCE(SUBSTRING(sfrt.ind2 FROM E'\\\\d+'),'0')::INT + 1 )),'$string_default_sort')
FROM $metabib_full_rec sfrt,
$metabib_metarecord mr
WHERE sfrt.record = mr.master_record
if (lc($sort) eq 'pubdate') {
$rank = <<" RANK";
( FIRST ((
- SELECT COALESCE(SUBSTRING(frp.value FROM '\\\\d+'),'$number_default_sort')::INT
+ SELECT COALESCE(SUBSTRING(frp.value FROM E'\\\\d+'),'$number_default_sort')::INT
FROM $metabib_full_rec frp
WHERE frp.record = mr.master_record
AND frp.tag = '260'
} elsif (lc($sort) eq 'title') {
$rank = <<" RANK";
( FIRST ((
- SELECT COALESCE(LTRIM(SUBSTR( frt.value, COALESCE(SUBSTRING(frt.ind2 FROM '\\\\d+'),'0')::INT + 1 )),'$string_default_sort')
+ SELECT COALESCE(LTRIM(SUBSTR( frt.value, COALESCE(SUBSTRING(frt.ind2 FROM E'\\\\d+'),'0')::INT + 1 )),'$string_default_sort')
FROM $metabib_full_rec frt
WHERE frt.record = mr.master_record
AND frt.tag = '245'
RANK
$secondary_sort = <<" SORT";
( FIRST ((
- SELECT COALESCE(SUBSTRING(sfrp.value FROM '\\\\d+'),'$number_default_sort')::INT
+ SELECT COALESCE(SUBSTRING(sfrp.value FROM E'\\\\d+'),'$number_default_sort')::INT
FROM $metabib_full_rec sfrp
WHERE sfrp.record = mr.master_record
AND sfrp.tag = '260'
if (lc($sort) eq 'pubdate') {
$rank = <<" RANK";
( FIRST ((
- SELECT COALESCE(SUBSTRING(frp.value FROM '\\\\d{4}'),'$number_default_sort')::INT
+ SELECT COALESCE(SUBSTRING(frp.value FROM E'\\\\d{4}'),'$number_default_sort')::INT
FROM $metabib_full_rec frp
WHERE frp.record = b.id
AND frp.tag = '260'
} elsif (lc($sort) eq 'title') {
$rank = <<" RANK";
( FIRST ((
- SELECT COALESCE(LTRIM(SUBSTR( frt.value, COALESCE(SUBSTRING(frt.ind2 FROM '\\\\d+'),'0')::INT + 1 )),'$string_default_sort')
+ SELECT COALESCE(LTRIM(SUBSTR( frt.value, COALESCE(SUBSTRING(frt.ind2 FROM E'\\\\d+'),'0')::INT + 1 )),'$string_default_sort')
FROM $metabib_full_rec frt
WHERE frt.record = b.id
AND frt.tag = '245'