Row Deleting - Query

(3 posts) (2 voices)

Tags:

No tags yet.

  1. senthilselvan, Member

    Hi

    I have created a report with following SP's to delete the specific Row's in MS SQL Database. but not able to execute the report
    and delete the rows. Please check the below SP's and help me to fix this issues.

    if object_id('Patient_Data_Delete','P') is not null
    drop procedure Patient_Data_Delete
    go
    create procedure Patient_Data_Delete
    (
    @lab_id varchar(10)
    )
    AS
    BEGIN

    select 'dbr.report', 'Patient_Data_Delete1', '[del]', 'hiddendiv', 'lab_id=lab_id', 'event=click', 'callbefore=confirmdel';

    select
    a.lab_id as 'lab_id',
    BRANCH_CODE as 'BRANCH_CODE',
    b.TEST_GROUP_CODE AS 'test_group_code',
    b.Report_file as 'Report_file',
    'dbr.purehtml:<div class="i_delete"></div>' as '[del]'
    from patient_dtl a
    inner join patient_test_group_list b on a.lab_id = b.lab_id
    where a.lab_id = @lab_id

    select 'dbr.embed_object', 'hiddendiv';

    end
    go

    --------------------------------------------------------------------------------

    if object_id('Patient_Data_Delete1','P') is not null
    drop procedure Patient_Data_Delete1
    go
    CREATE PROCEDURE Patient_Data_Delete1(
    @lab_id varchar(8),
    @test_group_code varchar(25))
    as
    BEGIN

    delete from patient_test_group_list where lab_id = @lab_id and test_group_code = @test_group_code
    select 'dbr.javascript', '$(mydbr_selected_cell).parent().remove();';

    END
    go
    --------------------------------------------------------------------------------------------------------

  2. myDBR Team, Key Master

    You are almost there. Couple of things:

    1. The linked report should be a report, not just a procedure. So instead of Patient_Data_Delete1 use sp_DBR_Patient_Data_Delete1 and attach it as a report.
    2. You are using `callbefore=confirmdel`, but you do not seem to have the `confirmdel`-function declared
    3. You are not passing the `test_group_code`-parameter to the delete report

    The corrected code should look something like this:

    if object_id('sp_DBR_Patient_Demo_Update','P') is not null
    drop procedure sp_DBR_Patient_Demo_Update
    go
    create procedure sp_DBR_Patient_Demo_Update
    (
    @lab_id varchar(10)
    )
    AS
    BEGIN select 'dbr.javascript', '
    function confirmdel(o)
    {
    return confirm("Are you sure you want to delete group code ''"+$(o).parent().children().eq(1).text()+"''?");
    }' select 'dbr.report', 'sp_DBR_Patient_Data_Delete1', '[del]', 'hiddendiv', 'lab_id=lab_id', 'test_group_code=test_group_code', 'event=click', 'callbefore=confirmdel'; select
    a.lab_id as 'lab_id',
    a.BRANCH_CODE as 'BRANCH_CODE',
    b.TEST_GROUP_CODE AS 'test_group_code',
    b.Report_file as 'Report_file',
    'dbr.purehtml:<div class="i_delete"></div>' as '[del]'
    from patient_dtl a
    inner join patient_test_group_list b on a.lab_id = b.lab_id
    where a.lab_id = @lab_id select 'dbr.embed_object', 'hiddendiv'; end
    go

    And the delete report:

    if object_id('sp_DBR_Patient_Data_Delete1','P') is not null
    drop procedure sp_DBR_Patient_Data_Delete1
    go
    CREATE PROCEDURE sp_DBR_Patient_Data_Delete1(
    @lab_id varchar(8),
    @test_group_code varchar(25))
    as
    BEGIN delete from patient_test_group_list where lab_id = @lab_id and test_group_code = @test_group_code
    select 'dbr.javascript', '$(mydbr_selected_cell).parent().remove();'; END
    go

    You should also be consistent with the datatypes (is lab_id varchar(10) or varchar(8)?).

  3. senthilselvan, Member

    Team

    Thank you so much ..


Reply

You must log in to post.