-- name: CreatePlannedConsignmentTpDetails :one
INSERT INTO plannedconsignments_tpdetails (
    plannedconsignments_id,
    country_id,              
    modesoftransport_id,
    exit_date,
    exitpoint_id,
    airline_id,
    exithandler_id
 ) VALUES (
    $1,
    $2,
    $3,
    $4,
    $5,
    $6,
    $7
) 
RETURNING *;

 -- name: GetPlannedConsignmentTpDetails :one
SELECT * FROM plannedconsignments_tpdetails
WHERE id = $1 LIMIT 1;

-- name: GetPlannedConsignmentNoTpDetails :one
SELECT * FROM plannedconsignments_tpdetails
WHERE plannedconsignments_id = $1 LIMIT 1;

-- name: ListPlannedConsigmentsTpDetails :many
SELECT * FROM plannedconsignments_tpdetails
ORDER BY id LIMIT $1
OFFSET $2;

-- name: UpdatePlannedConsigmentTpDetails :one
UPDATE plannedconsignments_tpdetails
  set 
    country_id = $2,              
    modesoftransport_id = $3,
    exit_date = $4,
    exitpoint_id = $5,
    airline_id = $6,
    exithandler_id = $7
WHERE id = $1
RETURNING *;

-- name: DeletePlannedConsigmentTpDetails :exec
DELETE FROM plannedconsignments_tpdetails WHERE id= $1;
