|
Tips&Trucs
Het
volgende script maakt een nieuw Word‑document
aan, voegt wat tekst toe en slaat de inhoud op in een
nieuw bestand. Let op: het werkt niet met Forms 9i en
hoger en het ondersteunt geen OLE‑automation.
DECLARE
‑‑ Declare the OLE objects
MyApplication OLE2.OBJ_TYPE;
MyDocuments
OLE2.OBJ_TYPE;
MyDocument
OLE2.OBJ_TYPE;
MySelection
OLE2.OBJ_TYPE;
‑‑ Declare handle to the OLE argument
list
args OLE2.LIST_TYPE;
BEGIN
‑‑ Create the Word.Application object
and make Word visible
‑‑ by setting the 'Visible' property
to true
MyApplication := OLE2.CREATE_OBJ('Word.Application');
OLE2.SET_PROPERTY(MyApplication, 'Visible', 1);
‑‑ get a handle on Documents collection
MyDocuments:= OLE2.GET_OBJ_PROPERTY(MyApplication,
'Documents');
‑‑ Add a new document to the Documents
collection
Mydocument := OLE2.INVOKE_OBJ(MyDocuments, 'Add');
‑‑ Get a handle on Selection object
MySelection:=OLE2.GET_OBJ_PROPERTY(MyApplication,
'Selection');
‑‑ Insert the text 'Hello Word97!'
into word document
OLE2.SET_PROPERTY(MySelection, 'Text', 'Hello
Word97!');
‑‑ Save the document to the filesystem
as EXAMPLE.DOC
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'C:\DOCS\EXAMPLE.DOC');
OLE2.INVOKE(MyDocument, 'SaveAs', args);
OLE2.DESTROY_ARGLIST(args);
‑‑ Close the document
OLE2.INVOKE(MyDocument, 'Close');
‑‑ Release the OLE objects
OLE2.RELEASE_OBJ(MySelection);
OLE2.RELEASE_OBJ(MyDocument);
OLE2.RELEASE_OBJ(MyDocuments);
OLE2.RELEASE_OBJ(MyApplication);
END;
Wilt
u de ASCII‑tabel afdrukken? Gebruik dan dit:
set
serveroutput on size 10240
declare
i number;
j number;
k number;
begin
for i in 2..15 loop
for j in 1..16 loop
k:=i*16+j;
dbms_output.put((to_char(k,'000'))||':'||chr(k)||' ');
if k mod 8 = 0 then
dbms_output.put_line('');
end if;
end loop;
end loop;
end;
/
show
errors
Soms
is het handig te controleren of een jaar een schrikkeljaar
is. Het volgende script biedt in zo’n geval uitkomst:
select
year,
decode( mod(year, 4), 0,
decode( mod(year, 400), 0, 'Leap Year',
decode( mod(year, 100), 0, 'Not a Leap Year', 'Leap Year')
), 'Not a Leap Year'
) as leap_year_indicator
from my_table /
|