I have tried to execute the following script:
SET TERM !! ;
EXECUTE BLOCK AS
DECLARE I INTEGER;
BEGIN
I = 296;
WHILE (I < 500) DO
BEGIN
UPDATE DD_TABLE SET DATA_FLOW = DATA_RAW
WHERE DATA_COUNTER = I
I = I + 1;
END
END!!
SET TERM;!!
and I got the error:
Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Token unknown - line 15, column 4
I'm not sure exactly what I missed.
Related
I am facing SQL exception while running below query in db2 database.
UPDATE TRINITI.T_PARENT_LOTS_API
SET ACTION_CODE = TXN_CODE19_18_FROP4000_TO4000.TXN_CODE19_18_FROP4000_TO4000_TMDV_TXN_CMD,
NEW_FACTORY_NAME = TXN_CODE19_18_FROP4000_TO4000.TXN_CODE19_18_FROP4000_TO4000_TMDV_SHIP_TO_CD,
OLD_OPERATION = '' '',
NEW_OPERATION = '' '',
NEW_TXN_QTY = TXN_CODE19_18_FROP4000_TO4000.TXN_CODE19_18_FROP4000_TO4000_TMDV_TXN_QTY2,
TRANSFER_FACTORY_NAME = TXN_CODE19_18_FROP4000_TO4000.TXN_CODE19_18_FROP4000_TO4000_TMDV_TRANSFER_FACTORY_NAME,
SUBINV_CODE = TXN_CODE19_18_FROP4000_TO4000.TXN_CODE19_18_FROP4000_TO4000_TMDV_SUBINV_CODE,
TRANSFER_SUBINV_CODE = TXN_CODE19_18_FROP4000_TO4000.TXN_CODE19_18_FROP4000_TO4000_TMDV_TRANSFER_SUBINV_CODE,
NEW_BOM_LEVEL = '' DBK '',
NEW_UOM_CODE = TXN_CODE19_18_FROP4000_TO4000.UOM
Where TRINITI.T_PARENT_LOTS_API.ACTION_CODE Is null
And ((TRINITI.T_PARENT_LOTS_API.OLD_STATE_ID = '18' And
TRINITI.T_PARENT_LOTS_API.NEW_OPERATION = '4000' And
TRINITI.T_PARENT_LOTS_API.OLD_OPERATION = '4000' And
TRINITI.T_PARENT_LOTS_API.COMMENTS = 'SHIP')
Or (TRINITI.T_PARENT_LOTS_API.OLD_STATE_ID = '19'
And TRINITI.T_PARENT_LOTS_API.NEW_OPERATION = '4000'
And TRINITI.T_PARENT_LOTS_API.COMMENTS = 'RECV')
)
And TRINITI.T_PARENT_LOTS_API.TRANSACTION_ID = TXN_CODE19_18_FROP4000_TO4000.CONTROL_NO
Not getting where query went wrong.
SQL0104N is a syntax error. It says it is expecting another ")" somewhere. Looking at your statement, count how many "(" you open and how many closing ")" you have. That seems correct. Now, because Db2 complains about end of statement, you need to check if the statement is really passed to Db2 as given above.
Is there an additional character or formatting that indicates "end of statement"?
I would like to run 2 queries within the same code, but I cannot figure out how to. The 2 queries are as follows:
UPDATE usercomp
SET shiftstart = shifts.shiftstarttime,
shiftfinish = shifts.shiftfinishtime
FROM shifts
WHERE usercomp.shiftid = shifts.id
SET break1start = breaks.timestarted,
break1finish = breaks.timefinished,
break1duration = breaks.duration
FROM breaks
WHERE usercomp.break1id = breaks.id;
I am getting the following error:
ERROR: syntax error at or near "SET"
LINE 6: SET break1start = breaks.timestarted,
Can anyone help ?
You need to write two UPDATE statement
UPDATE usercomp
SET shiftstart = shifts.shiftstarttime,
shiftfinish = shifts.shiftfinishtime
FROM shifts
WHERE usercomp.shiftid = shifts.id;
UPDATE usercomp
SET break1start = breaks.timestarted,
break1finish = breaks.timefinished,
break1duration = breaks.duration
FROM breaks
WHERE usercomp.break1id = breaks.id;
I am getting the Error using database.jdbc.connection/fastinsert (line 140)
Table variables and insert 'fieldnames' do not match. error while exporting data from matlab to sql. Can you please help me out.
Below is my code.
conn = database('rScenariosDB','NCAT\aabhaler','','Vendor','Microsoft SQL Server','Server','A0030110GB6S942','AuthType','Windows','portnumber',1433);
for i = 1 : rScenarioCnt
if rScenario{i}.status == 1
ECostMax(i) = rScenario{i}.ECostMax;
CO2EmisMax(i) = rScenario{i}.CO2EmisMax;
ECost(i) = rScenario{i}.YearAlloc.ECost;
CO2Emis(i) = rScenario{i}.YearAlloc.CO2Emis ;
EmisCostYear(i) = rScenario{i}.YearAlloc.EmisCostYear ;
CO2EmisYear(i) = sum(rScenario{i}.YearAlloc.CO2EmisYear);
end
end
rId = 1 : rScenarioCnt ;
colnames={'rScenarioId' ,'ECostMax' , ' CO2EmisMax','ECost' ,'CO2Emis', 'EmisCostYear', 'CO2EmisYear' };
data = table(rId',ECostMax',CO2EmisMax',ECost',CO2Emis',EmisCostYear', CO2EmisYear','VariableNames',colnames);
tablename = 'rScenarios';
fastinsert(conn,tablename,colnames,data);
curs=exec(conn,'select * from [dbo].[rScenarios]');
curs=fetch(curs);
disp(curs.Data);
close(curs);
close(conn);
So i have a tool that call procedure.
Tool looks like that:
call Attach_test('select TTID from alerts.status where Class in (73000,8891) and to_int(TTID) > 0 and ServerSerial in ($selected_rows.Serial)',[ $selected_rows.Serial ]); flush iduc;
it should get TTID (that field have only one of many selected alarms ) and array of server serials of selected alarms.
Then all this data is transfered to SQL procedure that looks like:
declare
tempservser integer; k integer;
begin
for k = 1 to array_len(serserial) do
begin
set tempservser = serserial[k];
update alerts.status set ParentTT = parentttid, TTFlag = 2 where ServerSerial = tempservser and TTID = '' ;
end;
end
Parameters:
in parentttid Char(11)
in serserial array of Integer
And here comes the trouble - procedure do nothing. There is no errors or something but there is no update on selected alarms.
I want it to work like this - you select many alarms with only one that have TTID, run this tool that set ParentTT = TTID on every other of selected alarms.
OS ver. 8.1
Sorry for my english
I figured out how to do it:
Tool
call AttachSelectedToTTID([ $selected_rows.Serial ],[ $selected_rows.ParentTT ]);
flush iduc;
Procedure
declare
tempservser integer; k integer;n integer;partt char(15);
begin
for n = 1 to array_len(ttid) do
begin
if (ttid[n] != '' ) then
set partt = ttid[n];
end if;
end;
for k = 1 to array_len(serserial) do
begin
set tempservser = serserial[k];
update alerts.status set ParentTT = partt,TTFlag = 2 where Serial = tempservser and TTID = '';
end;
end
Parameters:
in ttid array of Char(15)
in serserial array of Integer
I have the following code.
CREATE OR REPLACE procedure BEFOR_VIP_RESET.CP_UPDATE_DTL_YHJ_SUM
is
cursor cur IS SELECT TRIM(DC.INV_NUM) INV_NUM,
SUM(DC.REDEEMVALUE) SUM_REDEEMVALUES
FROM DINV_COUPON DC
GROUP BY DC.INV_NUM;
INT_COUNT_DINV_COUPON_BY_INV number;
begin
for RUR1 in cur LOOP
BEGIN
SELECT COUNT(*) INTO INT_COUNT_DINV_COUPON_BY_INV
FROM DINV_DTL_YHJ DDY
WHERE TRIM(DDY.INV_NUM) = TRIM(RUR1.INV_NUM);
IF (INT_COUNT_DINV_COUPON_BY_INV != 0)
THEN
UPDATE DINV_DTL_YHJ D_D_Y
SET D_D_Y.REDEEMWAY = (RUR1.SUM_REDEEMVALUES/INT_COUNT_DINV_COUPON_BY_INV); --this error
END IF;
END;
END LOOP;
end CP_UPDATE_DTL_YHJ_SUM;
Error message:
ORA-06550: line 12, column 27:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
. ( * # % & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like
When I debug I find INT_COUNT_DINV_COUPON_BY_INV and RUR1.INV_NUM have the right value.
When I change:
UPDATE DINV_DTL_YHJ D_D_Y
SET D_D_Y.REDEEMWAY = (RUR1.SUM_REDEEMVALUES/INT_COUNT_DINV_COUPON_BY_INV);
to
UPDATE DINV_DTL_YHJ D_D_Y
SET D_D_Y.REDEEMWAY = 66;
I also have the same error message.
It looks as if you forgot a WHERE clause on your UPDATE statement. Was this intentional?
Maybe something like:
WHERE TRIM(DDY.INV_NUM) = TRIM(RUR1.INV_NUM);