Anyone who can write an APL function should be able to host it on the web.™
Rendered webpage |
APL code |
:Class SQAPLExample : MiPageSample
⍝ Control:: _.DataTable
⍝ Description:: Submit queries an SQL database using SQAPL
:field Public state←'' ⍝ holds the input from the Select
:field Public Shared States ⍝ holds the list of [;1] state names [;2] state abbbreviations
∇ Compose;data
:Access Public
Add _.h2'SQAPL/jQuery Demonstration'
:If ~0∊⍴States
Add _.h3'Zip Codes by State'
('#state' 'autofocus="autofocus" onChange="this.form.submit()"'(Add _.Form).Add _.Select(States(States[;1]⍳⊂state))).Prompt←'[Select State]'
:If state≢''
data←#.SQL.Do'ZipCodes' 'select * from ZipCodes where StateAbbr = :a<C2: order by Zipcode'state
:If 0=data.ReturnCode
Add _.DataTable data.(Columns⍪Data)
:Else
Add _.h3'Database query failed? RC = ',⍕data.ReturnCode
:EndIf
:EndIf
:Else
Add _.h3'ZipCodes database is not available! Sorry...'
:EndIf
∇
∇ Init;data
:Implements constructor :base
:Access public
States←0 2⍴''
data←#.SQL.Do'ZipCodes' 'select * from States order by StateName'
:If data.ReturnCode=0
States←⌽data.Data
:EndIf
∇
:EndClass