UPDATE statement syntax
I seem to have the most problem with UPDATE statement syntax. The following select works fine:
select * from rco.rpt_ds1_cnt_cat c, rco.rpt_ds1_valid_per_lerg l
where l.loc = c.aloc;
All I want to do, and preferably with aliases is set c.aloc = l.loc. Every imaginable syntax is coming up with errors, either invalid columns or SET word missing, etc.
Can someone tell me how to word this?
You need to be aware that id there is a record in rpt_ds1_cnt_cat that does not have a matching record in rpt_ds1_valid_per_lerg this statement will update aloc_valid to NULL. If that is not what you are looking for, then you need to add a predicate like:
UPDATE rpt_ds1_cnt_cat C
SET aloc_valid = (SELECT DISTINCT validperlerg
FROM rpt_ds1_valid_per_lerg l
WHERE l.loc = c.aloc)
WHERE c.aloc IN (SELECT loc FROM rpt_ds1_valid_per_lerg)
or
UPDATE rpt_ds1_cnt_cat C
SET aloc_valid = (SELECT DISTINCT validperlerg
FROM rpt_ds1_valid_per_lerg l
WHERE l.loc = c.aloc)
WHERE EXISTS (SELECT 1
FROM rpt_ds1_valid_per_lerg l
WHERE l.loc = c.aloc)If loc is the PK of rpt_ds1_valid_per_lerg, or is constrained unique, then you could also update a join, which is what I think you were trying for originally.
Something like:
UPDATE (SELECT c.aloc_valid, l.validperlerg
FROM rpt_ds1_cnt_cat c, rpt_ds1_valid_per_lerg l
WHERE l.loc = c.aloc)
SET aloc_valid = validperlergHTH
John
Similar Messages
-
Hi,
I am getting following error message ,
[Microsoft][ODBC Microsoft Access Driver] Syntax error in UPDATE statement.
When run this code.
<%@ page import= "java.sql.*"%>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb");
Statement st = con.createStatement();
st.executeUpdate("update tscipshift set 11-Aug-08='M' where TechN='Elamparuthi'");
%>
tscipshift=table ,column=11-Aug-08 are all exist.
I dont know why I am getting error mesage.
Any idea why?Shahbaz2008 wrote:
you haven't set your user name and password hereI don't believe that's necessary with Access. Then again, it's not an enterprise database.
Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb");
change it to this
Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb","+username+","+password+");
here pass your username and password...
In Oracle default user name and password is
username = scott
password = tigerSo who uses that? Only an eejit would leave that account open.
So the statement would be
Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb","scott","tiger");
or In Mirosoft Access there is no user name and password so the statement will be Like I said - unnecessary, and not the reason the OP is having problems.
Connection con = DriverManager.getConnection("jdbc:odbc:bspipdb","","");>
Besides this change your table name 11-Aug-08 to anything that is not start with number or any special symbols.
for example aug112008 is good or aug is too good.No, it's still not good if you understand ANYTHING about relational databases and normalization.
I think it would work.I think you're just as stup!d as the OP.
% -
JDBC: Syntax error in UPDATE statement???
Hi,
I have been trying to solve this seemingly simple problem for the past 4 hours, and I had no success. I am working on a jdbc:odbc connection which utilizes MS Access. I have been constantly getting "Syntax error in UPDATE statement", and this is the statement
(name of the table is CDs, columns are number, artist, album, label and date - all strings):
query = "UPDATE CDs SET artist = '" + fields.artist.getText() +"', album = '" +
fields.album.getText() + "', label = '" +
fields.label.getText() + "', date = '" +
fields.date.getText() + "' WHERE number = '" + fields.number.getText() + "'";
Can anybody recognize an error? Thank you,
mirkokrugA couple of possibilities.
If the column NUMBER is numeric then it wouldn't need quotes around the data value. Also if the column DATE is a date or date/time type then the format from the textbox may not be correct.
Col -
Update statement with Case syntax
I want to put case statement in an update statement using Oracle 10g
I'm getting a syntax error on the last line Ora-00933: SQL command not properly ended
Help please
UPDATE EMP a
SET EMP.TYPE = CASE
WHEN 'Y' = 'A' THEN 'DIV'
WHEN 'Y' = '1' THEN 'DEF'
END CASE;Hi,
Samim wrote:
I want to put case statement in an update statement using Oracle 10g
I'm getting a syntax error on the last line Ora-00933: SQL command not properly ended
Help please
UPDATE EMP a
SET EMP.TYPE = CASE
WHEN 'Y' = 'A' THEN 'DIV'
WHEN 'Y' = '1' THEN 'DEF'
END CASE;The closing keyword that corresponds to "CASE" is "END", not "END *CASE* ".
The string 'Y' is never equal to 'A', or to '1'.
If you have a column named y in the table, then you might want to say:
UPDATE EMP
SET EMP.TYPE = CASE
WHEN Y = 'A' THEN 'DIV'
WHEN Y = '1' THEN 'DEF'
END;I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statemnts to re-create your emp table as it exists before the UPDATE), and the results you want from that data (that is, the contents of the emp table after the UPDATE). -
Decode function in Update statement
Hello everyone,
I'm trying to write a query where I can update a pastdue_fees column in a book_trans table based on a difference between return_dte and due_dte columns.
I am using Oracle SQL. This is what I have so far for my decode function:
SQL> SELECT
2 DECODE(SIGN((return_dte - due_dte)*2),
3 '-1', '0',
4 '1', '12', 'Null')
5 FROM book_trans;
DECO
Null
12
Null
0
So the logic is that if the sign is -1, the value in return_dte column should be 0; if it's +1 then it's 12 and everything else is Null.
So now, I need to enter my decode function into the update statement to update the columns. However, I get error messages.
The logic should be:
UPDATE book_trans SET PastDue_fees = decode(expression)
I've given it a couple of different tries with the following results:
SQL> UPDATE book_trans
2 SET pastdue_fees = SELECT
3 DECODE(SIGN((return_dte - due_dte)*2),
4 '-1', '0',
5 '1', '12', 'Null')
6 FROM book_trans;
SET pastdue_fees = SELECT
ERROR at line 2:
ORA-00936: missing expression
SQL> UPDATE book_trans
2 SET pastdue_fees =
3 DECODE(SIGN((return_dte - due_dte)*2),
4 '-1', '0',
5 '1', '12', 'Null')
6 FROM book_trans;
FROM book_trans
ERROR at line 6:
ORA-00933: SQL command not properly ended
Any help or tips would be greatly appreciated as I've been taking SQL for about six weeks and not very proficient!
Thanks!882300 wrote:
Hello everyone,
I'm trying to write a query where I can update a pastdue_fees column in a book_trans table based on a difference between return_dte and due_dte columns.
I am using Oracle SQL. This is what I have so far for my decode function:
SQL> SELECT
2 DECODE(SIGN((return_dte - due_dte)*2),
3 '-1', '0',
4 '1', '12', 'Null')
5 FROM book_trans;
DECO
Null
12
Null
0
So the logic is that if the sign is -1, the value in return_dte column should be 0; if it's +1 then it's 12 and everything else is Null.
So now, I need to enter my decode function into the update statement to update the columns. However, I get error messages.
The logic should be:
UPDATE book_trans SET PastDue_fees = decode(expression)
I've given it a couple of different tries with the following results:
SQL> UPDATE book_trans
2 SET pastdue_fees = SELECT
3 DECODE(SIGN((return_dte - due_dte)*2),
4 '-1', '0',
5 '1', '12', 'Null')
6 FROM book_trans;
SET pastdue_fees = SELECT
ERROR at line 2:
ORA-00936: missing expression
SQL> UPDATE book_trans
2 SET pastdue_fees =
3 DECODE(SIGN((return_dte - due_dte)*2),
4 '-1', '0',
5 '1', '12', 'Null')
6 FROM book_trans;
FROM book_trans
ERROR at line 6:
ORA-00933: SQL command not properly ended
Any help or tips would be greatly appreciated as I've been taking SQL for about six weeks and not very proficient!
Thanks!If you really really really want to update the entire table, the syntax would be...
UPDATE book_trans
SET
pastdue_fees = DECODE(SIGN((return_dte - due_dte)*2), -1, 0, 1, 12, Null);I took out all the single quotes. If you actually have a string column and you're storing entirely numbers in it then it should be declared as a NUMBER column and not a character (varchar2) column.
ALWAYS use the proper data type, it'll save you a ton of headaches in the future.
Also, since you're new to the forum, please read the FAQ so you learn the etiquette and what not.
http://wikis.sun.com/display/Forums/Forums+FAQ -
IF statement syntax in SQL script view
I need to include a "IF" condition in the "SELECT" section of my SQL script view.
I tried the following syntax's but I get the error 'Incorrect SQL syntax near 'IF'
1. IF(Revenue <> '0' AND Quantity <> '0', Revenue/Quantity, '0') AS Gross Price
2. IF(Revenue != '0' AND Quantity != '0', Revenue/Quantity, '0') AS Gross Price
3. IF(Revenue <> '0' AND Quantity <> '0' THEN Revenue/Quantity ELSE '0' END) AS Gross Price
4. IF(Revenue != '0' AND Quantity != '0' THEN Revenue/Quantity ELSE '0' END) AS Gross Price
My final SQL would read like follows:
SELECT field1, field2, IF(......) AS field3
FROM table1
Can anybody please help with the correct IF statement syntax to be used in the SQL script based view?Hi Lakshmi,
below is the syntax for IF statement.
IF <bool_expr1> THEN
<then_stmts1>
ELSEIF <bool_expr2>
THEN <then_stmts2>
[ELSE <else_stmts3>]
END IF
eg :
BEGIN
DECLARE found INT := 1;
SELECT count(*) INTO found FROM books WHERE isbn = :v_isbn;
IF :found = 0 THEN
INSERT INTO books VALUES (:v_isbn, 'In-Memory Data Management', 1, 1, '2011', 42.75, 'EUR');
ELSE
UPDATE books SET price = 42.75 WHERE isbn =:v_isbn;
END IF;
END;
Sreehari -
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 the following FORALL Update to direct SQL UPDATE statement
I have a FORALL loop to update a table. It is taking too long. I want to rewrite the code to a direct UPDATE sql. Also, any other tips or hints which can help run this proc faster?
CURSOR cur_bst_tm IS
SELECT listagg(tm, ' ') WITHIN GROUP(ORDER BY con_addr_id) best_time,
con_addr_id
FROM (select Trim(Upper(con_addr_id)) con_addr_id,
||decode(Initcap(start_day),
'Monday', 'm',
'Tuesday', 'tu',
'Wednesday', 'w',
'Thursday', 'th',
'Friday', 'f',
Initcap(start_day))
||'='
||trunc(( ( TO_DATE(start_tm,'HH12:MI:SS PM') - trunc(TO_DATE(start_tm,'HH12:MI:SS PM')) ) * 24 * 60 ))
||','
||trunc(( ( TO_DATE(end_tm,'HH12:MI:SS PM') - trunc(TO_DATE(end_tm,'HH12:MI:SS PM')) ) * 24 * 60 )) tm
FROM (SELECT DISTINCT * FROM ODS_IDL_EDGE_OFFC_BST_TM)
WHERE con_addr_id is not null)
GROUP BY con_addr_id
ORDER BY con_addr_id;
TYPE ARRAY IS TABLE OF cur_bst_tm%ROWTYPE;
l_data ARRAY;
BEGIN
OPEN cur_bst_tm;
LOOP
FETCH cur_bst_tm BULK COLLECT INTO l_data LIMIT 1000;
FORALL i IN 1..l_data.COUNT
UPDATE ODS_CONTACTS_ADDR tgt
SET best_times = l_data(i).best_time,
ODW_UPD_BY = 'IDL - MASS MARKET',
ODW_UPD_DT = SYSDATE,
ODW_UPD_BATCH_ID = '0'
WHERE Upper(edge_id) = l_data(i).con_addr_id
AND EXISTS (SELECT 1 FROM ods_idl_edge_cont_xref src
WHERE tgt.contacts_odw_id = src.contacts_odw_id
AND src.pc_flg='Y')
EXIT WHEN cur_bst_tm%NOTFOUND;
END LOOP;
CLOSE cur_bst_tm;Record count:-
select count(*) from
ODS_IDL_EDGE_OFFC_BST_TM;
140,000
SELECT count(*)
FROM ods_idl_edge_cont_xref src
WHERE src.pc_flg='Y';
118,000
SELECT count(*)
FROM ODS_CONTACTS_ADDR;
671,925
Database version 11g.
Execution Plan for the update:
Operation Object Name Rows Bytes Cost Object Node In/Out PStart PStop
UPDATE STATEMENT Optimizer Mode=ALL_ROWS 6 K 8120
UPDATE ODW_OWN2.ODS_CONTACTS_ADDR
HASH JOIN SEMI 6 K 256 K 8120
TABLE ACCESS FULL ODW_OWN2.ODS_CONTACTS_ADDR 6 K 203 K 7181
TABLE ACCESS FULL ODW_OWN2.ODS_IDL_EDGE_CONT_XREF 118 K 922 K 938
Edited by: user10566312 on May 14, 2012 1:07 AMThe code tag should be in lower case like this {noformat}{noformat}. Otherwise your code format will be lost.
Here is a update statementupdate ods_contacts_addr tgt
set (
best_times, odw_upd_by, odw_upd_dt, odw_upd_batch_id
) =
select best_time, odw_upd_by, odw_upd_dt, odw_upd_batch_id
from (
select listagg(tm, ' ') within group(order by con_addr_id) best_time,
'IDL - MASS MARKET' odw_upd_by,
sysdate odw_upd_dt,
'0' odw_upd_batch_id,
con_addr_id
from (
select Trim(Upper(con_addr_id)) con_addr_id,
||decode(Initcap(start_day), 'Monday', 'm', 'Tuesday', 'tu', 'Wednesday', 'w', 'Thursday', 'th', 'Friday', 'f', Initcap(start_day))
||'='
||trunc(((TO_DATE(start_tm,'HH12:MI:SS PM')-trunc(TO_DATE(start_tm,'HH12:MI:SS PM')))*24*60 ))
||','
||trunc(((TO_DATE(end_tm,'HH12:MI:SS PM')-trunc(TO_DATE(end_tm,'HH12:MI:SS PM')))*24*60)) tm
FROM (
select distinct * from ods_idl_edge_offc_bst_tm
WHERE con_addr_id is not null
group
by con_addr_id
where upper(tgt.edge_id) = con_addr_id
where exists
SELECT 1
FROM ods_idl_edge_cont_xref src
WHERE tgt.contacts_odw_id = src.contacts_odw_id
AND src.pc_flg='Y'
and exists
select null
from (
SELECT listagg(tm, ' ') WITHIN GROUP(ORDER BY con_addr_id) best_time,
'IDL - MASS MARKET' odw_upd_by,
SYSDATE odw_upd_dt,
'0' odw_upd_batch_id,
con_addr_id
FROM (
select Trim(Upper(con_addr_id)) con_addr_id,
||decode(Initcap(start_day), 'Monday', 'm', 'Tuesday', 'tu', 'Wednesday', 'w', 'Thursday', 'th', 'Friday', 'f', Initcap(start_day))
||'='
||trunc(((TO_DATE(start_tm,'HH12:MI:SS PM')-trunc(TO_DATE(start_tm,'HH12:MI:SS PM')))*24*60 ))
||','
||trunc(((TO_DATE(end_tm,'HH12:MI:SS PM')-trunc(TO_DATE(end_tm,'HH12:MI:SS PM')))*24*60)) tm
FROM (
SELECT DISTINCT * FROM ODS_IDL_EDGE_OFFC_BST_TM
WHERE con_addr_id is not null
GROUP
BY con_addr_id
where upper(tgt.edge_id) = con_addr_id
This is an untested code. If there is any syntax error then please fix it and try. -
How to use escape character in update statement.
Hi All,
I'm trying to update table using following sql update statement, but everytime it's asking me for the input due to the '&' value in below sql.
UPDATE xyz_xyz
SET NAME = 'ABC & PQR'
WHERE ID = (SELECT ID
FROM abc_abc
WHERE NAME = 'C & PQR');Please let me know how to use escape character syntax or let me know if there is any alternative solution.
Thanks,
VishwasHi,
By default, & marks a substitution variable name.
If you're not using substitution variables in that statement (or, if this is in PL/SQL, in that entire package or procedure) then the easiest thing to do is just diable substitution variables; then & will be a normal character:
SELECT DEFINE OFF
UPDATE xyz_xyz
SET NAME = 'ABC & PQR'
WHERE ID = (SELECT ID
FROM abc_abc
WHERE NAME = 'C & PQR');
SET DEFINE ONIf you can't do that, then & is always taken literally if it comes right before a single-quote, so you could say:
UPDATE xyz_xyz
SET NAME = 'ABC &' || ' PQR'
WHERE ID = (SELECT ID
FROM abc_abc
WHERE NAME = 'C &' || ' PQR');There is a SQL*Plus "SET ESCAPE" command, too, but if you use it, you have to worry about whether the escape character is to be taken literally or not.
SET ESCAPE \Yet another alternative is to make some other character, such as ~, mark the substitution variables:
SET DEFINE ~Read all about them in the SQL*Plus manual.
http://download.oracle.com/docs/cd/B28359_01/server.111/b31189/ch2.htm#sthref103 -
Improving SQL Insert statement syntax
It's about insert statement syntax, in insert statement, unlike in update statement column names and corresponding values are separated in two different sets. With this separation debugging/writing of insert statement is going to be time taking activity. To identify what value is getting stored in any column, first column position needs to be identified and after that by counting commas in the values list value is located. If functions are included in insert statement then counting of commas doesn't help to locate the value.
In any non trivial application column count in insert statement is going to be very big number and it is unmanageable.
If column name and value are written next to each other as it is done in cause of UPDATE statement, it is going to drastically reduce the debugging efforts and there by improves the productivity of the developers.
So I request SQL community please consider having a variant of insert statement in similar lines of update statement. This will simplify the life of millions of developers.
Edited by: user9110509 on Feb 6, 2010 10:19 AMHi,
That's a good idea! An optional alternate way of specifying the columns would be handy.
Perhaps the reason it hasn't been done yet is that most people, like those who have responded to this message, do not find the current syntax much of a problem. We can't be sure if your idea "is going to drastically reduce the debugging efforts" until it is available, but my guess is that it isn't.
One thing I do to make sure the two lists match is to indent the values directly below the column names, like this:
INSERT INTO emp (empno, ename, hiredate, job)
VALUES (9876, 'OBAMA', TO_DATE ( '20-JAN-2009'
, 'DD-MON-YYYY), 'PRESIDENT');If the list is very long, or individual values are very complicated, then I might start with a list of the column names
INSERT INTO emp -- Step 1: not ready to run yet
( empno
, ename
, hiredate
, job
VALUESthen use the editor's copy and paste commands to duplicate that list:
INSERT INTO emp -- Step 2: not ready to run yet
( empno
, ename
, hiredate
, job
VALUES
( empno
, ename
, hiredate
, job
;and then fill in the VALUES section, leaving the copied names as comments:
INSERT INTO emp -- Step 3: ready to run
( empno
, ename
, hiredate
, job
VALUES
( 9876 -- empno
, 'OBAMA' -- ename
, TO_DATE ( '20-JAN-2009'
, 'DD-MON-YYYY
) -- hiredate
, 'PRESIDENT' -- job
; -
Help with doing SELECT sub query within the SET of an UPDATE statement
After doing some research, it appears as if it's possible to use a SELECT subquery in the SET of an UPDATE statement. i did find some examples and here is my code, however when I click the "check" button it's saying the field (my entire select subquery) is unknown and neither in one of the specified tables or defined by a "DATA". Do I have a syntax issue or is there another reason why it's not taking this as a valid statement? Thanks for the help!
LOOP AT IT_DATA
UPDATE /BIC/AZDP_O0140
SET /BIC/ZCOUNTER = (SELECT COUNT( DISTINCT MATERIAL )
FROM /BIC/AZDP_O0140
WHERE MATERIAL EQ IT_DATA-MATERIAL
GROUP BY MATERIAL).
ENDLOOP.my Update does indeed have a WHERE clause but because of the issue i'm having, all my criteria in my WHERE is black text in the ABAP editor. The editor doesn't even recognize the keywords "WHERE" or "EQ". Below is my entire statement which contains all WHERE criteria in both the Update and the Subquery, i've just removed it for testing to help simplify the query and eliminate as many other factors as posisble that may be causing problems:
LOOP AT IT_DATA.
UPDATE /BIC/AZDP_O0140
SET /BIC/ZCOUNTER = (SELECT COUNT( DISTINCT MATERIAL ) FROM /BIC/AZDP_O0140
WHERE WHSE_NUM EQ IT_DATA-WAREHOUSE
AND PLANT EQ IT_DATA-PLANT
AND /BIC/ZTRAN_NO EQ IT_DATA-TRANS_NUM
AND DELIV_NUMB EQ IT_DATA-DELIVERY
AND MATERIAL EQ IT_DATA-MATERIAL
GROUP BY MATERIAL)
WHERE WHSE_NUM EQ IT_DATA-WAREHOUSE
AND PLANT EQ IT_DATA-PLANT
AND /BIC/ZTRAN_NO EQ IT_DATA-TRANS_NUM
AND DELIV_NUMB EQ IT_DATA-DELIVERY
AND MATERIAL EQ IT_DATA-MATERIAL.
ENDLOOP.
i should also mention the sources i found were not within the SAP Library but instead on other third-party ABAP websites. so because i was having issues i wanted to post here to see if anyone else has come up with a working solution. but if this cannot be done i can likely come up with a solution for my needs using multiple internal tables, this would just have been much easier since i can get a query like this to do what i want in SQL Server. Thought i could utilize this in ABAP as well. -
Explain plan on Update statement in function
All,
I have an update statement in a function and my explain plan shows:
"Optimizer" "Cost" "Cardinality" "Bytes"
"UPDATE STATEMENT" "ALL_ROWS" "2" "1" "7"
"UPDATE user.<table_name>" "" "" "" ""
"INDEX(UNIQUE SCAN) <table_name>.<PK_column_cons>" "ANALYZED" "1" "1" "7"
Filtering is on index unique column, but cost is 1 what does that mean?
do i need to change my update statement in function?
Any ideas?
Regards,
~ORAThe cost is the optimizer's measure of how much effort it will take to execute the statement. For any statement the optimizer will evaluate a number of execution plans and choose the one with the lowest cost. I wouldn't worry too much about what it actually "means". However if you want to understand this subject in a lot more detail I would recommend the book Cost-Based Oracle Fundamentals by Jonathan Lewis.
For your update statement the optimizer has chosen to access a single row by the primary key index, which is probably good enough, so you should not need to change it.
The only faster way to access the data would be to use the row's ROWID directly. You would need to have fetched this explicitly in a previous SELECT statement, or you could use it implicitly with the WHERE CURRENT OF syntax for a cursor opened with FOR UPDATE. -
Problem with CFQUERY update statement
I'm having trouble getting an SQL Update statement to work
correctly and I'm scratching my head as to why.
The output i get is the following:
Syntax error in UPDATE statement
SQLSTATE 42000
SQL UPDATE companies SET CompanyName = 'Insight Data Ltd',
Address1 = '5 Boulevard', Address2 = '', Address3 = '', City =
'Weston-super-Mare', County = 'North Somerset', Postcode =
'BS231NN', OfficeBranch = 'BR', contacttitle1 = 'Mr', contactname1
= 'Andrew', contactsurname1 = 'Scott', contactposition1 = 'Owner',
mail1 = 'yes', TelNumber = '01934 123456', TPS = 'no', FaxNumber =
'',FPS = 'no',MobileNumber = '',MPS = 'no',email =
'[email protected]', EPS = 'no', WebAddress = '
http://www.insightdata.co.uk',
contacttitle2 = 'Mr', contactname2 = 'David', contactsurname2 =
'Lewis', contactposition2 = 'Office Manager', mail2 = 'no',
contacttitle3 = 'Mr', contactname3 = '', contactsurname3 = '',
contactposition3 = 'Owner', mail3 = 'no', contacttitle4 = 'Mr',
contactname4 = '', contactsurname4 = '', contactposition4 =
'Owner', mail4 = 'no', wPVCUfab = 'yes', wALUinst = 'yes', WHERE
companyid = 33415
VENDORERRORCODE -3503
DATASOURCE idv6
I've checked that all the data fields are in the correct
format, and I can't see why I am getting a syntax error. Any help
on this would be appriciatedAgreed, but it looks like you already have the sql. Take the
query from the error message above and run it in your database.
Though I did notice have an extra comma between the last column and
there WHERE clause.
wALUinst = 'yes' , WHERE companyid = 33415
For the optional columns, put the commas first to prevent
errors due to trailing or too many commas
UPDATE Table
SET Column1 = 'value'
<cfif SomeValueExists>, Column2 = 'other value'
</cfif>
WHERE ID = 123
Two other things to consider: use cfqueryparam and consider
normalizing your table. Column names like Contact1, Contact2,
Contact3 ... are usually a sign its time to normalize.
Maybe you are looking for
-
I just bought a 2 gb shuffle and I have more music in my itunes than it can hold. How can i sync only the certain playlists on the shuffle?
-
Hi All, I just wonder anyone can lend me a hand please. I am using Java to develop a search engine at the moment, I need to store all the words from a single html page, and I have done this, but the thing is how can I get all pages from a certain int
-
What color ipod 5 is the best looking?
I like how the yellow one is a little gold but is it just like that in the pictures. I've seen the blue in person and it is really nice, but I'm looking for something new and different but I don't want an eye sore every time I look at it. P.s. the re
-
CUE 7.0 Custom Prompts - Limit with Prompt Management
Hi All, I seem to be having a problem when using prompt management to create custom prompts. I am running CUE 7.0.2, and according to the table here http://www.cisco.com/en/US/docs/voice_ip_comm/unity_exp/rel7_0/rel_notes/rel_notes.html#wp221528 I
-
Displaying 2 decimal places in BI Answers column, using SQL_TSI_HOUR
Hi, Would anyone know why the following code refuses to display 2 decimal places in a BI answers report: ' case when "- Job Detail"."Date Delivered" is null or "- Job Detail"."Date Received" is null then 'Not Available' else cast (ROUND(cast(timestam