# How to pass a null value to a prepared statement with LibPQ.jl

**URL:** <https://discourse.julialang.org/t/how-to-pass-a-null-value-to-a-prepared-statement-with-libpq-jl/25068>\
**Category:** Data\
**Created:** [June 8, 2019, 6:26am UTC](https://discourse.julialang.org/t/how-to-pass-a-null-value-to-a-prepared-statement-with-libpq-jl/25068 "2019-06-08T06:26:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tencnivel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tencnivel/32/8662_2.png) [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Post date:** [June 8, 2019, 6:26am UTC](https://discourse.julialang.org/t/how-to-pass-a-null-value-to-a-prepared-statement-with-libpq-jl/25068/1 "2019-06-08T06:26:55Z")

</div>

Passing ‘nothing’ to a prepared statement throws an error

---

<div class="post-metadata">

**Author:** ![tencnivel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tencnivel/32/8662_2.png) [@tencnivel](https://discourse.julialang.org/u/tencnivel)\
**Post date:** [June 8, 2019, 6:28am UTC](https://discourse.julialang.org/t/how-to-pass-a-null-value-to-a-prepared-statement-with-libpq-jl/25068/2 "2019-06-08T06:28:07Z")

</div>

Passing ‘missing’ to a prepared statement does work

```julia
using LibPQ
conn = LibPQ.Connection("dbname=library user=library"; throw_error=true)
prepared_insert = LibPQ.prepare(conn,
                       "INSERT INTO book (title,publisher_description) VALUES (\$1, \$2);")
result = execute(prepared_insert, ["O'Neil and the Martians", missing]; throw_error=true)
close(conn)

```
