SQL Method Examples

The following are some basic database Method examples:

Query

	for each { variable } in { table }
	
	where { condition }
	do
	{ body }
	end
	

Insert

	INSERT INTO { table }({ column1, column2, ... })
	VALUES({ val1, val2, ... });
	

Delete

	DELETE FROM { table }
	WHERE { condition };
	

Update

	UPDATE { table }
	SET { column1 = value1, column2 = value2, ... }
	WHERE { condition };
	

Exists

	select Name, Skill from EMP where EXISTS
	    select * from EMP where EMP.Name = empName
	group by Name
	having COUNT(Skill) > 1);
	

Primary Key

If the Table has a primary key, the following methods are available:
  • load() : Loads the record if the primary key is set. Returns a boolean indicating if the record was found.
  • store() : Inserts or updates the record in the database. The primary key must be set.
  • delete() : Deletes the record in the database. The primary key must be set.