Edit database view records within LibreOffice Base

I created a view in my MariaDB database:

CREATE
    ALGORITHM = MERGE
    DEFINER = 'user'@'%'
    SQL SECURITY DEFINER
    VIEW Test
    AS
        SELECT
            Students.id AS studentId,
            StudentGroups.id AS groupId
        FROM
            Students
                INNER JOIN StudentGroups
                    ON Students.id = Groups.studentId;

When I check as explained here if the view is updatable, it tells me yes:

SELECT
    IS_UPDATABLE
FROM
    INFORMATION_SCHEMA.VIEWS
WHERE
    TABLE_NAME = `Test`;

But when opening the view from LibreOffice Base (in the table tab), records cannot be updated.

Am I doing it wrong or does LibreOffice disallow edition?

I’ve never seen any view being editable in Base, not even SELECT * FROM DATA.

Forms allow editing related data in Base. You can build arbitrary hierarchies of forms and sub-forms where any record set is editable, if it is based on a single table including its primary key.

Okey, I don’t really understand why it works this way (the fact that LibreOffice Base doesn’t allow updating views when the database server itself allows it) but thank you for the answer!

I think (guess), the reason has something to do with the way how Base parses queries and parameters and then decides by itself if the result should be editable or not. Views are always parsed by the database engine. In this mode, called “direct SQL”, all record sets are read-only, and query parameters are unsupported.

1 Like