SQLite VDBE opcode

Cast

Force the value in register P1 to be the type defined by P2.

An example

1 of the 178 statements we compiled against the sample database use Cast. This is the one with the shortest program; the rows that use Cast are highlighted.

SELECT CAST(ms AS TEXT), CAST('12' AS INTEGER) FROM tracks
addropcodep1p2p3p4p5
0Init01000
1OpenRead04040
2Rewind0900
3Column0310
4Cast16600
5String8020120
6Cast26800
7ResultRow1200
8Next0301
9Halt0000
10Transaction00101
11Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Column, Goto, Halt, Init, Next, OpenRead, ResultRow, Rewind, String8, Transaction.

What the SQLite documentation says

Force the value in register P1 to be the type defined by P2.

A NULL value is not changed by this routine. It remains NULL.

From sqlite.org's list of opcodes for SQLite 3.54.1, in the public domain. Opcodes are not a stable interface and change between releases.

← Blob · Checkpoint →