How to use ALTER USER MAPPING command with arguments through db.Exec()

30 views Asked by At

Below is the code snippet

if _, err := db.Exec(cmd, args...); err != nil {     
   return fmt.Errorf("failed to execute command: command %s %v", v.Command, err) 
}

where cmd being passed is

ALTER USER MAPPING FOR user1 SERVER myserver OPTIONS (SET password $1 );

and args is

["mypass"]

however, I get the following error -

failed to execute command: command ALTER USER MAPPING FOR user1 SERVER myserver OPTIONS (SET password  $1 ); pq: syntax error at or near "$1"

Does anyone know where I am mistaking?

I tried with,

command as -

Insert into table1 values ($1)

and args as -

[3]

which works perfectly. However, I am expecting the smilier behaviour with ALTER USER MAPPING command.

0

There are 0 answers