here's an example to complete the title, this is the inner of my function (i am using postgresql but i guess this is pure SQL language)
$$
INSERT INTO foo VALUES (DEFAULT, $1) RETURNING id;
INSERT INTO link_foo_to_bar VALUES (1, <?>);
$$ language SQL;
two things to notice here, I RETURNING the id of the first insert, how to catch it as to use the returned id as the second argument of the second insert marked as < ? > ?