EditTable report with Multiple parameters, not editing

(8 posts) (2 voices)

Tags:

No tags yet.

  1. KnuttyKitten, Member

    I'm also having problems with my edit report.

    the report that displays the list
    select 'dbr.editable', 'UnitCost', 'sp_DBR_Update_PUC', 'setid=SettlementID','msku=Sku', "options={'onblur':'', 'callback':autosum_int}";

    the report that is supposed to update the database (and doesn't)
    CREATE PROCEDURE sp_DBR_Update_PUC( setid bigint(250), msku varchar(250) CHARSET utf8, inLogin varchar(30), inValue decimal(6,2))

    select cid into @uid from dbname.users where username = inLogin;

    if (inValue>0) then update dbname.AzTransactionRpts a set a.puc = inValue where a.cid = @uid and a.settlement id = setid and a.sku = msku;

    else /* Reject the update, return the original value */ select a.puc from dbname.AzTransactionRpts a where a.cid = @uid and a.settlement id = setid and a.sku = msku; end if;

    END $$

    I can't even figure out if the variables are being passed correctly. :( but the database is not being updated at all, thus the original report where the edit is happening reverts back to zero.

    Note, If I assign the 'sp_DBR_Update_PUC' to a report and manually fill in the prompted variables, the database does update. so I know the update query is correct.

    I need to pass all three qualifications (loginID translated to uid), and 2 columns (settlementid & msku) to be sure to limit the editing to the proper rows.

    My issue I think is passing the variables from one report to the other.

    Thanks in advance!
    Tina

  2. myDBR Team, Key Master

    Hi,
    the code looks ok. You did not show the actual report context so the problem might be there.

    To see the passed parameters, you can create a log table and log the parameters in the editing procedure:

    First create a log table. You can use a table with exactly same columns and datatypes or just use a generic one and concatenate the values:

    create table param_log (
    log text
    );

    Then add the logging to the beginning of the editing sp_DBR_Update_PUC:

    insert into param_log
    select concat( setid,':', msku, ':', inLogin, ':', inValue);

    Then just do the editing and see what the content of the file is.

    --
    myDBR Team

  3. KnuttyKitten, Member

    Hi,

    Thank you for the reply,

    unfortuntatly your logging suggestion isn't populating the log table

    here is the full report for the list

    DROP PROCEDURE IF EXISTS sp_DBR_SKU_Profitabilty $$ CREATE PROCEDURE sp_DBR_SKU_Profitabilty(settlement bigint(250), inLogin varchar(30)) BEGIN

    select cid into @cid from dsguru_eBayMadeEasy.users u where u.username = inLogin;

    Select date(Min(a.date/time) )as 'Start Date', date(max(a.date/time)) as 'End Date' from dsguru_eBayMadeEasy.AzTransactionRpts a where a.settlement id = settlement and a.cid = @cid;

    drop table if exists SkuSums;

    CREATE TEMPORARY TABLE IF NOT EXISTS SkuSums AS select a.settlement id as 'Setid', a.sku as 'msku', sum(a.quantity) as 'TotalQty', sum(a.total)-sum(a.sales tax collected) as 'Net', sum(a.puc) as 'ExtCost', sum(a.total)-sum(a.sales tax collected)-sum(a.puc) as 'Profit' from dsguru_eBayMadeEasy.AzTransactionRpts a where a.cid = @cid and Type='Order' and a.settlement id = settlement group by a.settlement id, a.sku;

    select '' as '------------------- SKU Profitablilty per period -----------------';

    select 'dbr.editable', '[UnitCost]', 'sp_DBR_Update_PUC', 'uid=cid', 'setid=SettlementID', 'msku=Sku'; select 'dbr.sum',6,7; select 'dbr.colstyle', 'SettlementID', mydbr_style('NumAsStr'); select 'dbr.colstyle', 'ROI', '%.0f %'; select 'dbr.colstyle', 'UnitCost', '[background: #d0edfe;]';

    select a.cid as 'cid', a.settlement id as 'Settlement ID[SettlementID]', a.sku as 'Sku[Sku]', a.description as 'Description', sum(a.quantity) as 'Qty', sum(a.total)-sum(a.sales tax collected) as 'Net Net Income', s.Profit as 'Profit', s.ExtCost as 'Extended Cost', sum(case when s.ExtCost > 0 then ((s.Profit / s.ExtCost)*100) else ' ' end) as 'ROI' , a.puc as 'Unit Cost[UnitCost]' from dsguru_eBayMadeEasy.AzTransactionRpts a inner join SkuSums s on s.msku = a.sku and s.Setid = a.settlement id where a.cid = @cid and Type='Order' and a.settlement id = settlement group by a.settlement id, a.sku order by a.settlement id desc, a.sku desc;

    END $$

    here is the full code for the edit report
    DROP PROCEDURE IF EXISTS sp_DBR_Update_PUC $$ CREATE PROCEDURE sp_DBR_Update_PUC( uid int, msku varchar(250) CHARSET utf8, setid bigint(250), inValue decimal(6,2)) BEGIN

    insert into dsguru_eBayMadeEasy.param_log select concat( uid,':', setid,':', msku, ':', inLogin, ':', inValue);

    if (inValue>0) then

    update dsguru_eBayMadeEasy.AzTransactionRpts a set a.puc = inValue where a.cid = uid and a.settlement id = setid and a.sku = msku;

    else select a.puc from dsguru_eBayMadeEasy.AzTransactionRpts a where a.cid = uid and a.settlement id = setid and a.sku = msku; end if;

    END $$

    here is the path to the new param_log table

    [code] Server: localhost » Database: dsguru_eBayMadeEasy » Table: param_log

    (and yes all those db column names are surrounded by the `, they are showing brown in the editor so I think the spaces in column names isn't the issue. The table column names can not be changed due to code for importing the data into the database.)

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

    I was exploring the other alternatives to editing the cost field and I was able to get the the popup window (via dbr.report) to edit the field and refresh the table, unfortunately I don't know how to display the msku and description contents as un-editiable fields. If I use the = they don't display. If I use the pop up window I would want the only field editable is the cost. The user would need to know what the sku and description of the item they are about to edit.

    Thanks in Advance!

  4. myDBR Team, Key Master

    Try to create the param_log to the mydbr-database so you can be sure myDBR has insert rights to the table.

    What is the 'NumAsStr' format?

    if the problem persists, send the output of the sp_DBR_SKU_Profitabilty report with '&export=sql' added to the URL to support email.

    --
    myDBR Team

  5. KnuttyKitten, Member

    NumAsStr column %d

    so the system doesn't put commas into the sku

  6. KnuttyKitten, Member

    I was exploring the other alternatives to editing the cost field and I was able to get the the popup window (via dbr.report) to edit the field and refresh the table, unfortunately I don't know how to display the msku and description contents as un-editiable fields. If I use the = they don't display. If I use the pop up window I would want the only field editable is the cost. The user would need to know what the sku and description of the item they are about to edit.

  7. KnuttyKitten, Member

    Hi again

    re: if the problem persists, send the output of the sp_DBR_SKU_Profitabilty report with '&export=sql' added to the URL to support email.

    I'm sorry I don't understand this request. (I've only been in the system for less than a month)

    and no logs if I put the param_log table in the MyDBR database and update the edit sp

    Thanks
    Tina

  8. myDBR Team, Key Master

    Tina,
    when you run the report and add '&export=sql' to the report URL, myDBR will generate the report as SQL. This allows for us to rerun the report without your tables / data.

    Save the report SQL output in a text file and send it to support@mydbr.com. The email will create a support ticket which we can then process.

    --
    myDBR Team


Reply

You must log in to post.