Wednesday, November 24, 2021

Tip of the Day: PROJECT and Default Column Definitions
Product.......: R:BASE X.5 and R:BASE X.5 Enterprise (Version 10.5)
Build.........: 10.5.4.11118 or higher
Sections......: Commands
Keywords......: PROJECT, Column, Default, Table, USING, SELECT

Did you know that the PROJECT command was enhanced to now transfer default column definitions to the newly created table?

Similar to table comments, the PROJECT command now transfers default column definitions to the newly created table. If you want to change the projected default column definition, define the desired default column definition with the ALTER TABLE command.

The PROJECT command is used to create a new table from an existing table or view. The new table can be a copy of an existing table, a copy of an existing table with the rows sorted in a different order, a duplicate of a table structure without any data, a table that contains specific rows and columns from an existing table, or a SELECT clause which specifies the columns and one or more tables or views from which to create the new table.

When not using SELECT, you must include the USING clause with the PROJECT command. The USING clause specifies the columns to be included in the new table. If you want the new table to include all the columns from an existing table, use an asterisk (*) in the clause. If you want the new table to include only specific columns from the existing table, list them in the order you want them to appear in the new table. If you want the new table to include all columns in a different order, list them in the order you want them to appear.

Using the SELECT portion, it is not necessary to create a view first in order to perform PROJECT into a new table from multiple table joins. A USING clause is not needed as all required columns are defined in the SELECT statement.

The following example create a new table from the Staff and Departments table, with the SELECT statement to specify the column and table source.

SET ERROR MESSAGE 2038 OFF
DROP TABLE StaffDepts
SET ERROR MESSAGE 2038 ON
PROJECT StaffDepts FROM +
SELECT t2.DepartmentID,t2.Description,t2.OwnerDept, +
t1.LastName,t1.FirstName,t1.PhoneExt,t2.DeptShape +
FROM Staff t1,Departments t2 +
WHERE t1.DepartmentID = t2.DepartmentID
COMMENT ON TABLE StaffDepts IS 'Staff and Departments'
RETURN

Very Best R:egards,

Razzak.

R:BASE Technologies, Inc.
https://www.rbase.com


--
For group guidelines, visit 
http://www.rbase.com/support/usersgroup_guidelines.php
--- You received this message because you are subscribed to the Google Groups "RBASE-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rbase-l+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rbase-l/1M73XX-1mhv5z1QVz-008ZN7%40mrelay.perfora.net.

Reply via email to