try_ip_host functie

Van toepassing op:controleren gemarkeerd als Ja Databricks Runtime 18.2 en hoger

Retourneert de canonieke weergave van een IPv4- of IPv6-adres. Retourneert NULL in plaats van een fout op te geven als de invoer ongeldig is.

Syntax

try_ip_host ( ip )

Arguments

  • ip: A STRING of BINARY waarde die een IPv4- of IPv6-adres vertegenwoordigt.

Returns

Hetzelfde type als de invoer (STRING of BINARY), die de canonieke vorm van het adres vertegenwoordigt.

De functie retourneert NULL als de invoer is of ongeldig is NULL .

Examples

> SELECT try_ip_host('192.168.1.5');
  192.168.1.5

> SELECT try_ip_host('2001:0db8:0000:0000:0000:0000:0000:0001');
  2001:db8::1

> SELECT try_ip_host('2001:DB8::1');
  2001:db8::1

> SELECT try_ip_host('::ffff:192.0.2.128');
  ::ffff:192.0.2.128

> SELECT hex(try_ip_host(X'C0A80101'));
  C0A80101

> SELECT try_ip_host('invalid');
  NULL

> SELECT try_ip_host(X'');
  NULL

> SELECT try_ip_host(NULL);
  NULL