Hi Pierre and thanks for your reply.
However, I don’t understand very well the example.
I was asking for an example code working in HSQLDB 1.8, which is the SQL that attach LibreOffice Base.
Could you please attach a simple demo database, with a query, using a temporary table and some comments explaining how to load the data in a temporary table.
The example I proposed was:
let’s imagine I have a very simple database. EMPLOYEES.ODB
That database have a table tbl_EMPLOYEES with 3 fields.
ID_Employee (the primary key)
EmployeeName (text field to introduce the employee’s name)
EmployeeLastname (text field to introduce the employee’s last name)
I have that database with 3 or 4 employees in it. Okay, now let’s imagine I want to create the temporary table tbl_temp_WORKERS with the following fields
ID_Worker
WorkerName
WorkerLastname
And let’s imagine I want to load all the data from the tbl_EMPLOYEES to tbl_temp_WORKERS and show the registries from the temporary table tbl_temp_WORKERS
How may I do that?
If you could attach an example database (ODB file) with a query in which you have the SQL code showing how to load the data from the table to the temporary table, I’d be grateful.
The code you attached perhaps is very difficult to understand for people starting from scratch.
With a simple code and a demo database, this would more easy to understand.
I’m a bit lost with the code you typed and I don’t understand it… sorry
Cheers
Okay, finally I managed how to add data from a real table to a temporary table
Here you have an example database you can download and you can use to do tests. This example database is in Spanish, it has many tables and we will perform a query using a temporary table example.
You can download the database here:
THIS CODE LOAD DATA FROM A REAL TABLE INTO A TEMPORARY TABLE:
//
// THIS CODE LOAD THE DATA FROM A REAL TABLE TO A TEMPORARY TABLE
//
//
// THE SELECT CREATE THE TEMPORARY TABLE ON THE FLY OBSERVE HOW IT IS NAMED "tbl_TEMPORAL"
// (FULL STOP) "the field you want to show" FOR EXAMPLE: "tbl_temporal"."Nombre" WILL SHOW THE
// FIELD NOMBRE (NAME) FROM THE TEMPORARY TABLE "tbl_temporal"
//
// SUMMARIZING WE CREATE A TEMPORARY TABLE CALLED tbl_TEMPORAL AND WE ARE SHOWING FROM
//THAT TEMPORARY TABLE THE FIELDS
//
// Nombre (name in English), "Apellido1ero" (LastName),"Apellido2Seg" (Second Lastname, in Spain
// we use two last names father and mother)
//
SELECT
"tbl_TEMPORAL"."Nombre",
"tbl_TEMPORAL"."Apellido1ero",
"tbl_TEMPORAL"."Apellido2seg"
// NOW AS USUALLY WE USE THE FROM (SELECT - FROM) AS IN ALL THE QUERIES DUE WE ARE LOADING
// DATA FROM A REAL TABLE, IT MUST BE PRESENT IN THE FROM, SO WE HAVE FROM "tbl_EMPLEADOS",
// OBSERVE WE HAVE A COMMA BECAUSE WE CONTINUE ADDING DATA TO BE SHOWN IN THE QUERY, AND
// THAT DATA IS THE DATA FROM THE TEMPORARY TABLE
//
// SO... WE HAVE FROM "tbl_EMPLEADOS",
//
// AND NOW WE PROCEED TO LOAD THE DATA USING ANOTHER SELECT FROM WE WILL SELECT ALL THE
// DATA SELECT * (ASTERISK) FROM THE REAL TABLE "tbl_EMPLEADOS" AND WE WILL LOAD THAT DATA IN
// THE TEMPORARY TABLE "tbl_TEMPORAL"
//
// AT THIS TIME WE ARE CREATING THE TEMPORARY TABLE AND ALSO LOADING ALL THE DATA IN IT. WE
// LOAD ALL THE DATA IN THE TEMPORARY TABLE USING THE SELECT * FROM AND WE DEFINE THE
// TEMPORARY TABLE USING AN ALIAS AS "tbl_TEMPORAL"
FROM "tbl_EMPLEADOS",
( SELECT *
FROM "tbl_EMPLEADOS") AS "tbl_TEMPORAL"
// FINALLY WE DEFINE A RELATIONSHIP BETWEEN THE REAL TABLE tbl_EMPLEADOS AND THE TEMPORARY
// TABLE tbl_TEMPORAL FOR THAT WE STABLISH THE RELATIONSHIP USING THE WHERE AND RELATING
// THE PRIMARY KEY FIELD OF BOTH TABLES SEE THE FIELD ID_Empleados IS PRESENT IN BOTH TABLES
// THE REAL ONE tbl_EMPLEADOS AND THE TEMPORARY TABLE tbl_TEMPORAL
WHERE "tbl_EMPLEADOS"."ID_Empleados" = "tbl_TEMPORAL"."ID_Empleados"
THE CODE WITHOUT COMMENTARIES IS AS FOLLOWS
SELECT
"tbl_TEMPORAL"."Nombre",
"tbl_TEMPORAL"."Apellido1ero",
"tbl_TEMPORAL"."Apellido2seg"
FROM "tbl_EMPLEADOS",
( SELECT *
FROM "tbl_EMPLEADOS") AS "tbl_TEMPORAL"
WHERE "tbl_EMPLEADOS"."ID_Empleados" = "tbl_TEMPORAL"."ID_Empleados"