'posgresql: how to declare variables with DECLARE command?

I've searched and found a similar question posted over a year ago, but the proposed answers (2) don't address my question.

The page at https://www.techonthenet.com/postgresql/declare_vars.php described how to delare a variable with the declare command, but when I tried an example, such as

DECLARE vSite varchar := 'TechOnTheNet.com';

I got the error below.

ERROR:  syntax error at or near "varchar"
LINE 1: DECLARE vSite varchar := 'TechOnTheNet.com';

When I looked up the syntax of the declare command, I got the following info, which is for something completely different from what's described in the above page.

=# \h declare
Command:     DECLARE
Description: define a cursor
Syntax:
DECLARE name [ BINARY ] [ ASENSITIVE | INSENSITIVE ] [ [ NO ] SCROLL ]
    CURSOR [ { WITH | WITHOUT } HOLD ] FOR query

URL: https://www.postgresql.org/docs/14/sql-declare.html



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source