MySql Error Handling

(3 posts) (2 voices)
  • Started 3 years ago by ajdjackson
  • Latest reply from ajdjackson
  1. ajdjackson, Member

    Hi

    Any chance with a bit of help on this please?

    I've created a report that has a linked report attached to a button that allows the user to enter a new record. All this works fine but I would like to create a popup message that informs the user that they have attempted to add a record that already exists ie a Duplicate entry for key 'PRIMARY' - error 1062 I think.

    At the moment I display an message via dbr.text. I would like a popup message dialogue box that informs the user that the record already exists and a OK to continue that refreshes the main report. I think I would need to use some javascript here but I haven't a clue as to how to go about it.

    I've tried this and it works but not very elegant.

    if not exists (select tblContractXidJobNo from hilmark.tblsitesplotsjake where tblContractXidJobNo = concat((select Plot_Prefix from hilmark.tblsitesjake where Site_ID=inSiteID),'_',inPlotNum))

    then

    insert into hilmark.tblsitesplotsjake ( tblContractXidJobNo, Site_ID, Plot_Phase) values ( concat((select Plot_Prefix from hilmark.tblsitesjake where Site_ID=inSiteID),'_',inPlotNum),inSiteID, inPhaseID);

    select 'dbr.refresh';

    else

    select 'dbr.text', "This Plot already exists!", 'comment';

    end if;

    Many thanks

    Jake

    Posted 3 years ago #
  2. myDBR Team, Key Master

    You did not show how you call the linked report, but you can just display alert to the user instead using dbr.text.

    select 'dbr.javascript', 'alert("This Plot already exists!");';

    --
    myDBR Team

    Posted 3 years ago #
  3. ajdjackson, Member

    Hi

    Thanks for getting back.

    That worked fine - easier than I thought.

    I was calling the linked report as follows:

    select 'dbr.button', 'Enter New Plot'; select 'dbr.report', 'sp_DBR_New_Plot','createx','inSiteID=1'; select inSiteID;

    Jake

    Posted 3 years ago #

Reply

You must log in to post.