# wrong number of arguments to function substr() (SQLite)

Source: https://sqlstreak.com/sql/errors/wrong-number-of-arguments-to-function · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**Short answer:** The function was called with too few or too many arguments. `substr` needs at least a string and a start position: `substr(name, 1, 3)`. SQLite says so directly; PostgreSQL reports that no function with that argument list exists.

## The exact messages

- PostgreSQL: `ERROR: function substr(text) does not exist`
- SQLite: `wrong number of arguments to function substr()`

## How PostgreSQL prints it

```
ERROR:  function substr(text) does not exist
LINE 1: SELECT substr(name) AS short
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
```

## Why it happens

### A missing argument

`substr(name)`, `round()`, `replace(x, 'a')`: each needs more.

### An extra argument

`round(x, 1, 2)` or a function from another database with a different signature.

### A misplaced bracket

`substr(name, 1), 3)` closes the call early, leaving the 3 outside.

## The broken query

```sql
SELECT substr(name) AS short
FROM pets;
```

## The fix

```sql
SELECT substr(name, 1, 3) AS short
FROM pets
ORDER BY id
LIMIT 5;
```

Text, start position and length: the first three letters.

| short |
| --- |
| Bis |
| Moc |
| Pic |
| Lun |
| Waf |
