tePLSQL icon indicating copy to clipboard operation
tePLSQL copied to clipboard

Subsequent calls to render() append template result to previous calls' template results

Open salahkamel opened this issue 4 years ago • 6 comments

Hi there,

I am new to tePLSQL and I am facing an issue when trying to use a very basic example. When calling several times render() or process() within the same session, it seems that the result of an execution includes the result of the previous execution(s)...

To demonstrate this, here is the simple script that I have been using:

/*
** Script showing issue with tePLSQL
**
*/

/* 1. create a temp table to store tePLSQL results */
drop table TMP_RESULTS;
create table TMP_RESULTS(K number primary key, RES CLOB);

/* 2. create a simple template that displays current date */
delete from TE_TEMPLATES where NAME = 'salah.firstTest';

insert into TE_TEMPLATES( NAME, TEMPLATE )
values (
'salah.firstTest', 
'Today''s date is <%= to_char(systimestamp, ''dd-mon-yyyy hh24:mi:ss.ff'') %>
'
);

commit;

/* 3. Call render or process() twice and notice that the second execution includes the results of the first execution ! */
declare
    res1 clob := NULL;
    res2 clob := NULL;
begin
    /* Execute first call... so far, so good */
    res1 := teplsql.process(p_template_name => 'salah.firstTest');
    insert into TMP_RESULTS(K, RES) values (1, res1);
    /* Execute second call: result will be (res1 || res2) !!!!*/
    res2 := teplsql.process(p_template_name => 'salah.firstTest');
    insert into TMP_RESULTS(K, RES) values (2, res2);

    commit;
end;
/
/* 4. See the bad news.... */
select K, RES from TMP_RESULTS order by K;

The result is the following:

K RES
1 Today's date is ( 12-feb-2021 16:26:19.078314000 )
2 Today's date is ( 12-feb-2021 16:26:19.078314000 )
Today's date is ( 12-feb-2021 16:26:19.081377000 )

Did I miss anything? Is there a global variable in the package that needs to be initialized on every run? Any other idea?

Database Version Oracle Database 12c Standard Edition Release 12.2.0.1.0 - 64bit Production

Many thanks! -Salah

salahkamel avatar Feb 12 '21 16:02 salahkamel

Which version? The latest? Or the published 1.0?

MikeKutz avatar Feb 12 '21 17:02 MikeKutz

Latest (master)

--

Salah Kamel

Chief Executive Officer https://cloud.letsignit.com/collect/bc/5e592d2168a32f000cb00b2a?p=Px7AEi8szWxWxuJyjtD5Ct2ZnTHIVkk5OAjcNQuh1nDc13KJ6KZIaXId4xpysiW2O0uozd2pB1peYcuEfgI_2YzGUFgNvHvfa15m_cWzLNt54dVfEz-HKckLARW9th6JEJ_vdwln_1HDDTCc0PKJiw==

[email protected] | +33.6.30.71.32.27 | +1.415.650.8111

Blog https://cloud.letsignit.com/collect/bc/5e592d2168a32f000cb00b2a?p=Px7AEi8szWxWxuJyjtD5Ct2ZnTHIVkk5OAjcNQuh1nDc13KJ6KZIaXId4xpysiW2O0uozd2pB1peYcuEfgI_2YzGUFgNvHvfa15m_cWzLNs4MiId05rrslSfQmHgaUGmAw_2F8JFw6G5NPbLSw2bsg== | Twitter https://cloud.letsignit.com/collect/bc/5e592d2168a32f000cb00b2a?p=Px7AEi8szWxWxuJyjtD5Ct2ZnTHIVkk5OAjcNQuh1nDc13KJ6KZIaXId4xpysiW2O0uozd2pB1peYcuEfgI_2YzGUFgNvHvfa15m_cWzLNt-stN_2ah1Lc5i2wpVoWcf555c6I-m5iUENnicyN-JMg== | LinkedIn https://cloud.letsignit.com/collect/bc/5e592d2168a32f000cb00b2a?p=Px7AEi8szWxWxuJyjtD5Ct2ZnTHIVkk5OAjcNQuh1nDc13KJ6KZIaXId4xpysiW2O0uozd2pB1peYcuEfgI_2YzGUFgNvHvfa15m_cWzLNu55rIpJ2tyU4ZbySQZj6_OMO3dyg7A7LqLEgdQhCy53ahA8fSF2EWwNO7eiyX5nvI= | Learn More https://cloud.letsignit.com/collect/bc/5e592d2168a32f000cb00b2a?p=Px7AEi8szWxWxuJyjtD5Ct2ZnTHIVkk5OAjcNQuh1nDc13KJ6KZIaXId4xpysiW2O0uozd2pB1peYcuEfgI_2YzGUFgNvHvfa15m_cWzLNt54dVfEz-HKckLARW9th6J0_SZcMSCyhGC-4OKAFuuqtPL09J9JQkY14YRIgOfoBQ= https://cloud.letsignit.com/collect/b/60251921d4d73667c1862d05?p=Px7AEi8szWxWxuJyjtD5Ct2ZnTHIVkk5OAjcNQuh1nDc13KJ6KZIaXId4xpysiW2O0uozd2pB1peYcuEfgI_2YzGUFgNvHvfa15m_cWzLNvJcqBQb1sNWvPlOzDHqy2DJ3evGI7Z-zoZJNkH2A_WDFqIwLYkhy6wNm3aXoGMlXLmkd6QFYRuW1-of1neOxON

On Fri, Feb 12, 2021 at 6:39 PM MikeKutz [email protected] wrote:

Which version? The latest? Or the published 1.0?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/osalvador/tePLSQL/issues/53#issuecomment-778338640, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLZPNZKGKKXRR5DCCP6AKDS6VRVVANCNFSM4XQ65QYQ .

salahkamel avatar Feb 12 '21 18:02 salahkamel

If you want I can try with the published version (if you mean the one on http://osalvador.github.io/tePLSQL/)... Let me know how I can help...

salahkamel avatar Feb 12 '21 18:02 salahkamel

Confirmed. This was on master and not in the published 1.0.0 tag. Sorry for the confusion. I have now tested with 1.0.0 and the problem does not occur. Thanks for the quick turn around and good luck with fixing it in (master).

Have a nice weekend -Salah

salahkamel avatar Feb 12 '21 18:02 salahkamel

it looks like the code for #46 is missing the "clear buffer" line. I'll need to run some test to ensure it doesn't break the other process method.

I suspect you can add g_buffer2 := null; to line 1145.

Again, I'll have to test everything before I post it as a fix.

Thanks,

MK

MikeKutz avatar Feb 12 '21 19:02 MikeKutz

Thanks Mike. We'll stay on v1.0.0 for now and consider moving to master in a few weeks. Thanks for the great support.

Salah

On Fri, Feb 12, 2021, 20:59 MikeKutz [email protected] wrote:

it looks like the code for #46 https://github.com/osalvador/tePLSQL/issues/46 is missing the "clear buffer" line. I'll need to run some test to ensure it doesn't break the other process method.

I suspect you can add g_buffer2 := null; to line 1145.

Again, I'll have to test everything before I post it as a fix.

Thanks,

MK

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/osalvador/tePLSQL/issues/53#issuecomment-778421158, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADLZPN5RBUF72WQT3GJJJM3S6WCCHANCNFSM4XQ65QYQ .

salahkamel avatar Feb 13 '21 15:02 salahkamel