Skip to content

Instantly share code, notes, and snippets.

@lukesutton
Created May 27, 2010 05:49
Show Gist options
  • Save lukesutton/415513 to your computer and use it in GitHub Desktop.
Save lukesutton/415513 to your computer and use it in GitHub Desktop.
Dolt.procedure do
name :get_jammy
single_parition true
partition_info "Reservation.FlightInfo", 0
sql :number_of_seats, %{
SELECT NumOfSeats, COUNT(ReserveID) AS SeatsInUse
FROM Flight AS F, Reservation AS R
WHERE F.FlightID=R.FlightID AND R.FlightID = ?;
}
run do
queue :number_of_seats, :flight_id
execute
abort_if_empty!
set :seats, table(0, 0, "NumOfSeats")
set :in_use, table(0, 0, "SeatsInUse")
returns subtract(:in_use).from(:seats)
end
end
stack = []
stack << [:queue, :number_of_seats, :flight_id]
stack << [:execute]
stack << [:abort_on_empty]
stack << [:returns, [:subtract, [:table, 0, 0, "SeatsInUse"], [:table, 0, 0, "NumOfSeats"]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment