x89
x89

Reputation: 3460

syntax to pass multiple variables into query

When I try adding 2 columns, my query works fine

('INSERT INTO TABLE (JSON_S, LOAD_DATE) SELECT PARSE_JSON(?), CURRENT_TIMESTAMP', [[content]] )

However, when I try to add another variable (string):

('INSERT INTO TABLE (JSON_S, LOAD_ID, LOAD_DATE) SELECT PARSE_JSON(?), (?), CURRENT_TIMESTAMP', [[content]], load_id)

I get an error that:

Bind variable ? not set.

What's the correct syntax?

Upvotes: 0

Views: 242

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175706

Arguments should be provided as tuple:

con.cursor().execute("INSERT INTO TABLE (JSON_S, LOAD_ID, LOAD_DATE) SELECT PARSE_JSON(?), ?, CURRENT_TIMESTAMP()"
    ,(content, load_id))

Upvotes: 1

Related Questions