Default block adapted to include domains
Here is an example of simple block which composes list of "name + domain" for a dragged table when using the Text to insert form between IBExpert's DB Explorer and the SQL Editor or Script Executive:
execute ibeblock (
StatementID variant,
SelectedNames variant,
SelectedNamesFmt variant,
SelectedTypes variant,
ParentName variant = '',
ParentNameFmt variant = '',
ParentType variant,
--------------------------------
ObjectAlias variant = '',
VarPrefix variant = '',
InsertCRLF boolean = FALSE)
RETURNS (
StatementCaptions variant,
StatementText variant = '',
DoNotFormat boolean = FALSE comment 'If TRUE, no additional formatting will be performed')
as
begin
-- Uncomment following line to avoid additional formatting of statement text
DoNotFormat = TRUE;
CRLF = ibec_CRLF();
SQLDialect = 3;
Conn = ibec_GetDefaultConnection();
if (Conn is not null) then
SQLDialect = ibec_GetConnectionProp(Conn, 'DBSQLDialect');
if (StatementID is null) then
begin
if (SelectedTypes[0] = __dboTable) then
StatementCaptions[301] = 'Name + Domain';
suspend;
exit;
end
s = '';
if (StatementID = 301) then
begin
TableName = SelectedNames[0];
for SELECT rf.rdb$field_name, rf.rdb$field_source,
f.rdb$field_type, f.rdb$field_sub_type, f.rdb$field_length, f.rdb$field_precision,
f.rdb$segment_length, f.rdb$character_length, f.rdb$field_precision
from rdb$relation_fields rf, rdb$fields f
where (rf.rdb$relation_name = :TableName) and (f.rdb$field_name = rf.rdb$field_source)
order by rf.rdb$field_position
into :fname, :dname,
:fType, :fSubType, :fLength, :fScale, :fSegLength, :fCharLength, :fPrecision
do
begin
FieldType = ibec_IBTypeToStr(fType, fSubType, fLength, fScale, fSegLength, fCharLength, fPrecision, SQLDialect);
if (InsertCRLF and (s <> '')) then
s .= CRLF;
else
s .= ' ';
s .= VarPrefix + ibec_FormatIdent(ibec_Trim(fname));
if (ibec_Copy(dname, 1, 4) <> 'RDB$') then
s .= ' ' + ibec_FormatIdent(ibec_Trim(dname));
else
s .= ' ' + FieldType;
end
s = ibec_Trim(s);
end
StatementText = s;
suspend;
end
See also:
SQL Editor / Inserting text
back to top of page
<< IBExpert "Text to insert" form default Block | IBEBlock | Joining tables from different databases >>







