# HIMPORT SET

> Make a hash from values, using a list of field names prepared on this connection.

URL: https://docs.hotkv.com/commands/himport-set/

```
HIMPORT SET key name value [value ...]
```

- Group: Hash
- HotKV Cloud: all plans
- On-Premise: no license needed

`HIMPORT SET` makes the hash at `key` from the values given, matched in order
with the field names that [HIMPORT PREPARE](https://docs.hotkv.com/commands/himport-prepare/index.md) stored
under `name`. A hash the key already held is replaced. The number of values
must equal the number of prepared fields. A key that holds another type is
refused with `WRONGTYPE` and left as it is.

The hash is read like any other (`HGETALL`, `HGET`).

## Return value

Simple string `OK` in RESP2 and RESP3. Errors:

| Error | Cause |
| --- | --- |
| `ERR no such fieldset` | `name` was not prepared on this connection, or was discarded. |
| `ERR value count does not match fieldset field count` | The number of values differs from the number of fields. |
| `WRONGTYPE Operation against a key holding the wrong kind of value` | The key holds another type. |

## Examples

```
127.0.0.1:6379> HIMPORT PREPARE person name age city
OK
127.0.0.1:6379> HIMPORT SET account:1 person Ada 36 London
OK
127.0.0.1:6379> HIMPORT SET account:2 person Grace 85 NYC
OK
127.0.0.1:6379> HGETALL account:1
1) "age"
2) "36"
3) "city"
4) "London"
5) "name"
6) "Ada"
127.0.0.1:6379> HIMPORT SET account:3 nosuch a b c
(error) ERR no such fieldset
127.0.0.1:6379> HIMPORT SET account:4 person only-one
(error) ERR value count does not match fieldset field count
127.0.0.1:6379> SET plain x
OK
127.0.0.1:6379> HIMPORT SET plain person a b c
(error) WRONGTYPE Operation against a key holding the wrong kind of value
```

## Compatibility

A Redis 8.10 command.

## See also

[HIMPORT PREPARE](https://docs.hotkv.com/commands/himport-prepare/index.md), [HSET](https://docs.hotkv.com/commands/hset/index.md),
[HGETALL](https://docs.hotkv.com/commands/hgetall/index.md)