DELETE and ABORT with JSON | VantageCloud Lake - Examples: DELETE and ABORT with JSON - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Setting Up DELETE Example

Create and populate table(s) to use in subsequent example(s).

CREATE TABLE my_table (eno INTEGER, edata JSON(100)); 
INSERT INTO my_table(1, '{"name":"Cameron","age":24}'); 

Example: Using DELETE Statement

Selectively delete data that meets the criteria.

DELETE my_table WHERE CAST (edata.JSONExtractValue('$.age') AS INTEGER) = 24; 
To see the result of the DELETE, run: SELECT * FROM my_table;
*** No rows found 

Setting Up ABORT Example

Create and populate table(s) to use in subsequent example(s).

CREATE TABLE my_table (eno INTEGER, edata JSON(100));  
INSERT INTO my_table(1, '{"name":"Cameron","age":24}'); 

Example: Using ABORT Statement

Abort on a portion of the JSON instance.

ABORT 'JSON Abort' 
FROM my_table 
WHERE CAST (edata.JSONExtractValue('$.age') AS INTEGER) = 24; 
Result:
*** Failure 3513 JSON Abort.