Table creation: Difference between revisions

Content added Content deleted
(added FunL)
Line 57: Line 57:


Also, a properly tuned system would likely use different code (for example, you could get better performance if you put an entire column into a box instead of introducing a new box for each element in a column).
Also, a properly tuned system would likely use different code (for example, you could get better performance if you put an entire column into a box instead of introducing a new box for each element in a column).

=={{header|FunL}}==
<lang funl>import db.*
import util.*

Class.forName( 'org.h2.Driver' )
conn = DriverManager.getConnection( "jdbc:h2:~/test", "sa", "" )
statement = conn.createStatement()
statement.execute( '''
CREATE TABLE Persons
(
PersonID int,
FirstName varchar(255),
LastName varchar(255),
Address varchar(255),
City varchar(255),
Province char(2)
)''' )
statement.execute( '''
INSERT INTO Persons VALUES
(1, 'Sylvia', 'Henry', '5896 Cotton Prairie Wharf', 'Parrsboro', 'SK'),
(2, 'Kelly', 'Saunders', '3608 Indian Island Promenade', 'Goober Hill', 'SK'),
(3, 'Vernon', 'Douglas', '394 Dusty Impasse', 'Muleshoe', 'NS'),
(4, 'Jim', 'Fleming', '2523 Quaking Fawn Trace', 'Halbrite', 'ON'),
(5, 'Roderick', 'Owens', '7596 Umber View', 'Frognot', 'SK')
''' )
statement.execute( "SELECT * FROM Persons ORDER BY LastName" )
print( TextTable.apply(statement.getResultSet()) )
conn.close()</lang>
{{out}}

<pre>
+----------+-----------+----------+------------------------------+-------------+----------+
| PERSONID | FIRSTNAME | LASTNAME | ADDRESS | CITY | PROVINCE |
+----------+-----------+----------+------------------------------+-------------+----------+
| 3 | Vernon | Douglas | 394 Dusty Impasse | Muleshoe | NS |
| 4 | Jim | Fleming | 2523 Quaking Fawn Trace | Halbrite | ON |
| 1 | Sylvia | Henry | 5896 Cotton Prairie Wharf | Parrsboro | SK |
| 5 | Roderick | Owens | 7596 Umber View | Frognot | SK |
| 2 | Kelly | Saunders | 3608 Indian Island Promenade | Goober Hill | SK |
+----------+-----------+----------+------------------------------+-------------+----------+
</pre>


=={{header|Mathematica}}==
=={{header|Mathematica}}==