Table creation/Postal addresses: Difference between revisions

Content added Content deleted
(mssql = transact-sql)
Line 2:
In this task, the goal is to create a table to store addresses.
 
=={{header|ALGOL 68}}==
{{works with|ALGOL 68|Standard - no extensions to language used}}
{{works with|ALGOL 68G|Any - tested with release mk15-0.8b.fc9.i386}}
<!-- {{does not work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release 1.8.8d.fc9.i386 - needed formatted transput}} -->
<lang algol>MODE ADDRESS = STRUCT(
INT page,
FLEX[50]CHAR street,
FLEX[25]CHAR city,
FLEX[2]CHAR state,
FLEX[10]CHAR zip
);
FORMAT address repr = $"Page: "gl"Street: "gl"City: "gl"State: "gl"Zip: "gll$;
 
INT errno;
FILE sequence; errno := open(sequence, "sequence.txt", stand back channel);
SEMA sequence sema := LEVEL 1;
 
OP NEXTVAL = ([]CHAR table name)INT: (
INT out;
# INT table page = 0; # # only one sequence implemented #
# DOWN sequence sema; # # NO interprocess concurrency protection #
on open error(sequence,
(REF FILE f)BOOL: (
reset(sequence); #set(table page,1,1);#
put(sequence, 0);
try again;
FALSE
)
);
try again:
reset(sequence); #set(table page,1,1);# get(sequence,out);
out +:=1;
reset(sequence); #set(table page,1,1);# put(sequence,out);
# UP sequence sema; #
out
);
 
OP INIT = (REF ADDRESS self)REF ADDRESS: ( page OF self := NEXTVAL "address"; self);
 
REF ADDRESS john brown = INIT LOC ADDRESS;
 
john brown := (page OF john brown, "10 Downing Street","London","England","SW1A 2AA");
 
printf((address repr, john brown));
 
FILE address table;
errno := open(address table,"address.txt",stand back channel);
# set(address table, page OF john brown,1,1); - standard set page not available in a68g #
put bin(address table, john brown);
close(address table)</lang>
Output:
<pre>
Page: +1
Street: 10 Downing Strreet
City: London
State: England
Zip: SW1A 2AA
</pre>
=={{header|DB2 UDB}}==
CREATE TABLE Address (