I am currently trying to create a new column with passwords based on other column from the same table (tb_customer). The source to create the passwords is the column cust_cif.
The script I used is as follows:
ALTER TABLE erp.tb_customer
ADD COLUMN password CHAR (34) USING crypt(erp.tb_customer.cust_cif, gen_salt('md5'));
I am getting an error and don't know why, since md5 doesn't need installation (but I did nevertheless).
The error is the following:
ERROR: does not exist type «crypt»
LINE 2: ADD COLUMN password crypt(erp.tb_customer.cust_cif, gen_sa...
I also tried with
ALTER TABLE erp.tb_customer
ADD COLUMN password SELECT crypt(erp.tb_customer.cust_cif, gen_salt('md5'));
Here are some values shown in the table tb_customer
:
cust_no | cust_name | cust_cif | last_updated_by | last_updated_date
"C0001" "PIENSOS MARTIN" "A12345678" "SYSTEM" "2022-04-28"
"C0002" "AGRICULTURA VIVES" "A66666666" "SYSTEM" "2022-04-28"
"C0003" "CULTIVOS MARAVILLA" "A55555555" "SYSTEM" "2022-04-28"
"C0004" "ASOCIADOS PEREZ" "A23126743" "SYSTEM" "2022-04-28"
"C0005" "TECNICOS AVA" "B34211233" "SYSTEM" "2022-04-28"
"C0006" "AGR AGRI" "B78788999" "SYSTEM" "2022-04-28"
"C0007" "AGRIMARCOS" "B98766562" "SYSTEM" "2022-04-28"
"C0008" "CULTIVANDO ALEGRIA" "B12333123" "SYSTEM" "2022-04-28"
"C0009" "MARCOS LIMPIEZA" "A87727711" "SYSTEM" "2022-04-28"
"C0010" "VIAJES MUNDO" "A00099982" "SYSTEM" "2022-04-28"
What am I doing wrong?
Thank you in advance.
There is no
ADD COLUMN...USING
.You will have to add the column and populate it (UPDATE) in different statements. Possibly in the same transaction.