on 06-01-2022 3:20 PM
I am trying to update my database using a command in my crystal sub report with a parameter. I am using the following command in my subreport to test my functionality.
Declare
R_Inv5 varchar(30);
LABELID NUMBER(9,0);
begin
Update arinvt set cuser5 = '66666' where id = 202685;
if {?Pm-MASTER_LABEL.ID} is null then
select 9385776 into LABELID from DUAL;
else
select {?Pm-MASTER_LABEL.ID} into LABELID from DUAL;
end if;
update master_label set inv_cuser5 = '666769'
where id = LABELID;
update lminvtry set inv_cuser5 = '8884444' where master_label_id = 9385776;
select 9378870 into LABELID from DUAL;
end;
The highlighted line where I Have hardcoded the master_label_id appears to be executed but the command using the {?Pm-MASTER_LABEL.ID} parameter does not appear to execute.
When I use the parameter in a select command its appears to work so the parameter value appears to get passed into the command correctly.
select m.inv_cuser5,l.inv_cuser5 as luser5,{?Pm-MASTER_LABEL.ID} as id from master_label m
join lminvtry l on l.master_label_id = m.id
where m.id = {?Pm-MASTER_LABEL.ID}
ID from above displays on subreport with correct value.
Be careful doing updates using CR, if Verify Database options are enabled it can run the query 2 times causing problems...
As Dell suggest, avoid doing this...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Another option is to use a Crystal UFL (User Function Library) that adds functions to Crystal so formulas can execute SQL statements.
A list of 3rd-party UFLs is maintained here .
At least one of these UFLs provides functions to trigger dynamic SQL statements from Crystal Reports formulas.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Crystal is not really intended to be used to update data. However, you could try this instead (because you don't need to use "Select" to set the value of a variable in Oracle):
Declare
R_Inv5 varchar(30);
LABELID NUMBER(9,0);
begin
Update arinvt set cuser5 = '66666' where id = 202685;
if {?Pm-MASTER_LABEL.ID} is null then
LABELID := 9385776 ;
else
LABELID := {?Pm-MASTER_LABEL.ID};
end if;
update master_label
set inv_cuser5 = '666769'
where id = LABELID;
update lminvtry
set inv_cuser5 = '8884444'
where master_label_id = 9385776;
select 9378870 into LABELID from DUAL;
end;
If that doesn't work, you might have to create a stored procedure that will do the update and return a dataset - even if it's a single field - in an InOut parameter.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
75 | |
9 | |
8 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.