I am trying to insert the password in a table using encrypt()
function provided by a snowflake.
The below statement is working fine
select encrypt('Patient tested positive for COVID-19', $passphrase);
but when I am trying to use the variable instead of direct string password inside encrypt()
I am getting an error(below query is giving an error)
set acc_name = 'acc1';
set username = 'username1';
set password = 'passtemp';
set passphare = 'random_string';
insert into db.public.detailstable values ($acc_name,$username,encrypt($password, $passphare));
Error:
SQL compilation error: Invalid expression [ENCRYPT(:SFSL_A2_0, :SFSL_A2_1)] in VALUES clause
Create table statement:
create or replace TABLE detailstable (
accountName VARCHAR(16777216),
username VARCHAR(16777216),
password BINARY(8388608)
);
CodePudding user response:
The VALUES clause in an INSERT requires a literal, expression, default value, or NULL. The result of the encrypt function call does not satisfy that requirement. The following statement will work.
insert into db.public.detailstable
select $acc_name, $username, encrypt($password, $passphare);