1. A programmable controller comprising: a command execution unit to execute multiple commands in a user program other than a last END command in order and that after the END command is executed by an END command processing unit, executes the commands of the user program again in order; a database storage unit to store therein a database that holds data used in a process performed by the command execution unit in a table format; a database-query-command generation unit, when the commands include a command to access the database, to convert the access command into a database query command described in a database query language; a database management unit to access the database in the database storage unit and to acquire data specified by the database query command; and an END command processing unit, after the commands in the user program are executed by the command execution unit, to execute the END command including a process of acquiring the result of executing the database query command, wherein when a process corresponding to the database query command issued is completed, the END command processing unit performs a completion checking process of writing the data acquired by the database management unit in an address specified by the command to access the database of a user-data storage unit, and when the process corresponding to the database query issued is not completed, the END command processing unit performs the completion checking process at a time of executing a next END command.