1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| CREATE DATABASE '..\Data\Base.fdb' page_size 4096 DEFAULT CHARACTER SET ISO8859_1;
-- =====================
-- création table "test"
-- =====================
create table test (
id smallint not null,
emp_no smallint not null,
lib varchar(255) not null,
constraint pk_test_id primary key (id)
);
insert into test (id,emp_no,lib) values (1, 29, '');
insert into test (id,emp_no,lib) values (2, 65, '');
insert into test (id,emp_no,lib) values (3, 144, '');
select * from test;
ID EMP_NO LIB
======= ======= ===============================================================================
1 29
2 65
3 144
commit;
-- =========================
-- Extraction et remplissage
-- =========================
SET TERM $;
execute block as
declare emp_no smallint;
declare fullname varchar(255);
begin
for execute statement 'select emp_no from test' into :emp_no do
for execute statement ('select full_name from employee where emp_no = ?')(:emp_no)
on external data source 'localhost:employee' as user 'sysdba' PASSWORD 'masterkey'
into :fullname do
update test set lib = :fullname where emp_no = :emp_no;
end$
SET TERM ;$
commit;
-- ========
-- Résultat
-- ========
select * from test;
ID EMP_NO LIB
======= ======= ===============================================================================
1 29 De Souza, Roger
2 65 O'Brien, Sue Anne
3 144 Montgomery, John
exit;
Appuyez sur une touche pour continuer... |
Partager