Doubt on update Statment
Removed
Message was edited by:
MIND
Like this ?
WHERE ( LICNXX.PRPR_ID = AFRSXX.SRV_PRPR_ID
AND LICNXX.LICN_STATE = AFRSXX.SRV_PRAD_STATE
AND LICNXX.PRPR_TYPE ='F'
AND AFRSXX.CLCL_CL_SUB_TYPE ='I')
OR ( LICNXX.PRPR_ID = AFRSXX.PRCP_ID
AND LICNXX.LICN_STATE = AFRSXX.SRV_PRAD_STATE
AND LICNXX.PRPR_TYPE ='C'
AND AFRSXX.CLCL_CL_SUB_TYPE ='P')
AND ROWNUM = 1Nicolas.
Similar Messages
-
Problem in update statment when using where condtion
Hi ,
Iam using update statment to update field in Z-Table .My statment is not working fine as per my requirement.The statment is as below,
UPDATE ZFINAL_DATA SET ZDATE_FLAG = SPACE where ZGLOBAL_CODE ( SELECT LIFNR FROM LFA1 WHERE KTOKK = 'ZLIE' ).
But this statment is doing my purpose .
My requirement is , I need to update ZDATE_FLAG = SPACE in ZFINAL_DATA table when LFA1 -LIFNR = ZFINAL_DATA-ZGLOBAL_CODE and LFA1-KTOKK = 'ZLIE'.
Can any correct the update statment which will be helpfull to proceed further .
Regards,
SriramHi Sriram,
Have a look into the logic of the below query. Maybe this will fulfil the requirement.
TYPES: BEGIN OF lt_lifnr,
lifnr TYPE lifnr,
END OF lt_lifnr.
DATA: la_lifnr TYPE TABLE OF lt_lifnr,
wa_zfinal_data TYPE zfinal_data,
la_zfinal_data TYPE TABLE OF zfinal_data.
TABLES: zfinal_data.
SELECT lifnr
FROM lfa1
INTO TABLE la_lifnr
WHERE ktokk = 'ZLIE'.
SORT la_lifnr BY lifnr.
SELECT *
FROM zfinal_data
INTO TABLE la_zfinal_data.
LOOP AT la_zfinal_data INTO wa_zfinal_data.
READ TABLE la_lifnr WITH KEY lifnr = wa_zfinal_data-zglobal_code
BINARY SEARCH TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
wa_zfinal_data-zdate_flag = space.
MODIFY la_zfinal_data
FROM wa_zfinal_data
INDEX sy-tabix
TRANSPORTING zdate_flag.
ENDIF.
ENDLOOP.
MODIFY zfinal_data FROM TABLE la_zfinal_data.
COMMIT WORK. -
hi for all, plz i have a question ,i have a tabel called (ClientT) which contain these fielde
First_Name
Last_Name
UserID
Address
Password
BirthDate
Answer
and i need to make an Update to this table according to some informatio ,My Code
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:test";
// Step 2: Establish the connection to the database.
java.sql.Connection c = DriverManager.getConnection(url,"", "");
java.sql.Statement st = c.createStatement();
String Query = "UPDATE ClientT " +
"SET Password = 'pass' "+
"WHERE (Address LIKE 'city') AND (BirthDate LIKE 'birth') AND (Answer LIKE 'color')";
st.executeQuery(Query);
st.close();
c.close();
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
catch(ClassNotFoundException ex) {
System.out.println("Class Not Found Exception ");
}when the trace reach
String Query = "UPDATE ClientT"+
it jump to th st.close();
what is the problem, the problem is with the UPDATE SQL Query.is the structure of this query correct??
Thanks.thank you for your third point i make it but still the code not done what i need (update the password in the tabel according to certain Client information),
i dont have an error to do
exception.printStacktrace();
the code not produce an error through debugging,or through run,so i thing the UPDATE statment not coorect.
i use this UPDATE statment for the first time so i dont sure is the structure of it right or not, and i using NetBeens IDE.
can you help me or give me an examples of UPDATE Statment.
thank
i have a question< is there is a diffrence when i replace the LIKE whith = in my SQL query?
my final code is
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:test";
// Step 2: Establish the connection to the database.
java.sql.Connection c = DriverManager.getConnection(url,"", "");
java.sql.Statement st = c.createStatement();
String Query = "UPDATE ClientT " +
"SET Password = ('"+pass+"') "+
"WHERE (Address = 'city') AND (BirthDate = 'birth') AND (Answer = 'color')";
st.executeUpdate(Query);
st.close();
c.close();
catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
catch(ClassNotFoundException ex) {
System.out.println("Class Not Found Exception ");
}Edited by: master2007 on Mar 16, 2008 1:13 AM -
Hi all,
Please advice if following statment will update correct rows?:
for x in (select rowid from table where col=345 and col2=567 and col3=678)
loop
update table set col6=344 wher rowid=x.rowid;
end loop;
I just whant to be sure that refference to rowid column in update statment will update correct rows.
Is the any cases when rowid value can be changed between fetching and updating?
Thank you.You probably should make sure that you aren't updatind a record that has already been updated by checking that col6 <> 344 in both the guard at the beginning of the loop and in the update statement folowing the guard.
LOOP
-- check if still rows to update
begin
select 'x'
into v_dummy
from table
where col1=345 and col2=567 and col3=678 and col6 <> 344
and rownum = 1;
exception
when no_data_found then
exit; -- leave loop
end;
update table
set col6=344
where col1=345 and col2=567 and col3=678 and col6 <> 344
and rownum <= 50000; -- use big chucks to update
commit;
END LOOP; -
Doubt on updating PROJN field in EKKN
Hi Friends,
I have a requirement to update the PROJN(old pos number) field in EKKN table with some shipment date from input file.
i have checked with BAPI_PO_CHANGE for updation.
I cannot accurately find a specific field where i need to update for PROJN in that BAPI.
Actually the PROJN field is not in use now.
Can anybody help me with which field in ME22N denotes the PROJN field.
Is there any ways to update an non-existing field with some other field.
<b><REMOVED BY MODERATOR></b>
Message was edited by:
Alvaro Tejada GalindoAs the field is no longer used I doubt if there is a bapi or other object that allows you to update the field. Even if there was a bapi then support for updating that field could be withdrawn in the future. To be safe you should look at using another field. If you get replies telling you to directly update ekkn-projn then ignore them, thats silly.
-
Doubt about UPDATE STAT COLUMN
Hi,
I have a doubt of when to execute update stat:
i create this SQL to generate an SQL script to generate update stat for all my tables:
select 'UPDATE STAT ' || schemaname || '.' || tablename || ' ESTIMATE SAMPLE 20 PERCENT' from tables where schemaname = 'DBUSER' and not tablename like 'JDBC%' AND type = 'TABLE'
and created this SQL to generate an SQL script for update stat for all columns.
select 'UPDATE STAT COLUMN(*) FOR ' || schemaname || '.' || tablename || ' ESTIMATE SAMPLE 20 PERCENT' from tables where schemaname = 'DBUSER' and not tablename like 'JDBC%' AND type = 'TABLE'
my doubt is i really need run that second script? or the UPDATE STAT for table dont UPDATE STAT for all columns?
thanks for any insight
Clóvis> my doubt is i really need run that second script? or the UPDATE STAT for table dont UPDATE STAT for all columns?
Hi Clovis,
hmm... good question.
There are a few things to know about the UPDATE STAT command here.
1) It will always generate statistics for key or indexed columns.
2) The optimizer won't be able to generate a better plan when there are column statistics for non-indexed columns present.
3) The command will also collect column statistics for all columns that already have statistics.
The direct effect of 3) is that by running your second command just once - all column statistics will always be collected.
Since you can easily change the default sample size for your tables via
ALTER TABLE SAMPLE SIZE 20 PERCENT
I would say: drop your script and just use
UPDATE STAT DBUSER.* ESTIMATE
This single command would lead to the same statistics as your script does.
And if you really, really want to leave out the JDBC tables - then just set their default sample size to 0 and they will be ignored by the UPDATE STAT command.
regards,
Lars -
Hi ,
I wana use two column conditionally in an update statement rather then writing two statement for each conditions.
update war_room_report_aged
set case when p_business_days_old=15 then nrpc_15_days
when p_business_days_old=25 then nrpc_25_days
when p_business_days_old=10 then nrpc_10_days end = exceeds_sr.c_date_recd
where bus_unit_abbrev = exceeds_sr.abr_bus_unit||'_'||exceeds_sr.abr_sub
and todays_date = p_end_date
and tio_priority = p_level;I can do it with two statement seperatly ,but i got in a situation where there would be more than 5 columns need to be updated according to parameter's value.
if p_business_days_old=15 then
update war_room_report_aged
set nrpc_15_days=exceeds_sr.c_date_recd
where bus_unit_abbrev = exceeds_sr.abr_bus_unit||'_'||exceeds_sr.abr_sub
and todays_date = p_end_date
and tio_priority = p_level;
elsif p_business_days_old=25 then
update war_room_report_aged
set nrpc_25_days=exceeds_sr.c_date_recd
where bus_unit_abbrev = exceeds_sr.abr_bus_unit||'_'||exceeds_sr.abr_sub
and todays_date = p_end_date
and tio_priority = p_level;
elsif .. then
end if;Can i made the same above in one statment?I am so devastated as there gonna be more than 10 conditions for 10 parameter and for each parameter's value relate to seperate 10 cloumns.You can do it this way:
create table test_table
pk_col number,
cond_1 number,
col_1 varchar2(5),
cond_2 number,
col_2 varchar2(5),
cond_3 number,
col_3 varchar2(5)
insert into test_Table values (1, 10, 'AAA', 20, 'BBB', 30, 'CCC');
update test_table
set col_1 = decode(&input, 10, col_1 || '1', col_1),
col_2 = decode(&input, 20, col_2 || '1', col_2),
col_3 = decode(&input, 30, col_3 || '1', col_3)
where pk_col = 1;
select *
from test_table;
PK_COL COND_1 COL_1 COND_2 COL_2 COND_3 COL_3
1 10 AAA1 20 BBB 30 CCCLogic is to check if the variable matches a certain Input condition, then update the column with new value, else just update it with Itself. This way, you achieve it in a single SQL and still do not risk losing column information. -
How to use the Output clause for the updated statment
How to use the output clause for the below update stament,
DECLARE @MyTableVar table(
sname int NOT NULL)
update A set stat ='USED'
from (select top 1 * from #A
where stat='AVAILABLE' order by sno)A
Output inserted.sname
INTO @MyTableVar;
SELECT sname
FROM @MyTableVar;
Here am getting one error incorrect syntax near Output
i want to return the updated value from output clausesee
http://blogs.msdn.com/b/sqltips/archive/2005/06/13/output-clause.aspx
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Using a WITH list in an update statment
I have the following SQL that gives a 'The multi-part identifier "CurrentScannedCasks.CSC" could not be bound.' error,.
So how can I, or can I, use the contents if a WITH statement to populate this update statement?
WITH CurrentScannedCasks (CSC) AS (
select CaskNo
from AllocationCask ac
inner join allocation a on a.ID = ac.AllocationID
where a.AllocationNo = 143601 -- {allocation number from input}
and ac.CaskScanned =1
and ac.AllocationID = (select distinct top 1 allocationID as latestAllocationID
from AllocationCask ac
inner join allocation a on a.ID = ac.AllocationID
where a.AllocationNo = 143601
order by allocationID DESC)
update scantransaction
set AllocationCaskID = (select ID from AllocationCask
where caskNo = CurrentScannedCasks.CSC
and AllocationID = (select distinct top 1 allocationID as latestAllocationID
from AllocationCask ac
inner join allocation a on a.ID = ac.AllocationID
where a.AllocationNo = 143601
order by allocationID DESC))
Where ID = (select top 1 ID from scantransaction st
where SUBSTRING(st.CaskBarcode, 13, 7) = CurrentScannedCasks.CSC
and st.AllocationNo = 143601
order by ID DESC)I forgot the from!
e.g.
WITH CurrentScannedCasks (CSC) AS (
select CaskNo
from AllocationCask ac
inner join allocation a on a.ID = ac.AllocationID
where a.AllocationNo = 143601 -- {allocation number from input}
and ac.CaskScanned =1
and ac.AllocationID = (select distinct top 1 allocationID as latestAllocationID
from AllocationCask ac
inner join allocation a on a.ID = ac.AllocationID
where a.AllocationNo = 143601
order by allocationID DESC)
update scantransaction
set AllocationCaskID = (select ID from AllocationCask
where caskNo = CurrentScannedCasks.CSC
and AllocationID = (select distinct top 1 allocationID as latestAllocationID
from AllocationCask ac
inner join allocation a on a.ID = ac.AllocationID
where a.AllocationNo = 143601
order by allocationID DESC))
from CurrentScannedCasks
Where ID = (select top 1 ID from scantransaction st
where SUBSTRING(st.CaskBarcode, 13, 7) = CurrentScannedCasks.CSC
and st.AllocationNo = 143601
order by ID DESC)
But it still dosn't appear toi be working properly, It should update all the caskScanned fields of the current allocation to 1 where any previous version of the cask was 1.
Then update the current allocationCaskId of the relevant transactions table record to that of the latest version od the cask record in the allocation cask table.
It looks like this isn't quite doing what I expected! -
Hi,
I need to update all values in 2 columns (Net_Quantity) and (Net_Amount) based on join condition with the another table in plsql block.
Query which i tried
UPDATE TFS_FRCST_TOOL_LINES SET NET_ORDERS_QTY=l_net_orders_qty and NET_AMOUNT=l_net_amount
WHERE TFS_FRCST_TOOL_HDRS.HEADER_ID =TFS_FRCST_TOOL_LINES.HEADER_ID;
It not updating, returns error like command not properly ended.
Can any one please give idea to solve this.
Regards
AjanDave is right. The first thing that struck was 'and' and I had pointed it to the user who posted this.
To Ajan --> You can try either of the options below,
UPDATE TFS_FRCST_TOOL_LINES
SET
NET_ORDERS_QTY=l_net_orders_qty,
NET_AMOUNT=l_net_amount
WHERE
TFS_FRCST_TOOL_LINES.HEADER_ID IN (SELECT TFS_FRCST_TOOL_HDRS.HEADER_ID FROM TFS_FRCST_TOOL_HDRS) ;
UPDATE (select NET_ORDERS_QTY, NET_AMOUNT
from TFS_FRCST_TOOL_LINES,TFS_FRCST_TOOL_HDRS
where TFS_FRCST_TOOL_LINES.HEADER_ID=TFS_FRCST_TOOL_HDRS.HEADER_ID)
set
NET_ORDERS_QTY=l_net_orders_qty,
NET_AMOUNT=l_net_amount -
I have a problem using update query, for updating one column in a table with another column in another table. For eg say i have two tables, collector and survey
Fields in Collector:
col_n_account_num
col_v_email
col_n_phone_number
Fields in survey
sur_v_question_id
sur_n_account_num
sur_v_response
update collector
case when sur_v_question_id=collector_email then col_v_email=sur_v_response end,
case when sur_v_question_id=collector_phone then col_n_phone_number=sur_v_response end
Thanks in advance
Regards,
sswrite two simple update statements
update collector set col_v_email =
(select sur_v_response from survey
where sur_v_question_id=collector_email )
and
update collector set col_n_phone_number =
(select sur_v_response from survey
where sur_v_question_id=collector_phone) -
Doubt in update function module
dear friends..
i have created an UPDATE function module with Processing type- Update Module, Start Immediate. i have handled the exceptions using Raise statement in the function module..
the call function looks as..
CALL FUNCTION 'ZFI_LCTXN_TABLES_UPDATE'
in update task
EXPORTING
ZLCTMB1 = p_lctmb1
NU_ENTRY = p_global-ins_zlctmb1
TABLES
UPD_PO = UPD_PO
UPD_SH = UPD_SH
EXCEPTIONS
ERROR = 1
OTHERS = 2.
p_subrc = sy-subrc.
commit work.
but if the update fails, and even though the RAISE ERROR works, and update termination message is registered in SM13, i dont get the value for sy-subrc as 1 .
is it the right way..if yes please tell me how to generate an error message within the transaction..so that the user knows the update has failed..
thank you for your time
NivinHi,
Maybe it's usefull for you.
<b>
IF sy-subrc EQ 4.
MESSAGE e001 RAISING not_found.
ELSEIF sy-subrc EQ 8.
MESSAGE e002 RAISING not_found.
ELSE.
ENDIF.</b>
Using this to create a message and raise in the same time !
Regards.
Marcelo Ramos -
Hi friends,
I need some suggestions,
I am designing a desktop application with HSQLDB. Database contains 5 or 6 tables with image names , local path to those images and user login details. Desktop version is working fine but now problem is, there will be a central database on server which needs to be updated when the user clicks update. I need to update any new entry in DB and some times i need to upload those images to server.
One way of doing is, include a separate entry in each table like new and whenever user updating get that entry and if its true i need to update that particular table row in the server and upload images to server if necessary, if everything is fine i need to change that entry to false. I think this will be fine for small number of tables but if it increases i need to check each and every table, update server, upload images and again update local db.
So what will be the better way of doing this operation ? I can't update server db simultaneously as most of the time application run offline.
Thanks in advance
madhavthanks for your suggestion. its a good idea when all tables are same but prob is,
say exactly i have 7 tables. 4 are for different types of images which contains name and path as columns. one table is to hold user login details like 'uname', 'pwd' and 'isadmin', 2nd one is to hold list of customers with column 'name' and last one is to hold logo info with column 'path'.
Means, i need to create one single table with lot of columns or need to create 4 other tables to check for updates or am i misunderstood your suggestion ?
I am sorry if i am not very clear in my first post -
Hello All,
In my sender jdbc adpter configuration i read data from table that contains filed 'status' witch indicate does record has been send to sap. But limitation of this solution is that i read up to ne row and example query looks like this
select up to 1 rows * from table where status = 0 order by id.
and update query
update table set status = 1 where id = ( select id 1 rows * from table where status = 0 order by id )
Can you write your strategy of reading multiple records.
I know that stored procedure can be solution of this problem, but i'm wondering how do you handle with that.
BR
Maciejyou can indeed read and update multiple records;
Adapter Work Method
· You must add an indicator that specifies the processing status of each data record in the adapter (data record processed/data record not processed) to the database table.
· The UPDATE statement must alter exactly those data records that have been selected by the SELECT statement. You can ensure this is the case by using an identical WHERE clause. (See Processing Parameters, SQL Statement for Query, and SQL Statement for Update below).
· Processing can only be performed correctly when the isolation level for transaction is set to repeatable_read or serializable.
Example
SQL statement for query: SELECT * FROM table WHERE processed = 0;
SQL statement for update: UPDATE table SET processed = 1 WHERE processed = 0;
processed is the indicator in the database.
the above is from SAP help.
follow the query as mentioned and do not forget to set the repeatable_read or serializable in the adapter
http://help.sap.com/saphelp_nw04/helpdata/EN/7e/5df96381ec72468a00815dd80f8b63/frameset.htm -
Need to reduce no of calling same function in update statment
update tab1 set
col1 = FN1(a),
col2 = FN2(a),
col3 = FN3( FN1(a), FN2(a) , c )
here FN1 and FN2 is called two time .. or only once ,, ??
if 2 time then how to make it once call only ...
can we change it like this
update tab1 set
col1 = FN1(a),
col2 = FN2(a),
col3 = FN3( col1 , col2 , c )
both r same or differnt ..??Edited by: user12108669 on Dec 11, 2009 4:31 AMHi,
Those are very good questions.
Riedelme has told you who is the best person to answer thiose questions: you.
To see how ofte a function is called, you can have it display something (using dmbs_output) or increment a sequence, package variable or SYS_CONTEXT attribute.
CREATE TABLE tab1
( a NUMBER
, col1 NUMBER
, col2 NUMBER
, col3 NUMBER
, c NUMBER
INSERT INTO tab1 (a) VALUES (1);
INSERT INTO tab1 (a) VALUES (2);
INSERT INTO tab1 (a) VALUES (3);
CREATE SEQUENCE fn1_seq START WITH 1;
CREATE SEQUENCE fn2_seq START WITH 1001;
CREATE OR REPLACE FUNCTION fn1
( in_num IN NUMBER
RETURN NUMBER
IS
seq_val NUMBER;
BEGIN
SELECT fn1_seq.NEXTVAL
INTO seq_val
FROM dual;
RETURN seq_val;
END fn1;
SHOW ERRORS
CREATE OR REPLACE FUNCTION fn2
( in_num IN NUMBER
RETURN NUMBER
IS
seq_val NUMBER;
BEGIN
SELECT fn2_seq.NEXTVAL
INTO seq_val
FROM dual;
RETURN seq_val;
END fn2;
SHOW ERRORS
CREATE OR REPLACE FUNCTION fn3
( in_x NUMBER
, in_y NUMBER
, in_z NUMBER
RETURN NUMBER
IS
BEGIN
RETURN in_x + in_y;
END fn3;
SHOW ERRORSTo avoid calling the functions repeatedly, you can use MERGE instead of UPDATE, like this:
MERGE INTO tab1 dst
USING (
SELECT a
, fn1 (a) AS fn1_a
, fn2 (1) AS fn2_a
, c
FROM tab1
) src
ON (src.a = dst.a)
WHEN MATCHED THEN UPDATE
SET dst.col1 = src.fn1_a
, dst.col2 = src.fn2_a
, dst.col3 = fn3 (src.fn1_a, src.fn2_a, src.c)
SELECT *
FROM tab1
ORDER BY a;Output:
. A COL1 COL2 COL3 C
1 1 1001 1002
2 2 1002 1004
3 3 1003 1006
Maybe you are looking for
-
Billing qty should be equal to or less than order and delivery qty
Hi Gurus , Can anyone tell me how to configure a sales document so that the order qty ,delivery qty does not exceed the billing qty. Thanks N Regards, Siddhartha
-
I am just trying to have a button send an e-mail on a button CLICK event, this is what I tried, but obviously wrong. Any help would be appreciated: btn_conHit.addEventListener (MouseEvent.CLICK, conClick); function conClick (e:MouseEvent):void{ o
-
EMAIL SECURITY SETTINGS CHANGE
Ok..well this simply isn't working out for my Galaxy S4. I'm signed into my Verizon account and receiving email. On going into the account to make the changes, on either the incoming or outgoing servers...I enter the information, click DONE and am
-
New ipod 5 wont hold a charge why
okay so i judt got the new ipod touch 5th gen and i charged it over night and then went to school and it was charged but then when i got it out on the bus it was all the way dead and my brother has the ipod touch 5th gen to so i tryed both of our cha
-
Firefox keeps saying not responding
When ever I click on a site example to read my mail Firefox keeps stating not responding. This happens what ever I click on.I uninstalled and reinstalled but it is still doing the same thing.