Regarding update statement
Hi all,
In this report when i click on update radio button and write my desk company code and code and and then press enter so all values coming on text box. now i want to update this one
before its working fine but after i add at selection screen in this report because of that my update function not working........
can i create two internal table for that......... what to do.........................
can u give me suggestion in this report....
below is my whole coding........
REPORT ZDESKDLC NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA DECLARATION
TABLES : ZDESKDLC.
data: itab_zdeskdlc like zdeskdlc occurs 0 with header line.
*DATA: wa like zdeskdlc.
data wa_zdeskdlc like zdeskdlc.
*clear wa_zdeskdlc.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: CCOD LIKE ZDESKDLC-CCODE MODIF ID ABC.
PARAMETERS: DESKCODE LIKE ZDESKDLC-DESK_CODE MODIF ID ABC.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION SCREEN WITH RADIO BUTTON
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.
PARAMETERS: DELETE RADIOBUTTON GROUP G1 USER-COMMAND R DEFAULT 'X'.
PARAMETERS: UPDATE RADIOBUTTON GROUP G1.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-001.
PARAMETERS: CCOD1 LIKE ZDESKDLC-CCODE MODIF ID DEF,
DESKCD LIKE ZDESKDLC-DESK_CODE MODIF ID DEF,
SR_MANAG LIKE ZDESKDLC-SR_MANAGEMENT MODIF ID DEF,
LASTNAME LIKE ZDESKDLC-LAST_NAME MODIF ID DEF,
FIRSTNM LIKE ZDESKDLC-FIRST_NAME MODIF ID DEF,
DEPART LIKE ZDESKDLC-DEPARTMENT MODIF ID DEF,
ADM_SYS LIKE ZDESKDLC-ADMIN_SYSTEM MODIF ID DEF,
RACF_ID LIKE ZDESKDLC-RACF_ID MODIF ID DEF,
OPEN_DT LIKE ZDESKDLC-OPEN_DATE MODIF ID DEF,
CLOSE_DT LIKE ZDESKDLC-CLOSE_DATE MODIF ID DEF,
SAPUSRID LIKE ZDESKDLC-SAP_USER_ID MODIF ID DEF.
SELECTION-SCREEN END OF BLOCK B3.
AT SELECTION-SCREEN OUTPUT.
IF DELETE = 'X'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'DEF'.
SCREEN-ACTIVE = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
IF UPDATE = 'X'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC'.
SCREEN-ACTIVE = '0'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
AT SELECTION-SCREEN.
AT SELECTION-SCREEN.
*if not CCOD1 is initial.
*clear : wa_zdeskdlc.
*CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
*EXPORTING
*INPUT = CCOD1
*IMPORTING
*OUTPUT = CCOD1.
*select single * from zdeskdlc into wa_zdeskdlc
*where CCODE = CCOD1 and desk_code = deskcd.
*if sy-subrc eq 0.
**DESKCD = wa_zdeskdlc-DESK_CODE.
*SR_MANAG = wa_zdeskdlc-SR_MANAGEMENT.
*LASTNAME = wa_zdeskdlc-LAST_NAME.
*FIRSTNM = wa_zdeskdlc-FIRST_NAME .
*DEPART = wa_zdeskdlc-DEPARTMENT.
*ADM_SYS = wa_zdeskdlc-ADMIN_SYSTEM.
*RACF_ID = wa_zdeskdlc-RACF_ID.
*OPEN_DT = wa_zdeskdlc-OPEN_DATE.
*CLOSE_DT = wa_zdeskdlc-CLOSE_DATE.
*SAPUSRID = wa_zdeskdlc-SAP_USER_ID.
*endif.
*endif.
SELECT SINGLE sr_management last_name first_name department admin_system racf_id open_date close_date sap_user_id
FROM ZDESKDLC
INTO (SR_MANAG,LASTNAME,FIRSTNM,DEPART,ADM_SYS,RACF_ID,OPEN_DT,CLOSE_DT,SAPUSRID)
WHERE CCODE = CCOD1 and DESK_CODE = DESKCD.
START-OF-SELECTION
start-of-selection.
DELETE QUERY
IF DELETE = 'X'.
DELETE from zdeskdlc where
CCODE = CCOD AND
DESK_CODE = DESKCODE.
IF SY-SUBRC = 0.
MESSAGE s001(zjig) WITH 'data delete successfully'.
ELSE.
MESSAGE s001(zjig) WITH 'NO RECORD FOUND'.
ENDIF.
ENDIF.
UPDATE QUERY
*start-of-selection.
IF UPDATE = 'X'.
zdeskdlc-CCODE = CCOD1.
zdeskdlc-DESK_CODE = DESKCD.
zdeskdlc-SR_MANAGEMENT = SR_MANAG.
zdeskdlc-LAST_NAME = LASTNAME.
zdeskdlc-FIRST_NAME = FIRSTNM.
zdeskdlc-DEPARTMENT = DEPART.
zdeskdlc-ADMIN_SYSTEM = ADM_SYS.
zdeskdlc-RACF_ID = RACF_ID.
zdeskdlc-OPEN_DATE = OPEN_DT.
zdeskdlc-CLOSE_DATE = CLOSE_DT.
zdeskdlc-SAP_USER_ID = SAPUSRID.
SR_MANAG = wa_zdeskdlc-SR_MANAGEMENT .
LASTNAME = wa_zdeskdlc-LAST_NAME .
FIRSTNM = wa_zdeskdlc-FIRST_NAME .
DEPART = wa_zdeskdlc-DEPARTMENT .
ADM_SYS = wa_zdeskdlc-ADMIN_SYSTEM .
RACF_ID = wa_zdeskdlc-RACF_ID .
OPEN_DT = wa_zdeskdlc-OPEN_DATE .
CLOSE_DT = wa_zdeskdlc-CLOSE_DATE .
SAPUSRID = wa_zdeskdlc-SAP_USER_ID .
MODIFY ZDESKDLC.
*insert ZDESKDLC.
IF SY-SUBRC = 0.
MESSAGE s001(zjig) WITH 'data modify successfully'.
ENDIF.
ENDIF.
zenithi..
Hi All,
I have one problem more, Now update working is fine but selection screen not updated. in database update properly. but in selection screen shows same as data, not updated data..... so what to do for this query
for this mater can i use some clear screen................
pl give me suggestion.............
below is my whole code
*& Report ZDESKDLC_NEW *
REPORT ZDESKDLC_NEW .
*REPORT ZDESKDLC NO STANDARD PAGE HEADING LINE-SIZE 255.
DATA DECLARATION
TABLES : ZDESKDLC.
DATA: LW_SELECT TYPE zdeskdlc,
LW_UPDATE TYPE ZDESKDLC.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS: CCOD LIKE ZDESKDLC-CCODE MODIF ID ABC.
PARAMETERS: DESKCODE LIKE ZDESKDLC-DESK_CODE MODIF ID ABC.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION SCREEN WITH RADIO BUTTON
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.
PARAMETERS: DELETE RADIOBUTTON GROUP G1 USER-COMMAND R DEFAULT 'X'.
PARAMETERS: UPDATE RADIOBUTTON GROUP G1.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION SCREEN
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-001.
PARAMETERS: CCOD1 LIKE ZDESKDLC-CCODE MODIF ID DEF,
DESKCD LIKE ZDESKDLC-DESK_CODE MODIF ID DEF,
SR_MANAG LIKE ZDESKDLC-SR_MANAGEMENT MODIF ID DEF,
LASTNAME LIKE ZDESKDLC-LAST_NAME MODIF ID DEF,
FIRSTNM LIKE ZDESKDLC-FIRST_NAME MODIF ID DEF,
DEPART LIKE ZDESKDLC-DEPARTMENT MODIF ID DEF,
ADM_SYS LIKE ZDESKDLC-ADMIN_SYSTEM MODIF ID DEF,
RACF_ID LIKE ZDESKDLC-RACF_ID MODIF ID DEF,
OPEN_DT LIKE ZDESKDLC-OPEN_DATE MODIF ID DEF,
CLOSE_DT LIKE ZDESKDLC-CLOSE_DATE MODIF ID DEF,
SAPUSRID LIKE ZDESKDLC-SAP_USER_ID MODIF ID DEF.
SELECTION-SCREEN END OF BLOCK B3.
AT SELECTION-SCREEN OUTPUT.
IF DELETE = 'X'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'DEF'.
SCREEN-ACTIVE = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
IF UPDATE = 'X'.
LOOP AT SCREEN.
IF SCREEN-GROUP1 = 'ABC'.
SCREEN-ACTIVE = '0'.
screen-invisible = '1'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
AT SELECTION-SCREEN.
AT SELECTION-SCREEN.
IF UPDATE = 'X'.
**refresh sr_manag.
*CLEAR : sr_manag, lastname.
**CLEAR back.
*FREE MEMORY ID 'back'.
clear lw_update.
LW_UPDATE-SR_MANAGEMENT = SR_MANAG.
LW_UPDATE-LAST_NAME = LASTNAME.
LW_UPDATE-FIRST_NAME = FIRSTNM.
LW_UPDATE-DEPARTMENT = DEPART.
LW_UPDATE-ADMIN_SYSTEM = ADM_SYS.
LW_UPDATE-RACF_ID = RACF_ID.
LW_UPDATE-OPEN_DATE = OPEN_DT.
LW_UPDATE-CLOSE_DATE = CLOSE_DT.
LW_UPDATE-SAP_USER_ID = SAPUSRID.
SELECT SINGLE * FROM ZDESKDLC
INTO lW_SELECT
WHERE CCODE = CCOD1 and
DESK_CODE = DESKCD.
move LW_select-SR_MANAGEMENT to SR_MANAG.
MOVE LW_SELECT-Last_name TO LASTNAME.
MOVE LW_SELECT-FIRST_NAME TO FIRSTNM.
move LW_select-DEPARTMENT to DEPART.
move LW_select-ADMIN_SYSTEM to ADM_SYS.
move LW_select-RACF_ID to RACF_ID.
move LW_select-OPEN_DATE to OPEN_DT.
move LW_select-CLOSE_DATE to CLOSE_DT.
move LW_select-SAP_USER_ID to SAPUSRID.
CLEAR LW_SELECT.
ENDIF.
START-OF-SELECTION
start-of-selection.
DELETE QUERY
IF DELETE = 'X'.
DELETE from zdeskdlc where
CCODE = CCOD AND
DESK_CODE = DESKCODE.
IF SY-SUBRC = 0.
MESSAGE s001(zjig) WITH 'data delete successfully'.
ELSE.
MESSAGE s001(zjig) WITH 'NO RECORD FOUND'.
ENDIF.
ENDIF.
UPDATE QUERY
IF UPDATE = 'X'.
UPDATE ZDESKDLC
SET FIRST_NAME = LW_UPDATE-FIRST_NAME
LAST_NAME = LW_UPDATE-LAST_NAME
WHERE CCODE = CCOD1
AND DESK_CODE = DESKCD.
IF SY-SUBRC = 0.
lastname = LW_UPDATE-LAST_NAME.
firstnm = LW_UPDATE-FIRST_NAME.
MESSAGE s001(zjig) WITH 'data modified successfully'.
clear screen.
ENDIF.
CLEAR LW_UPDATE.
ENDIF.
Message was edited by:
zenithi george
Similar Messages
-
Problem regarding Update-Statement on se11 table
Hello I tried to update a dataset in a se11 table using UPDATE Statement.
It doesn't work and I get a sy-subrc = 4.
That is my code:
TABLES ZTDM_SAPOUTPUT.
* Arbeitsbereich definieren
DATA:
wa_ZTDM_SAPOUTPUT LIKE ZTDM_SAPOUTPUT.
wa_ZTDM_SAPOUTPUT-PK = '1'.
wa_ZTDM_SAPOUTPUT-FNCODE = '3'.
wa_ZTDM_SAPOUTPUT-MATNR = '3'.
wa_ZTDM_SAPOUTPUT-MAKTX = '3'.
wa_ZTDM_SAPOUTPUT-ZEINR = '3'.
wa_ZTDM_SAPOUTPUT-MATKL = '3'.
wa_ZTDM_SAPOUTPUT-STATE = '1'.
UPDATE ZTDM_SAPOUTPUT FROM wa_ZTDM_SAPOUTPUT.
Write: 'UPDATE returned' , sy-subrc.
SKIP.
The given Dataset having PK=1 doesn't get updated.
Maybe my understanding is wrong:
Is it correct that the updated dataset ist defined by the primary key in this workingarea?
My Primary Key is PK.
Can you see the error?UPDATE dbtab FROM wa. or
UPDATE (dbtabname) FROM wa.
Changes one single line in a database table, using a primary key to identify the line and taking the values to be changed from the specified work area, wa. The data is read out of wa from left to right, matching the line structure of the database table dbtab. The structure of wa remains unchanged. This means that wa must be at least as wide (see DATA) as the line structure of dbtab, and have the same alignment. Otherwise, a runtime error occurs.
If either the database table, dbtab, or the work area, wa, contain Strings, wa must be compatible with the line structure of dbtab.
Example
Changing the telephone number of the customer with customer number '12400177' in the current client:
DATA wa TYPE scustom.
SELECT SINGLE * FROM scustom INTO wa
WHERE id = '12400177'.
wa-telephone = '06201/44889'.
UPDATE scustom FROM wa.
When the command has been executed, the system field SY-DBCNT contains the number of updated lines (0 or 1).
Examples
Update discount for the customer with the customer number '00017777' to 3 percent (in the current client):
DATA: wa TYPE scustom.
SELECT SINGLE * FROM scustom INTO wa
WHERE id = '00017777'.
wa-discount = '003'.
UPDATE scustom FROM wa.
The Return Code is set as follows:
SY-SUBRC = 0:
The specified line has been updated.
SY-SUBRC = 4:
The system could not update any line in the table, since there is no line with the specified primary key.
rwrd if helpful
bhupal -
Regarding "Update .. From Table" Statement
Hi,
I have an existing piece of code which I'm trying to understand.
There are two scenarios regarding the UPDATE statement.
1) Scenario 1:
There exists a database table with around 100 or more fields/columns [Eg: DB_TABLE1].
An Internal Table exists with the same key as the above database table [EG: I_TABLE1].
code:
loop at I_TABLE1.
update DB_TABLE1
set kf1 = I_TABLE1-kfa
kf2 = I_TABLE1-kfb
kf3 = I_TABLE1-kfc
kf4 = I_TABLE1-kfd
where key1 = I_TABLE1-keya AND key2 = I_TABLE1-keyb.
Endloop.
In the above scenario the records in database table [DB_TABLE1] with matching condition are updated and the rest of the fields are not touched. - Correct me if I am wrong.
2) Scenario 2:
There exists a database table with around 100 or more fields/columns [Eg: DB_TABLE1].
Two Internal Tables exist with the same key as the above database table [EG: I_TABLE1 And I_TABLE2].
Code part a:
SELECT * FROM DB_TABLE1 INTO TABLE I_TABLE2
WHERE KF1 <> 0.
Internal Table 1 has some data.
Code part b:
loop at I_TABLE1.
update DB_TABLE1
set kf1 = I_TABLE1-kfa
kf2 = I_TABLE1-kfb
kf3 = I_TABLE1-kfc
kf4 = I_TABLE1-kfd
where key1 = I_TABLE1-keya AND key2 = I_TABLE1-keyb.
Endloop.
Code part c:
update DB_TABLE1 FROM TABLE I_TABLE2.
In the second scenario what will be the final effect of DB_TABLE1?
As i understand it, there is no use of Code part b. Am I right?
I thought that the records in I_TABLE2 with matching key in DB_TABLE1 will be updated and the rest of the records will be deleted.
But actually there is not change in the DB_TABLE1 when the above code is executed.
Help is appreciated.
Thanks.Hi Joey,
Scenario 1: In the above scenario the records in database table DB_TABLE1 with matching condition are updated and the rest of the fields are not touched.
- That's right.
Scenario 2: As i understand it, there is no use of Code part b.
- Exactly because of the following reasons:
1. Code part a shows data selected from DB_TABLE1 INTO TABLE I_TABLE2.
2. Code part c shows DB_TABLE1 updated from TABLE I_TABLE2 whereas Code part b uses ONLY internal table I_TABLE1.
3. If there are any operations performed in Code Part b on 'I_TABLE2', then this would have been different.
Regards,
Pranav. -
Error while schedulingg update stat in db13
Dear Experts,
Please look into my issue we are facing an error while scheduling update statistics in db13 and I tried to open detailed log
It is given
SXPG_COMMAND_EXECUTE failed for BRTOOLS - Reason: program_start_error: For More Information, See SYS
Please help me how to solve this my error
RegardsHi,
Check the owner for BRBACKUP, BRARCHIVE, and BRCONNECT in kernel,
these files should be with SIDADM, if not change the owner to SIDADM and rerun the update stats.
and also Refer the note 446172
Regards,
Ram -
Running an update statement on two dependent attributes
Dear All,
I have a repair_job table that contains values for work_cost, parts_cost and total_cost which is the sum of the work and parts cost values. I want to run an update statement that doubles the work cost and, naturally, updates the value of total cost as well. I tried to run it as:
update repair_job
set work_cost = 2 * work_cost, total_cost = work_cost + parts_cost
where licence in (
select licence from car
where year = to_char(sysdate,'YYYY')
thinking that because the update of work_cost is first on the list, the updated value of total cost would be correct. It seems however that the update of total cost happens first and then the work cost is been updated; not sure what the reason is for that and it happens no matter what the order is in the update statement.
I know that I can do it in two separate statements, or use a trigger or PL/SQL to do it but I am curious as to why it has this behaviour. Also, is there a way to do it in a single SQL statement - i.e. forcing the update of the work_cost attribute first and then that of total_cost?
I look forward to hearing from you soon.
Regards,
GeorgeWelcome to the forum!
>
thinking that because the update of work_cost is first on the list, the updated value of total cost would be correct. It seems however that the update of total cost happens first and then the work cost is been updated; not sure what the reason is for that and it happens no matter what the order is in the update statement.
I know that I can do it in two separate statements, or use a trigger or PL/SQL to do it but I am curious as to why it has this behaviour. Also, is there a way to do it in a single SQL statement - i.e. forcing the update of the work_cost attribute first and then that of total_cost?
>
The update to all columns of the row happen at the same time - there is no order involved.
You don't need two statements but you do need to do the updates based on the current value of the columns.
set work_cost = 2 * work_cost, total_cost = 2 * work_cost + parts_cost----------
In addition to sb92075's comments in 11 g you could also just define a virtual column for total_cost and then just query it like you do now.
total_cost NUMBER GENERATED ALWAYS AS (work_cost + parts_cost) VIRTUAL,See this Oracle-base article for an example
http://www.oracle-base.com/articles/11g/virtual-columns-11gr1.php
Edited to supplement sb92075's reply by mentioning virtual columns -
How can i use multiple row subquery in update statement
Hai All
I using group function in my update statement.. and i need to update more rows so i need to use multiple row
subquery pls tell me how to use multiple row subquery in update statement
For example
while i am using this like this i got an error
update dail_att set outtime in (select max(r2.ptime) from temp_att where empcode=r2.enpno and
barcode=r2.cardn and attend_date=r2.pdate group by enpno,pdate,cardn);
Pls tell me how to use with example
Thanks & regards
Srikkanth.MHai Man
Thanks for ur response Let me clear what i need
First step Fetch the records as text file and stores into table T1
and the next step is i have seperated the text using substring and stores in different columns of a table
There are two shifts 0815 to 1645 and 1200 and 2000
Here I rep IN and O rep OUT
Empno date time inout
001 01-01-10 0815 I
002 01-01-10 0815 I
003 01-01-10 0818 I
001 01-01-10 1100 0
001 01-01-10 1130 I
002 01-01-10 1145 0
002 01-01-10 1215 I
004 01-01-10 1200 I
005 01-01-10 1215 I
004 01-01-10 1315 O
004 01-01-10 1345 I
001 01-01-10 1645 0
002 01-01-10 1715 0
003 01-01-10 1718 0
004 01-01-10 2010 0
005 01-01-10 2015 0
This is my T1 table i have taken data from text file and stored in this table from this table i need to move data to another table T2
T2 contains like this
Empno Intime Intrin Introut Outtime Date
001 0815 1100 1130 1645 01-01-10
002 0815 1145 1215 1715 01-01-10
003 0818 1718 01-01-10
004 1200 1315 1345 2010 01-01-10
005 1215 2015 01-01-10
This what i am trying to do man but i have little bit problems Pls give some solution with good example
And my coding is
declare
emp_code varchar2(25);
in_time varchar2(25);
out_time varchar2(25);
Cursor P1 is
Select REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
From temp_att
group by REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
ORDER BY enpno,pdate,ptime;
begin
for r2 in p1 loop
declare
bar_code varchar2(25);
begin
select barcode into bar_code from dail_att where empcode=r2.enpno and attend_date=r2.pdate;
For r3 in (select empcode,empname,barcode,intime,intrin,introut,addin,addout,outtime,attend_date from dail_att)loop
if r2.inout ='O' then
update dail_att set outtime =(select max(r2.ptime) from temp_att where empcode=r2.enpno and barcode=r2.cardn and attend_date=r2.pdate group by r2.cardn,r2.enpno,r2.pdate );
end if;
end loop;
exception
when no_data_found then
if r2.inout ='I' then
insert into dail_att(barcode,empcode,intime,attend_date)(select r2.cardn,r2.enpno,min(r2.ptime),r2.pdate from temp_att group by r2.cardn,r2.enpno,r2.pdate );
end if;
end;
end loop;
commit;
end;
Pls tell me what correction i need to do i the update statement i have used a subquery with group function but when i used it will return only one row but my need is to return many rows and i need to use multiple row subquery
and how can i use it in the update statement
Thanks In Advance
Srikkanth.M -
How to track a column is not updated in a update statement issued.
Hello All,
Is there a way to write a trigger when a particular column is not specified in update statement.
For example, consider i have a table with 20 columns(Say Column1...column20). Trigger has to get fired only when column15(say) is not specified.
I know
CREATE OR REPLACE TRIGGER test_trigger
BEFORE UPDATE
OF COLUMN1, COLUMN2......COLUMN20--Except COLUMN15
ON TESTTABLE
FOR EACH ROW
BEGIN
END of_clause; /
above trigger will solve my problem. But i don't want to mention all columns in this trigger. It will cause maintainance problem afterwards.
Is there any way to mention something like NOT OF COLUMN in the trigger ?
Regards,
Abhijit.That trigger would get fired for every column except column 15.
What do you mean by "when a particular column is not specified in update statement"? Do you mean that the column is not mentioned at all in the update statement, or that the value of that column is not being changed even if it is mentioned in the statement?
If you mean the former, then I don't think there is any way to do that. however, if you want to do something only if the value in column15 is unchanged, then something along the lines of:
CREATE TRIGGER test_trigger
BEFORE UPDATE OF testtable
FOR EACH ROW
BEGIN
BEGIN
IF (:new.column15 IS NULL and :old.column15 IS NULL) OR
(:new.column15 IS NOT NULL and :old.column15 IS NOT NULL and
:new.column15 = :old.column15) THEN
< do whatever for no changes >
ELSE
< do nothing or something else for changes >
END IF;
END;John -
Write an UPdate statement using the logic used in PL/SQL block (oracle 10g)
Hi All,
I have written the following PL/SQL block. I want to write an UPDATE statement using the logic used in the following PL/SQL block. can any one please help me out in this regards.
DECLARE
v_hoov_fag gor_gold_post.hoov_flg%TYPE;
v_b49n gor_gold_post.b49n%TYPE;
CURSOR c
IS
SELECT bs_id, loyalty_date, loyalty_period, contract_date
FROM gor_gold_post
WHERE tariff_code IN (169, 135, 136);
BEGIN
FOR rec IN c
LOOP
IF (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
- SYSDATE) < 304
OR ( TRUNC ( ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
- SYSDATE
) IS NULL
AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2
THEN
v_hoov_flg := 1;
ELSE
v_hoover_flag := 99;
END IF;
IF (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
- SYSDATE) < 121.6
OR ( TRUNC ( ADD_MONTHS (rec.loyalty_date, rec.loyalty_period)
- SYSDATE
) IS NULL
AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2
THEN
v_b49n := 1;
ELSE
v_b49n := 99;
END IF;
UPDATE gor_gold_post
SET hoov_flg = v_hoov_flg,
b49n = v_b49n
WHERE bs_id = rec.bs_id AND tariff_code IN (169, 135, 136);
COMMIT;
END LOOP;
END;Thank you,Using case statement.
UPDATE gor_gold_post
SET hoov_flag = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 304
OR
(TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
THEN 1
ELSE 99
END,
b49n = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 121.6
OR
(TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
THEN 1
ELSE 99
END
WHERE tariff_code IN (169, 135, 136);Note: Code not tested. -
I got some problem in update statement.Can anybody discuss with me regarding my problem? Below is the occured problem.
//all the declaration like Connection, ResultSet are declared, setting the ODBC path and so on steps have been set up before this method. When compile it, no error, when I start to run my program, the program�s interface is shown, but the following error was appearred and data cannot be updated, can anybody tell me where is my mistake?
//ERROR:SQL Error in update statement:java.sql.SQLException [Microsoft][ODBC][ODBC Microsoft Access Driver] Syntax Error in UPDATE statement.
//emp_overview is the table name
// last_name, first_name, office_phone�.is the attributes of the table
//this method had declare in the interface class already
public String updateData (String idd, String ln, String fn, String op,
String oe, String hp, String ps, String ss)
throws java.rmi.RemoteException
{//begin of this method
String result ="";
try
Statement statement = connection.createStatement();
String sql = "UPDATE emp_overview SET" +
"last_name=' "+ln+
" ', first_name=' "+fn+
" ', office_phone=' "+op+
" ', office_ext=' "+oe+
" ', home_phone=' "+hp+
" ', primary_skill=' "+ps+
" ', secondary_skill=' "+ss+
" ' WHERE id="+idd;
statement.executeUpdate(sql);
statement.close();
catch (java.sql.SQLException e)
System.out.println("SQL Error in update statement: "+e);
//throw a RemoteException with the exception
//embedded for the client to receive
throw new java.rmi.RemoteException("Error in Updating exist row into DB", e);
return result;
}//end of this methodHi Kevin,
According to the code you have posted, it looks like you are missing a space between "SET" and "last_name". I suggest you add the following line of code:
System.out.println(sql);
before the invocation of "executeUpdate()".
I also suggest you add the following line of code:
e.printStackTrace();in your "catch" block.
Hope this helps.
Good Luck,
Avi. -
Update statement in Internal Table
Plz tell me the syntax and e.g. of update statement in Internal Table program
Moderator message: Welcome to SCN, please research yourself before asking basic questions.
Edited by: Thomas Zloch on Feb 25, 2010 12:47 PMHi,
Use UPDATE statement , check below description from SAP help.
UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab.
Effect
Mass update of several lines in a database table.Here, the primary key for identifying the lines tobe updated and the values to be changed are taken from the lines of theinternal table itab.
The system field SY-DBCNT contains the number of updated lines,i.e. the number of lines in the internal table itab which havekey values corresponding to lines in the database table.
Regards
L Appana -
Hai All
update dail set timeout=out_time where attend_date=r1.bardate and
(select bar_code from empl_barcode where empl_barcode.barcode=r1.barcode);
I got an error in my update statement. How can i write update statement with this or where i change..
Regards
Srikkanth.MHi,
review the syntax for the UNDATE statement. The following is okay:
UPDATE dail
SET timeout = out_time
WHERE attend_date = x
AND y > z
;if all the columns (including x, y and z) are in dail.
If you need to get some of those values from another table, then you can do a scalar sub-query , that is, a query that returns 9at most) one row, enclosed in parentheses.
For example, if x is in another table (named r1), you might say:
UPDATE dail m
SET timeout = out_time
WHERE attend_date = ( -- Begin scalar sub-query
SELECT MAX (bardate)
FROM r1
WHERE dail_id = m.id
) -- End scalar sub-query
AND y > z
;It looks like you're trying to do something similar.
I'm not sure exactly what x is supposed to be, and you're missing y (or z) as well as the operator between them.
MERGE is often easier to use than UPDATE, when you need to reference other tables.
If you'd like help, post a little sample data (CREATE TABLE and INSERT statements for all tables as they exist before the UPDATE) and the results you want from taht data (the contents of dail after the UPDATE). -
How to convert pl/sql block into single update statement
Dear all gurus,
I have pl/sql block mention below, Can I convert this pl/sql block to single update statement if possible?
If not how to optimize this block?
Pleaese suggest.
thanks in advance.
Vijay
DECLARE
CURSOR vt_mlr_cursor IS Select master_key, user4 from vt_mlr Where USER4 is not null;
USERFIELD VARCHAR2(100);
C1 VARCHAR2(3); /* this will return location of first space = 12 */
C2 VARCHAR2(3); /* this will return location of second space = 20 */
C3 VARCHAR2(3); /* this will return location of third space = 28 */
C4 VARCHAR2(3); /* this will return location of forth space = 35 */
Field1 VARCHAR2(40); /* this will return FTMYFLXA04W */
Field2 VARCHAR2(10); /* this will return VPI0043 */
Field3 VARCHAR2(10); /* this will return VCI0184 */
Field4 VARCHAR2(10); /* this will return 005 */
Field5 VARCHAR2(10); /* this will return 00001 */
Field_2_n_3 VARCHAR2(25);
key VARCHAR2(10);
BEGIN
FOR vt_mlr_record IN vt_mlr_cursor
LOOP
key := vt_mlr_record.master_key;
USERFIELD := vt_mlr_record.user4;
C1 := INSTR(vt_mlr_record.user4,' ',1,1); /* this will return location of first space = 12 */
C2 := INSTR(vt_mlr_record.user4,' ',1,2); /* this will return location of second space = 20 */
C3 := INSTR(vt_mlr_record.user4,' ',1,3); /* this will return location of third space = 28 */
C4 := INSTR(vt_mlr_record.user4,' ',1,4); /* this will return location of forth space = 35 */
Field1 := SUBSTR(vt_mlr_record.user4,1,C1-1); /* this will return FTMYFLXA04W */
Field2 := SUBSTR(vt_mlr_record.user4,C1+4,C2-C1-4); /* this will return VPI0043 */
Field3 := SUBSTR(vt_mlr_record.user4,C2+4,C3-C2-4); /* this will return VCI0184 */
Field4 := SUBSTR(vt_mlr_record.user4,C3+4,C4-C3-4); /* this will return 005 */
Field5 := SUBSTR(vt_mlr_record.user4,C4+4,LENGTH(vt_mlr_record.user4)-C4-3); /* this will return 00001 */
Field_2_n_3 := Field2 || '/' || Field3;
/*DBMS_OUTPUT.PUT_LINE ('Current key is: ' || vt_mlr_record.master_key);*/
UPDATE vt_mlr
SET
aggregator_clli = Field1,
aggregator_vpi_vci = Field_2_n_3,
aggregator_slot = Field4,
aggregator_port = Field5
WHERE
master_key = vt_mlr_record.master_key;
END LOOP;
END;
/Hi Vijay,
Here's something to start with, you should be able to complete it.
First, combine your select and update statements:
update vt_mlr
set aggregator_clli = field1
,aggregator_vpi_vci = field_2_n_3
,aggregator_slot = field4
,aggregator_port = field5
where user4 is not null;Then put these two
C1 := INSTR(vt_mlr_record.user4,' ',1,1);
Field1 := SUBSTR(vt_mlr_record.user4,1,C1-1);into
Field1 := SUBSTR(vt_mlr_record.user4,1,INSTR(vt_mlr_record.user4,' ',1,1) -1);And put it into the update statement, removing reference to record
(I have also removed default values for position and occurrence in instr function):
update vt_mlr
set aggregator_clli = substr(user4, 1, instr(user4,' ') - 1)
,aggregator_vpi_vci = field_2_n_3
,aggregator_slot = field4
,aggregator_port = field5
where user4 is not null; I think you can do the rest from here ;-)
Regards
Peter -
DML Error logging for Update statement
Hello,
I am facing a problem with regard to DML Error logging with Update statement .
oracle : 10.2
I am executing following DML update:
BEGIN
UPDATE
table_1 a
SET a.Exp_DATE =a.EFF_DATE
WHERE a.col_a1 != (SELECT b.colb1
FROM table_2 b
WHERE a.msisdn =b.msisdn )
LOG ERRORS INTO table_1_ERR REJECT LIMIT UNLIMITED;
END ; I was expecting that "ORA-01427: single-row subquery returns more than one row" would be captured in LOG error table "table_1_err"
but instead I got run time error and whole dml was rolled back.
Please let me know whether this exception is not captured by DML error logging.
Thanks,
Abhishek*Oracle logs the following errors during DML operations:** Column values that are too large.
* Constraint violations (NOT NULL, unique, referential, and check constraints).
* Errors raised during trigger execution.
* Errors resulting from type conversion between a column in a subquery and the corresponding column of the table.
* Partition mapping errors.
>
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/transform.htm#sthref777 -
Execution time difference between SELECT & UPDATE statement in JDBC Sender.
Hi Experts,
In my scenario, I have used the JDBC Sender Adapter with the SELECT and UPDATE statement.
Now the problem is in between the execution of Select and update statement, few more entries are coming in the same DB Table.
So result of this is updation take place for those entries which are not even picked up by the select statement.
Can we avoid this execution time difference between the SELECT & UPDATE statemet on JDBC Sender side???
Thanks & Regards
JageshHi
Use serializable option in additional parameters, now all new entries would also be updated. -
JDBC Sender Adapter, Update statement
Hi ALL,
I have a JDBC to proxy scenario. We have stored procedure in the database that executess and sends the data to SAP.
Also the same store procedure updates the field Status_ID to distinguish between read and unread records. Status_ID acts as a Flag.
Now because the Stored procedure itself does what 'Update SQL Statement' in sender JDBC adapter does, what shall I put in 'Update SQL Statement' as it is not needed, but it's a mandatory field??
XIer
Message was edited by:
XIerDo you need that update in the sender jdbc adaptor to do anything....?
Dint think so..
Change your update statement to update Status_ID if its not updated..and if the sql procedure has run already then its not going to be updated ..as it already is.......
Regards
Ravi Raman
Maybe you are looking for
-
I was updating my software on my iphone 4 and it crashed so it recovered it and i restored it from its back up. However I have lost all my music and my apps but not my pictures. How can i get my music back. I did not remove my phone from the computer
-
Hallo Does someone know, how i can set the width of the DropDown-Menu from the JComboBox manually?? i want that the list is larger than the width of the JComboBox. thx for help :) eagle
-
Modifying a bitstream from a file
Hi, I'm trying to write an app for creating a 3D pic. I have all the theory sorted and now I require a means of creating a mirror image of a jpg. To do this involves moving the pixels on the right of the screen to the left and vice versa for each hor
-
Display other shopping carts without change/delete possibility?
Hi, We are using SRM 5.0 and some users needs to display shopping carts created by other, without given the access to change and delete those shopping cart (should still be able to change/delete one's own shopping carts). Anyone who has a solution on
-
FF is frozen on mac. I can do nothing at all.
for mac. FF opens when my computer comes on and it freezes. Tells me to close tabs. I can not do a thing. I was browsing when it froze. I unplugged, rebooted and shut down several times and it comes back up every time I turn the computer on I have to