CQL supports prepared statements. Using a prepared statement, Cassandra parses a query only once, but executes it multiple times with different concrete values.
In a statement, each time a column value is expected in the data manipulation and query statements, a bind variable marker can be used instead. A statement with bind variables must then be prepared. During execution of the prepared statement, concrete values for bind variables are provided in the order the bind variables are defined in the query string.
INSERT INTO playlists (id, song_order, song_id, title, artist, album) VALUES (62c36092-82a1-3a00-93d1-46196ee77204, 1, a3e64f8f-bd44-4f28-b8d9-6938726e34d4, '?', '?', '?');
UPDATE users SET name = '?', email = '?' WHERE user_uuid = ?;
DELETE email, phone FROM users USING TIMESTAMP 1318452291034 WHERE user_name = '?';
UPDATE myTable USING TTL ? SET v = 2 WHERE k = 'foo';
SELECT * FROM myTable LIMIT ?;
The exact procedure to prepare a statement and execute a prepared statement depends on the CQL driver used and is beyond the scope of this document. The Java Driver documentation includes an example.
Cassandra 2.0 and later support a query that uses bind variables even though the statement is not prepared. In Cassandra 2.0.1 (CQL 3.1.1), you can use named bind variables (:name instead of ?).