- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed
Closed
Copy link
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement
Description
Julian Sareyka opened SPR-8817 and commented
I have tried to setup an in-memory db with hsql. In one of my scripts there is a stored procedure. Database setup fails when executing this script.
I found out that this is due to automatic statement splitting in ResourceDatabasePopulator. Here all statements in a script are split on semicolons. So my stored procedure is cut into pieces (after p_date_value DAY;).
CREATE FUNCTION pkg_verweildauer.get_pub_ende (IN p_pub_start TIMESTAMP, IN p_date_unit VARCHAR(255), IN p_date_value NUMERIC) 
RETURNS timestamp
READS SQL DATA
BEGIN ATOMIC
DECLARE v_pub_ende timestamp;
case p_date_unit
	when 'DAYS' then
		SET v_pub_ende = p_pub_start + p_date_value DAY;
	when 'WEEKS' then
		SET v_pub_ende = TIMESTAMPADD(SQL_TSI_WEEK, p_date_value, p_pub_start);
	when 'MONTHS' then
		SET v_pub_ende = TIMESTAMPADD(SQL_TSI_MONTH, p_date_value, p_pub_start);
	when 'YEARS' then
		SET v_pub_ende = TIMESTAMPADD(SQL_TSI_YEAR, p_date_value, p_pub_start);
	else
		SET v_pub_ende = p_pub_start + 365 DAY;
end case;
RETURN v_pub_ende;
END;A simple solution would be to add a parameter to the <jdbc:script> tag to disable splitting on file basis. Unfortunately ResourceDatabasePopulator cannot be exchanged in the EmbeddedDatabaseBuilder.
I had to write a post processing bean, to add the stored function.
Affects: 3.0.5
Issue Links:
- Error when parsing PMS stored procedure script. [SPR-8884] #13525 Error when parsing PMS stored procedure script. ("is duplicated by")
- Add configurable SQL statement delimiter to ResourceDatabasePopulator and JDBC XML namespace. [SPR-7700] #12356 Add configurable SQL statement delimiter to ResourceDatabasePopulator and JDBC XML namespace. ("is duplicated by")
- Support EOF as statement separator in SQL scripts [SPR-11687] #16310 Support EOF as statement separator in SQL scripts
- Support triggers & stored procedures alongside standard statements in SQL scripts [SPR-13389] #17970 Support triggers & stored procedures alongside standard statements in SQL scripts
3 votes, 2 watchers
Metadata
Metadata
Assignees
Labels
in: dataIssues in data modules (jdbc, orm, oxm, tx)Issues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancementA general enhancement