This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE FUNCTION sales_func(employee_id int, vehicle_id int) | |
RETURNS SETOF sales | |
AS $$ | |
DECLARE | |
car_model text; | |
car_price int; | |
sales_bonus int; | |
bonus int; | |
BEGIN | |
EXECUTE 'SELECT model, sales_bonus, price FROM cars WHERE car_id = $1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flattener(array, newArray=[]) { | |
// test if parameters supplied is an array | |
if (!Array.isArray(array) && !Array.isArray(newArray)) { | |
throw new Error('parameters must be arrays!'); | |
} | |
// loop through the array | |
for (let i = 0; i < array.length; ++i) { | |
// check if element at index i is an array | |
if (Array.isArray(array[i])) { | |
// if element at index i is an array recursively call flattener function if true |
NewerOlder