'Can we make use of local variables inside Postgresql insert statement [duplicate]

I want to create a simple insert query for inserting records into the database with local variables. Example : Simple insert query looks like:

Insert Into TableName(id, firstName, lastName)
Values ('123','ABC','XYZ')

Now I want to use some local variable for assigning the values inside the Insert statement, something like this:

variable_Name UserFirstName = 'ABC'
variable_Name UserLastName = 'XYZ'
variable_Name UserId = '123'

Insert Into TableName(id, firstName, lastName)
Values (@UserId,@UserFirstName,@UserLastName)

How this can be done?



Sources

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

Source: Stack Overflow

Solution Source