Skip to main content

Anyone knows why you cannot return messages to the GUI panel using a cursor? I have a procedure that processes stock counts, and when there is an issue these are determined and returned as messages to the GUI panel using a cursor. 

The problem is I see the warnings in the debug screen but not the actual panel in de the GUI. Bug?

 

 

As far I know it's possible to use cursors with a tsf_send_message in it wrapped and sending it to a panel. I assume probably is wrong with your cursor code then. Please note that if there's an abort (1) given, it code might stop executing.

The code below should call 3 time tsf_send_message.

declare @tab table (id int identity primary key, name varchar(100))
insert into @tab (name) values ('Hello')
insert into @tab (name) values ('ABC')
insert into @tab (name) values ('XYZ')

declare cur_test cursor local forward_only read_only
for
select t.name
from @tab t

open cur_test

declare @name varchar(100)

fetch next
from cur_test
into @name

while @@FETCH_STATUS = 0
begin

exec dbo.tsf_send_message @name, null, 0

fetch next
from cur_test
into @name

end

close cur_test
deallocate cur_test

See also https://docs.microsoft.com/en-us/sql/t-sql/language-elements/declare-cursor-transact-sql?view=sql-server-ver15

 

Edit: Are you sure the “Message location” is “Panel” in the “Messages” subject in the SF?


It's not exactly my scenario, because I send 1:n times the same message_id with a different content. 

So the cursor gives back the following. And I tried all message locations, I see the messages in the debug screen, but never in the GUI. 

<msg id="unable_to_process_stock_count"><text>Partijnummer 879936-0 mismatch met Charge testmr2304 of leverancier. </text></msg>

<msg id="unable_to_process_stock_count"><text>Partijnummer 872996-0 mismatch met Charge 62967 of leverancier. </text></msg>

<msg id="unable_to_process_stock_count"><text>Partijnummer 890762-0 mismatch met Charge 114256a123 of leverancier. </text></msg>

 

-- Terugmelden fouten. 
declare @c_remark varchar(max)
declare feedback cursor local static read_only forward_only for
select '<text>Partijnummer '+ convert(varchar(9),t.batch_number)
+ '-'
+ convert(varchar(2),t.batch_sub_number)
+ ' mismatch met Charge ' + isnull(t.heat_number,'')
+ ' of leverancier. </text>'
from @processed t
where disapproved = 1

open feedback
fetch next from feedback
into @c_remark

while @@fetch_status = 0
begin

exec tsf_send_message 'unable_to_process_stock_count', @c_remark, 0

fetch next from feedback
into @c_remark
end

close feedback
deallocate feedback

 


Quick update: The cause has been identified. When the variables in the translation of the message are 1-based instead of 0-based, the messages will be suppressed by the GUI. 

For instance, when the translation is as following, the message will be suppressed:

The translation must be as following to work correctly:

Having the GUI suppressing these faulty messages makes the problem difficult to identify and resolve for a developer.

A ticket will be submitted to have the GUI still show these messages partially- or unformatted, so the developer can fix the message translation accordingly.


Reply