\p CREATE TABLE Client
CREATE CACHED TABLE "Client"
  ( ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL
  , nom VARCHAR(100) NOT NULL
  , lieu INTEGER NOT NULL
  , tél VARCHAR(100) DEFAULT NULL
  , mél VARCHAR(100) DEFAULT NULL
  , facturable BOOLEAN DEFAULT TRUE NOT NULL
  , CONSTRAINT "PK_Client" PRIMARY KEY(ID)
  , CONSTRAINT "FK_Client_lieu"
      FOREIGN KEY(lieu)
      REFERENCES "Lieu"(ID)
      ON UPDATE CASCADE
  );

DROP FUNCTION choisirUnClient IF EXISTS CASCADE;
CREATE FUNCTION choisirUnClient()
  RETURNS TABLE(nom_complet VARCHAR(100), ID INTEGER)
  READS SQL DATA
  BEGIN ATOMIC
    RETURN TABLE
      (SELECT nom || ' (' || "Lieu".nom || ')' AS nom_complet
             , ID
      FROM "Client"
      JOIN "Lieu" ON "Lieu".ID = "Client".lieu
      );
  END;
.;
