

 Amazon Redshift non supporterà più la creazione di nuovi Python UDFs a partire dalla Patch 198. Python esistente UDFs continuerà a funzionare fino al 30 giugno 2026. Per ulteriori informazioni, consulta il [post del blog](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/). 

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Funzione BPCHARCMP
<a name="r_BPCHARCMP"></a>

Confronta il valore di due stringhe e restituisce un integer. Se le stringhe sono identiche, la funzione restituisce `0`. Se la prima stringa è alfabeticamente posteriore, la funzione restituisce `1`. Se la seconda stringa è maggiore, la funzione restituisce `-1`. 

Per i caratteri multibyte, il confronto si basa sulla codifica dei byte.

Sinonimo di [Funzione BTTEXT\$1PATTERN\$1CMP](r_BTTEXT_PATTERN_CMP.md). 

## Sintassi
<a name="r_BPCHARCMP-synopsis"></a>

```
BPCHARCMP(string1, string2)
```

## Arguments (Argomenti)
<a name="r_BPCHARCMP-arguments"></a>

 *string1*   
Una stringa `CHAR` o una stringa `VARCHAR`. 

 *string2*   
Una stringa `CHAR` o una stringa `VARCHAR`. 

## Tipo restituito
<a name="r_BPCHARCMP-return-type"></a>

 INTEGER 

## Esempi
<a name="r_BPCHARCMP-examples"></a>

 Gli esempi seguenti utilizzano la tabella USERS dal database di esempio di TICKIT. Per ulteriori informazioni, consulta [Database di esempio](c_sampledb.md). 

Per determinare se il nome di un utente è alfabeticamente maggiore rispetto al cognome dell'utente per le prime dieci voci nella tabella USERS, utilizza l'esempio seguente. È possibile vedere che per le voci in cui la stringa per FIRSTNAME è successiva in ordine alfabetico rispetto a LASTNAME, la funzione restituisce `1`. Se LASTNAME in ordine alfabetico viene dopo FIRSTNAME, la funzione restituisce `-1`.

```
SELECT userid, firstname, lastname, BPCHARCMP(firstname, lastname)
FROM users
ORDER BY 1, 2, 3, 4
LIMIT 10;

+--------+-----------+-----------+-----------+
| userid | firstname | lastname  | bpcharcmp |
+--------+-----------+-----------+-----------+
|      1 | Rafael    | Taylor    |        -1 |
|      2 | Vladimir  | Humphrey  |         1 |
|      3 | Lars      | Ratliff   |        -1 |
|      4 | Barry     | Roy       |        -1 |
|      5 | Reagan    | Hodge     |         1 |
|      6 | Victor    | Hernandez |         1 |
|      7 | Tamekah   | Juarez    |         1 |
|      8 | Colton    | Roy       |        -1 |
|      9 | Mufutau   | Watkins   |        -1 |
|     10 | Naida     | Calderon  |         1 |
+--------+-----------+-----------+-----------+
```

Per restituire tutte le voci nella tabella USERS in cui la funzione restituisce `0`, utilizza l'esempio seguente. La funzione restituisce `0` quando FIRSTNAME è identico a LASTNAME. 

```
SELECT userid, firstname, lastname,
BPCHARCMP(firstname, lastname)
FROM users 
WHERE BPCHARCMP(firstname, lastname)=0
ORDER BY 1, 2, 3, 4;

+--------+-----------+----------+-----------+
| userid | firstname | lastname | bpcharcmp |
+--------+-----------+----------+-----------+
|     62 | Chase     | Chase    |         0 |
|   4008 | Whitney   | Whitney  |         0 |
|  12516 | Graham    | Graham   |         0 |
|  13570 | Harper    | Harper   |         0 |
|  16712 | Cooper    | Cooper   |         0 |
|  18359 | Chase     | Chase    |         0 |
|  27530 | Bradley   | Bradley  |         0 |
|  31204 | Harding   | Harding  |         0 |
+--------+-----------+----------+-----------+
```