EA1: code completion with update statements
Hello all,
Code completion works well for selects, but (for me, anyway) not as well for updates - I get nothing after
update table_a set <ctrl+space>
unless I select '(', which works for the first column, but after that, I get nothing. However, if I do this (doesn't really make much sense)
update table_a set xxx = <ctrl+space>
where xxx is nonsense, I then get a list of columns, and can chain several together. So, it's almost as if things are the wrong way around - you get code completion on the value rather than the column. Am I dong something wrong, or is this a bug?
In general, though, 1.5 just feels so much nicer to use. Well done!
John
Excellent! Bugs fixed even before they're reported ;>
Now, when can I get my hands on EA2.....?
Similar Messages
-
3.1EA2/EA1 : Code completion issues
Hi,
OS Win 7, JDK 1.6_11 shipped with SQL Dev, againts Oracle 9iR2.
I find lots of improvement on the new code completion feature.
However I also find lots of defects on it, here are they :
1. Code completion often offers long exhaustive list of possibility that cause the list to scroll pass the bottom part of SQL Dev instead of giving us a small window with vertical scroll bar in it.
2. Code completion does not offer field list on the following :
select *
from mytable1 t
inner join mytable2 x on x. -- does not show field list
select *
from mytable1 t
inner join mytable2 x on x.fi -- does not show field list starting with 'fi'
select *
from tmp_bow_data_aloy1 x
inner join
select *
from tmp_bow_data_aloy2 y
where y. <Ctrl + Space> -- does not show field list
select *
from tmp_bow_data_aloy1 x
inner join
select *
from tmp_bow_data_aloy2 y
where y.acct_card_no = x. -- does not show field list
update mytable1 t
set t. -- does not show field list
delete from mytable1 t
where t. -- does not show field list
3. Code completion mix between statement although has been delimited with ';'
select *
from mytable1 x;
select *
from mytable2 y
where <Ctrl + Space> -- shows all mytable1's fields as well as mytable2's fields
Hope these would be fixed on next EA.
Regards,
Buntoro
Edited by: Buntoro on Nov 18, 2011 3:52 AM
Add EA2 to titleHi Vadim,
I can confirm most of the issues have been fixed on 3.1EA2.
Thank you for that.
As for now, this 'challenging case' is the one that I work with most of the time.
select *
from departments x
inner join
select *
from locations l
where l.location_id = x.
)I am still hoping for the fixed.
Btw, the 3rd problem on which code completion mix between statement although has been delimited with ';' is the one that bothers me a lot.
It certainly a showstopper for using the code completion.
You cannot hope anymore from the unreliable code completion since it will mess up with the query.
I would like to give a more straightforward case just by adding another query on top of it :
select *
from employees x
inner join employees y on y.manager_id = x.employee_id;
select *
from departments x -- here I put the same alias as employees
inner join
select *
from locations l
where l.location_id = x. -- <Ctrl + Space>, hm... why department table showing these field list ???
)From the above example, you will notice that the 'challenging case' is displaying the fields from wrong tables.
It suppose to be from departments table, instead of the employees one above it.
Another problem also arise from above case.
4. Code completion does not work if there is 'failed to be parsed' statement above the current within the same worksheet.
select *
from employees
where department_id = ; -- hm.... I forget what's id that department is. Okay, let me leave it here first, and query the department tables
select *
from dep -- <Ctrl + Space>, wait.... why is it not working??FYI, 3.0 seems working nicely.
Hopefully this will be fixed too.
Regards,
Buntoro -
Emergency: problem with update statement!
hello guys, i have a very serious problem with an update statement in pl/sql.
i had an application written in sybase, where i had the following update statement:
update mis_dik_adeia
set trexon_etos_days = days_per_year
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_dik_adeia.adeia_id between :aapo and :aews
and mis_dik_adeia.employee_id = :erg
and mis_dik_adeia.etos = :etos
and mis_plafon_adeivn.years_yphr = ( select max( a.years_yphr ) from mis_plafon_adeivn a where a.adeia_id = mis_plafon_adeivn.adeia_id and a.years_yphr <= :eth ) using sqlca;
This is working properly in sybase. When i copied this code in pl/sql it displayed me error and it's impossible to work. Then i thought to make a nested select statement like this:
update mis_dik_adeia
set trexon_etos_days = (select days_per_year
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
but as you can understand, it is working, but it doesn't produce the same results as the update statement in Sybase!
It is very important for me to solve this problem , which is a very big trouble for me for a long time.
Please if anyone can help me i would appreciate it a lot!
Regards ,
Bill...Bill,
folowing the logic of your original query by Sybase
(it's embedded SQL in Power Builder, isn't it ?):
update mis_dik_adeia
set trexon_etos_days = (select days_per_year
from mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
where
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and
exists (select 1
from mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
In 9i you can also try the following:
megre into mis_dik_adeia
using (
select
days_per_year,
mis_dik_adeia.rowid rid
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr =
(select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth)
) src
on (mis_dik_adeia.rowid = src.rid)
when matched then
update set mis_dik_adeia.trexon_etos_days = src.days_per_year
when not matched then
insert (mis_dik_adeia.adeia_id) values(0);
In 10G it can be easily:
megre into mis_dik_adeia
using (
select
days_per_year,
mis_dik_adeia.rowid rid
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr =
(select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth)
) src
on (mis_dik_adeia.rowid = src.rid)
when matched then
update set mis_dik_adeia.trexon_etos_days = src.days_per_year;
I have to notice I didn't check it carefully, so I can miss...
Rgds.
Corrected a mistake in the table name
Message was edited by:
dnikiforov -
Help needed with Update statements.
Hello All,
I am trying to learn Berkeley XMLDB and facing problem to query the inserted XML file. I have a small XML file with the following contents:
<?xml version="1.0" standalone="yes"?>
<Bookstore>
<Book>
<book_ID>1</book_ID>
<title>Harry Potter and the Order of the Phoenix</title>
<subtitle>A Photographic History</subtitle>
<author>
<author_fname>J.K.</author_fname>
<author_lname>Rowling</author_lname>
</author>
<price>9.99</price>
<year_published>2004</year_published>
<publisher>Scholastic, Inc.</publisher>
<genre>Fiction</genre>
<quantity_in_stock>28997</quantity_in_stock>
<popularity>20564</popularity>
</Book>
</Bookstore>
When I try to update the TITLE of this node I have the following error message:
C:\Users\Chandra\Desktop\BDB>javac -classpath .;"C:\Program Files\Sleepycat Soft
ware\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\B
erkeley DB XML 2.1.8\jar\db.jar" bdb.java
bdb.java:75: illegal start of expression
public static final String STATEMENT1 = "replace value of node collection("twopp
ro.bdbxml")/Bookstore/Book/bookid/title with 'NEWBOOK'";
^
bdb.java:80: ')' expected
System.out.println("Done query: " + STATEMENT1);
^
2 errors
But when I remove the update statements and just try to display the TITLE of this node, I dont see any outputs. Please help me to catch up with my mistakes. Below is source code I am using to run this functionality.
Thanks.
import java.io.File;
import java.io.FileNotFoundException;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
import com.sleepycat.dbxml.XmlContainer;
import com.sleepycat.dbxml.XmlException;
import com.sleepycat.dbxml.XmlInputStream;
import com.sleepycat.dbxml.XmlManager;
import com.sleepycat.dbxml.XmlUpdateContext;
import com.sleepycat.dbxml.XmlDocument;
import com.sleepycat.dbxml.XmlQueryContext;
import com.sleepycat.dbxml.XmlQueryExpression;
import com.sleepycat.dbxml.XmlResults;
import com.sleepycat.dbxml.XmlValue;
public class bdb{
public static void main(String[] args)
Environment myEnv = null;
File envHome = new File("D:/xmldata");
try {
EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setAllowCreate(true); // If the environment does not
// exits, create it.
envConf.setInitializeCache(true); // Turn on the shared memory
// region.
envConf.setInitializeLocking(true); // Turn on the locking subsystem.
envConf.setInitializeLogging(true); // Turn on the logging subsystem.
envConf.setTransactional(true); // Turn on the transactional
envConf.setRunRecovery(true);
// subsystem.
myEnv = new Environment(envHome, envConf);
// Do BDB XML work here.
} catch (DatabaseException de) {
// Exception handling goes here
} catch (FileNotFoundException fnfe) {
// Exception handling goes here
} finally {
try {
if (myEnv != null) {
myEnv.close();
} catch (DatabaseException de) {
// Exception handling goes here
XmlManager myManager = null;
XmlContainer myContainer = null;
// The document
String docString = "D:/xmldata/test.xml";
// The document's name.
String docName = "cia";
try {
myManager = new XmlManager(); // Assumes the container currently exists.
myContainer =
myManager.createContainer("twoppro.bdbxml");
myManager.setDefaultContainerType(XmlContainer.NodeContainer); // Need an update context for the put.
XmlUpdateContext theContext = myManager.createUpdateContext(); // Get the input stream.
XmlInputStream theStream =
myManager.createLocalFileInputStream(docString); // Do the actual put
myContainer.putDocument(docName, // The document's name
theStream, // The actual document.
theContext, // The update context
// (required).
null); // XmlDocumentConfig object
theStream.delete();
// Update the title
public static final String STATEMENT1 = "*replace value of node collection("twoppro.bdbxml")/Bookstore/Book/[bookid=1]/title with 'NEWBOOK'";*
XmlQueryContext context = myManager.createQueryContext();
XmlQueryExpression queryExpression1 = myManager.prepare(STATEMENT1, context);
System.out.println("Try to execute query: " +
System.out.println("Done query: " + STATEMENT1);
queryExpression1.execute(context);
// Get a query context
XmlQueryContext context = myManager.createQueryContext();
// Set the evaluation type to Lazy.
context.setEvaluationType(XmlQueryContext.Lazy);
// Declare the query string
String queryString =
"for $u in collection('twoppro.dbxml')/Bookstore/Book/[bookid=1]"
+ "*return $u/title";*
// Prepare (compile) the query
XmlQueryExpression qe = myManager.prepare(queryString, context);
XmlResults results = qe.execute(context);
System.out.println("ok");
System.out.println(results);
} catch (XmlException e) {
// Error handling goes here. You may want to check
// for XmlException.UNIQUE_ERROR, which is raised
// if a document with that name already exists in
// the container. If this exception is thrown,
// try the put again with a different name, or
// use XmlModify to update the document.
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (myContainer != null) {
myContainer.close();
if (myManager != null) {
myManager.close();
} catch (XmlException ce) {
// Exception handling goes hereThanks Rucong. The change you suggested did helped me to run the program correct. But I also have the display function to retrive the results and my program is parsed without any output.
C:\Users\C\Desktop\BDB>Clientbuild.bat
C:\Users\C\Desktop\BDB>javac -classpath .;"C:\Program Files\Sleepycat Soft
ware\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\B
erkeley DB XML 2.1.8\jar\db.jar" bdb.java
C:\Users\C\Desktop\BDB>Client.bat
C:\Users\C\Desktop\BDB>java -classpath .;"C:\Program Files\Sleepycat Softw
are\Berkeley DB XML 2.1.8\jar\dbxml.jar";"C:\Program Files\Sleepycat Software\Be
rkeley DB XML 2.1.8\jar\db.jar" bdb
See there is no OUPUT displayed. Is there somethinglike a 'print' I have to use in this java code.
Any ideas ? Below is the code I am using now
import java.io.File;
import java.io.FileNotFoundException;
import com.sleepycat.db.DatabaseException;
import com.sleepycat.db.Environment;
import com.sleepycat.db.EnvironmentConfig;
import com.sleepycat.dbxml.XmlContainer;
import com.sleepycat.dbxml.XmlException;
import com.sleepycat.dbxml.XmlInputStream;
import com.sleepycat.dbxml.XmlManager;
import com.sleepycat.dbxml.XmlUpdateContext;
import com.sleepycat.dbxml.XmlDocument;
import com.sleepycat.dbxml.XmlQueryContext;
import com.sleepycat.dbxml.XmlQueryExpression;
import com.sleepycat.dbxml.XmlResults;
import com.sleepycat.dbxml.XmlValue;
public class bdb{
public static void main(String[] args)
Environment myEnv = null;
File envHome = new File("D:/xmldata");
try {
EnvironmentConfig envConf = new EnvironmentConfig();
envConf.setAllowCreate(true); // If the environment does not
// exits, create it.
envConf.setInitializeCache(true); // Turn on the shared memory
// region.
envConf.setInitializeLocking(true); // Turn on the locking subsystem.
envConf.setInitializeLogging(true); // Turn on the logging subsystem.
envConf.setTransactional(true); // Turn on the transactional
envConf.setRunRecovery(true);
// subsystem.
myEnv = new Environment(envHome, envConf);
// Do BDB XML work here.
} catch (DatabaseException de) {
// Exception handling goes here
} catch (FileNotFoundException fnfe) {
// Exception handling goes here
} finally {
try {
if (myEnv != null) {
myEnv.close();
} catch (DatabaseException de) {
// Exception handling goes here
XmlManager myManager = null;
XmlContainer myContainer = null;
// The document
String docString = "D:/xmldata/test.xml";
// The document's name.
String docName = "cia";
try {
myManager = new XmlManager(); // Assumes the container currently exists.
myContainer =
myManager.createContainer("twoppro.bdbxml");
myManager.setDefaultContainerType(XmlContainer.NodeContainer); // Need an update context for the put.
XmlUpdateContext theContext = myManager.createUpdateContext(); // Get the input stream.
XmlInputStream theStream =
myManager.createLocalFileInputStream(docString); // Do the actual put
myContainer.putDocument(docName, // The document's name
theStream, // The actual document.
theContext, // The update context
// (required).
null); // XmlDocumentConfig object
theStream.delete();
// Update the title
String STATEMENT1 = "for $n in collection('twoppro.bdbxml')/Bookstore/Book[book_ID=1]/title return replace value of node $n with 'NEWBOOK'";
XmlQueryContext context = myManager.createQueryContext();
XmlQueryExpression queryExpression1 = myManager.prepare(STATEMENT1, context);
System.out.println("Done query: " + STATEMENT1);
queryExpression1.execute(context);
// Get a query context
XmlQueryContext thiscontext = myManager.createQueryContext();
// Set the evaluation type to Lazy.
context.setEvaluationType(XmlQueryContext.Lazy);
// Declare the query string
String queryString =
"for $u in collection('twoppro.dbxml')/Bookstore/Book/[bookid=1]"
+ "return $u/title";
// Prepare (compile) the query
XmlQueryExpression qe = myManager.prepare(queryString, thiscontext);
XmlResults results = qe.execute(thiscontext);
System.out.println("ok");
System.out.println(results);
} catch (XmlException e) {
// Error handling goes here. You may want to check
// for XmlException.UNIQUE_ERROR, which is raised
// if a document with that name already exists in
// the container. If this exception is thrown,
// try the put again with a different name, or
// use XmlModify to update the document.
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (myContainer != null) {
myContainer.close();
if (myManager != null) {
myManager.close();
} catch (XmlException ce) {
// Exception handling goes here
Thanks. -
Hi, i have the following data
document_seq_num, Country, LE, SOB
33100037 NL 000320 13
33100037 NL 000320 13
33100037 NL 000320 13
33100037 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
i want an update statement for every change in the document sequnce with the other combination..
the seqence number should change.
i tried to write a rank over partion and and sequence but when i am trying to update, this is always updating
90000000 in first run, as it is in loop for all records it is updating the same. i want an
increment to the sequence for every change in document_seq_num
Can any one help me to correct this procedure
create or replace PROCEDURE test is
cursor cur_voc_ref
IS SELECT a.document_seq_num,
a.country, a.LE, a.SOB, 2009, Rank() over (partition by
a.country, a.LE, a.SOB
order by a.document_seq_num, a.country, a.LE, a.SOB)
from (select distinct document_seq_num,
country, LE, SOB,period_name
from temp_tab
where country= 'NL'
and LE= '000320'
and SOB=13
order by SOB,LE,document_seq_num) a
where
a.country= 'NL'
and a.LE= '000320'
and a.SOB=13
and substr(a.period_name,5,6) =substr(2009,3,4);
v_base number;
BEGIN
FOR c_rec IN cur_voc_ref
LOOP
BEGIN
select nvl(max(ggtsi.reference), substr(2009,3,2)*1000000) into v_base
from temp_tab ggtsi;
update temp_tab
set reference= v_base
where document_seq_num= c_rec.document_seq_num
and country=c_rec.country
and le=c_rec.le
and sob=c_rec.sob;
commit;
END;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( 'Exception in opening balance insert ' || SQLCODE || ' ' || SQLERRM );
END;user11289444 wrote:
Hi, i have the following data
document_seq_num, Country, LE, SOB
33100037 NL 000320 13
33100037 NL 000320 13
33100037 NL 000320 13
33100037 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
i want an update statement for every change in the document sequnce with the other combination..
the seqence number should change.
i tried to write a rank over partion and and sequence but when i am trying to update, this is always updating
90000000 in first run, as it is in loop for all records it is updating the same. i want an
increment to the sequence for every change in document_seq_num
Can any one help me to correct this procedure
create or replace PROCEDURE test is
cursor cur_voc_ref
IS SELECT a.document_seq_num,
a.country, a.LE, a.SOB, 2009, Rank() over (partition by
a.country, a.LE, a.SOB
order by a.document_seq_num, a.country, a.LE, a.SOB)
from (select distinct document_seq_num,
country, LE, SOB,period_name
from temp_tab
where country= 'NL'
and LE= '000320'
and SOB=13
order by SOB,LE,document_seq_num) a
where
a.country= 'NL'
and a.LE= '000320'
and a.SOB=13
and substr(a.period_name,5,6) =substr(2009,3,4);
v_base number;
BEGIN
FOR c_rec IN cur_voc_ref
LOOP
BEGIN
select nvl(max(ggtsi.reference), substr(2009,3,2)*1000000) into v_base
from temp_tab ggtsi;
update temp_tab
set reference= v_base
where document_seq_num= c_rec.document_seq_num
and country=c_rec.country
and le=c_rec.le
and sob=c_rec.sob;
commit;
END;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( 'Exception in opening balance insert ' || SQLCODE || ' ' || SQLERRM );
END;Hi,
I suggest you to add a column to preserve current RANK value for all rows, <preserve_rank> for example, and
when you add the new rows you will update your <preserve_rank> but you must pay attention to have the same value for
document_seq_num, with other words you may insert yours rows in a batch like this:
-- first update preserve_rank with RANK function
declare
v_doc_seq_num numeric;
begin
v_doc_seq_num:=33100040;
-- note !!!
-- put all into a valid sql command
-- and apply execute immediate
insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
-- update preserve_rank
update temp_tab x set x.preserve_rank = (Select max(preserve_rank) from temp_tab y
where y.document_seq_num=v_doc_seq_num) old_rank + 1)
where (prserve_rank is null) and x.document_seq_num=v_doc_seq_num;
end; I know it's a lost a memory but the trigger is the last solution who can give us a nightmare.
Regards,
Ion
Edited by: user111444777 on Sep 25, 2009 11:12 AM
Edited by: user111444777 on Sep 25, 2009 11:35 AM -
Create table temp_sibs as
(select 1701 sib_1, 1702 sib_2 from dual
union all
select 1171,1172 from dual
union all
select 1701,1172 from dual
union all
select 1171,1174 from dual
union all
select 1173,1176 from dual
union all
select 2001,2004 from dual
union all
select 2001,2006 from dual
union all
select 2002,2006
from dual)
create table temp_sib_data as
(select 111 pid, 1701 sibid, 5 amt from dual
union all
select 111 pid, 1176 sibid, 5 from dual
union all
select 222 pid, 2006 sibid, 5 from dual
union all
select 333 pid, 2001 sibid, 5 from dual
union all
select 333 pid, 2002 sibid, 5 from dual
union all
select 333 pid, 1171 sibid, 5 from dual
First table is a lookup table that defines relationships sib_1 is related to sib_2
Second table consists of a column pid and column sibid which is either sib_1 or sib_2
The user would pass parameter pid and sibid and I want to update all the related rows with any matching sibid to 0.
It is like 1701 matches with 1702 and 1701 matches with 1174 so indirectly 1701 and 1174 match...and 1171 matches because
1171 matches with 1174
so all 1701,1702,1171,1172, 1173,1174,1176 match (indirectly with each other)
So for example if the user passes 333 pid and 2001 rows with 333,2001 and 333,2002 should update the amt to 0
and if the user passes 111 and 1176 than 1st 2 rows should be updated to 0.Hi,
try this:
DEFINE PID='333'
DEFINE sibid='2001'
-- SELECT is only for test.
-- Replace SELECT with: UPDATE TEMP_SIB_DATA SET AMT = 0
SELECT * FROM TEMP_SIB_DATA
WHERE PID = &PID AND SIBID IN (
WITH TEMP AS(
SELECT SIB_1, SIB_2 FROM TEMP_SIBS
START WITH SIB_1 = &&SIBID OR SIB_2 = &&SIBID
CONNECT BY NOCYCLE PRIOR SIB_2 = SIB_1
OR PRIOR SIB_1 = SIB_2
OR SIB_2 = PRIOR SIB_2
OR SIB_1 = PRIOR SIB_1
SELECT SIB_1 FROM TEMP
UNION ALL
SELECT SIB_2 FROM TEMP
);For pid=333 and sibid=2001 it returns desired records for update:
PID SIBID AMT
333 2001 5
333 2002 5For pid=111 and=1176 it returns one row - 1176 matches only with 1173 and 1173 doesn't match with any other rows,
so only 5th row, not first 2, should be updated ... maybe I missed something ?
PID SIBID AMT
111 1176 5 -
Need help with update statement with multiple joins
I've got the following select statement that is pulling 29 records:
SELECT
PPA.PROJECT_ID,
PPA.SEGMENT1,
peia.expenditure_item_id,
peia.expenditure_type,
pec.expenditure_comment
FROM PA.PA_PROJECTS_ALL PPA,
pa.pa_expenditure_items_all peia,
pa.pa_expenditure_comments pec
where PPA.segment1 < '2008' and
PPA.project_id = 52 and -- just run for project # 20077119 for testing
peia.expenditure_type = 'PAYROLL' and
peia.project_id = ppa.project_id and
PEC.EXPENDITURE_ITEM_ID = PEIA.EXPENDITURE_ITEM_ID;
I need to update the pec.expenditure_comments to a static field for those 29 records. I assume I should start with the following, but not sure how to complete the where:
update
pa.pa_expenditure_comments pec
set pec.expenditure_comment = 'REFERENCE HD#728'
where
First time that we've ever needed to update, so any and all help appreciated.Try using exists:
update pa.pa_expenditure_comments pec
set pec.expenditure_comment = 'REFERENCE HD#728'
where exists ( select null
from pa.pa_projects_all ppa
, pa.pa_expenditure_items_all peia
, pa.pa_expenditure_comments pec2
where ppa.segment1 < '' -- not sure what you posted here, so for next time:
-- please put your examples between the code tags.
and ppa.project_id = 52 -- just run for project # 20077119 for testing
and peia.expenditure_type = 'PAYROLL'
and peia.project_id = ppa.project_id
and pec2.expenditure_item_id = peia.expenditure_item_id
and pec2.expenditure_item_id = pec.expenditure_item_id
); -
Code Error with Case Statement
Hi everyone,
I'm new to PL/SQL and APEX and I'm trying to get this code to work. It is supposed to insert an sysdate if the named fields are changed and then update the fields.
This is the code:
BEGIN
SELECT ATS_CLS_NAME, ATS_CEL_NAME, ATS_END_DATE,
CASE
WHEN
ATS_CLS_NAME <> :P6_ATS_CLS_NAME
AND ATS_CLS_NAME <> :P6_ATS_CEL_NAME
AND ATS_END_DATE is Null
THEN
UPDATE ATS_ALLOCATION
SET
ATS_ALLOCATION_ID = :P6_ATS_ALLOCATION_ID,
ATS_START_DATE = :P6_ATS_START_DATE,
ATS_END_DATE = SYSDATE,
ATS_CLS_NAME = :P6_ATS_CLS_NAME,
ATS_CEL_NAME = :P6_ATS_CEL_NAME,
ATS_EMP_ID = :P6_EMP_EMP_ID
ELSE
UPDATE ATS_ALLOCATION
SET
ATS_ATS_ALLOCATION = :P6_ATS_ALLOCATION,
ATS_START_DATE = :P6_ATS_START_DATE,
ATS_END_DATE = :P6_ATS_END_DATE,
ATS_CLS_NAME = :P6_ATS_CLS_NAME,
ATS_CEL_NAME = :P6_ATS_CEL_NAME,
ATS_EMP_ID = :P6_EMP_EMP_ID
FROM ATS_ALLOCATION
END CASE;
END;
And I get this error:
1 error has occurred
ORA-06550: line 12, column 7: PL/SQL: ORA-00936: missing expression ORA-06550: line 5, column 1: PL/SQL: SQL Statement ignoredBEGIN
UPDATE ATS_ALLOCATION
SET
ATS_ATS_ALLOCATION = :P6_ATS_ALLOCATION,
ATS_START_DATE = :P6_ATS_START_DATE,
ATS_END_DATE = CASE
WHEN ATS_CLS_NAME <> :P6_ATS_CLS_NAME
AND ATS_CLS_NAME <> :P6_ATS_CEL_NAME
AND ATS_END_DATE is Null
THEN SYSDATE
ELSE :P6_ATS_END_DATE
END,
ATS_CLS_NAME = :P6_ATS_CLS_NAME,
ATS_CEL_NAME = :P6_ATS_CEL_NAME,
ATS_EMP_ID = :P6_EMP_EMP_ID
END;
1 error has occurred
ORA-06550: line 18, column 3: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 4, column 1: PL/SQL: SQL Statement ignored ORA-06550: line 21, column 21: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with -
Problems with Update Statement
How Can I combine these three statements into one single statement.. Heard that I can use Decode command over here... But dont know whether that was correct or not..
Appreciate ur help..
UPDATE LOTIDS_FINAL SET TEAM = 'MLA' WHERE SUBSTR( EXPT,1) = 'A';
UPDATE LOTIDS_FINAL SET TEAM = 'AMD' WHERE SUBSTR( EXPT,1) = 'D';
UPDATE LOTIDS_FINAL SET TEAM = 'TMP' WHERE SUBSTR( EXPT,1) = 'G';
I want these three statements to one statement which can reduce my full table scans from 3 times to 1 time (I think)Try this:
UPDATE LOTIDS_FINAL
SET TEAM = DECODE (SUBSTR( EXPT,1,1), 'A', 'MLA', 'D', 'AMD', 'G', 'TMP', TEAM)
WHERE SUBSTR( EXPT,1,1) in ( 'A', 'D', 'G'); -
Help need with Update statement -Two date columns
I have two tables rate_change and load ,i want to update the next_rate_change_date and next_rate_change_date columns ,load table has rate_change_effe_term column has value (12) that represents months for each loan,
i want to take that rate_change_effe_term from load table and add it to min values of rate_chng_effective_date and then update the next_rate_change_date and then continue to do for all the rows of that loan_numer.
Please see the below sample data.
Current_data:::
Loan_number rate_chng_effective_date next_rate_change_date
111111 02/01/2012 02/01/2014
111111 03/01/2012 02/01/2014
111111 06/01/2012 02/01/2014
111111 07/01/2012 02/01/2014
111111 08/01/2012 02/01/2014
Requrired format
Loan_number rate_chng_effective_date next_rate_change_date
111111 02/01/2012 02/01/2014
111111 02/01/2014 02/01/2016
111111 02/01/2016 02/01/2018
111111 02/01/2018 02/01/2020
111111 02/01/2020 02/01/2022
/* Formatted on 10/24/2012 9:34:23 PM (QP5 v5.227.12220.39724) */
CREATE TABLE rate_change
loan_number NUMBER (10),
rate_chng_effective_date VARCHAR2 (20),
next_rate_change_date VARCHAR2 (20)
INSERT INTO rate_change
VALUES (111111, '02/01/2012', '02/01/2014');
INSERT INTO rate_change
VALUES (111111, '03/01/2012', '02/01/2014');
INSERT INTO rate_change
VALUES (111111, '06/01/2012', '02/01/2014');
INSERT INTO rate_change
VALUES (111111, '07/01/2012', '02/01/2014');
INSERT INTO rate_change
VALUES (111111, '08/01/2012', '02/01/2014');
COMMIT;
CREATE TABLE Load
loan_number NUMBER (10),
Correct_day VARCHAR2 (20),
rate_change_effe_term VARCHAR2 (20)
INSERT INTO Load
VALUES (111111, '02/20/2012', '24');
INSERT INTO Load
VALUES (222222, '02/15/2010', '96');
COMMIT;
Current_data:::
Loan_number rate_chng_effective_date next_rate_change_date
111111 02/01/2012 02/01/2014
111111 03/01/2012 02/01/2014
111111 06/01/2012 02/01/2014
111111 07/01/2012 02/01/2014
111111 08/01/2012 02/01/2014
Requrired format
Loan_number rate_chng_effective_date next_rate_change_date
111111 02/01/2012 02/01/2014
111111 02/01/2014 02/01/2016
111111 02/01/2016 02/01/2018
111111 02/01/2018 02/01/2020
111111 02/01/2020 02/01/2022
Any ideas ,suggestion greatly helps . Thank you very much.try with below query.
update rate_change
SET rate_chng_effective_date = To_CHAR(ADD_MONTHS((select MIN(TO_DATE(rate_chng_effective_date,'MM/DD/YYYY'))
FROM rate_change
WHERE loan_number = 111111)
(rownum -1)*(select rate_change_effe_term
FROM Load
WHERE loan_number =111111) ),'MM/DD/YYYY' )
,next_rate_change_date = To_CHAR(ADD_MONTHS((select MIN(TO_DATE(next_rate_change_date,'MM/DD/YYYY'))
FROM rate_change
WHERE loan_number = 111111)
(rownum -1)*(select rate_change_effe_term
FROM Load
WHERE loan_number =111111) ),'MM/DD/YYYY' )
WHERE loan_number = 111111 ;Thanks,ram -
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 -
Help on update statement in Apply DML Handler
I followed the example given in Streams document.
The document has the code for converting DELETE on the source to INSERT on the target. I added the dml handler code INSERT and UPDATE statements also.
In DELETE, INSERT, UPDATE dml handler code, I am setting the command type to 'INSERT' so that I can insert the data in the target table.
It is working fine for DELETE and INSERT statements.
When I do update on the source table,
I see only the value for the column I updated and all other columns are showing blank. May be this is the normal behaviour. How do I see the values for entire record. Do I need to join the source table based on the key column to get the data for the columns that were not updated.
Also, I thought I should at least see the values for key column and updated column in the target table. It only shows the value for updated column but not for key column. But, When I choosed the old values (I know we need new values, but I just did it for test purpose) in the UPDATE DML handler, it shows the values for key column and the updated column.
When I read the data in the LCR record using get_value('old', 'EMPLOYEE_ID') and get_value('NEW', 'FIRST_NAME')
for key column, it shows the value in both old and new. I do not understand why it is not inserting the key column value in the target table.
Thanks for your help in advance.
Best regards,I forgot to mention these things.
We added supplmental logging using alter database add supplemental log data (primary key, unique index) columns;
I also added the supplemental logging on the source key column (employee_id) using ALTER TABLE emp ADD SUPPLEMENTAL LOG GROUP log_group_emp_pk (employee_id) ALWAYS;
I also set the key column on the target table using DBMS_APPLY_ADM.SET_KEY_COLUMNS.
Thanks for your help in advance.
Best regards, -
Update Statement through function
Hi,
I've got the following select statement that is pulling 29 records:
select distinct aqh.quote_number, aqh.quote_header_id,aqh.quote_version, aql.line_number, msi.inventory_item_id, msi.segment1
,aqh.price_list_id, aqh.quote_expiration_date,aql.line_list_price, qpv.operand
from aso_quote_headers_all aqh, aso_quote_lines_all aql,mtl_system_items msi
,qp_list_headers qlh, qp_list_lines qpl, qp_list_lines_v qpv
where aqh.quote_header_id = aql.quote_header_id
and aql.inventory_item_id = msi.inventory_item_id
and aqh.price_list_id = qlh.list_header_id
and qlh.list_header_id = qpl.list_header_id
and qlh.list_header_id = qpv.list_header_id
and qpl.list_line_id = qpv.list_line_id
and msi.inventory_item_id = qpv.product_id
and aqh.quote_number = :quote_number --56530
i need to update the operand = list_line_price, for all the multiple 29 records. for every quote_number and quote_version_no.
i need help in this to write a function with update statement.
Thanks and RegardsHi,
whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements) for all the tables, and the results you want from that data. In the case of a DML operation (like UPDATE) the results will be the contents of the changed table after the DML is finished.
MERGE may be easier to use than UPDATE in this case.
Put your existing query in the USING clause. The only columns it needs to include in the SELECT clause are those that identify which rows to update, and the new values (line_list_price in this case). I assume that the table to be updated has a unique key, which I called primary_key in the example below. This can actually be two or more columns, but it can't include the column being updated (operand).
I assume that all the tables and all the conditions in your original query are necessary to get the columns in the SELECT clause. If not, you can simplify the query.
MERGE INTO qp_list_lines_v dst
USING (
select distinct aql.line_list_price, qpv.primary_key
from aso_quote_headers_all aqh, aso_quote_lines_all aql,mtl_system_items msi
,qp_list_headers qlh, qp_list_lines qpl, qp_list_lines_v qpv
where aqh.quote_header_id = aql.quote_header_id
and aql.inventory_item_id = msi.inventory_item_id
and aqh.price_list_id = qlh.list_header_id
and qlh.list_header_id = qpl.list_header_id
and qlh.list_header_id = qpv.list_header_id
and qpl.list_line_id = qpv.list_line_id
and msi.inventory_item_id = qpv.product_id
and aqh.quote_number = :quote_number --56530
) src
ON (src.primary_key = dst.primary_key)
WHEN MATCHED THEN UPDATE
SET dst.operand = src.list_line_price;You can use a MERGE statement like this in a PL/SQL procedure or function. (If you put this in a function, then you can only call the function from PL/SQL; you can't use a function that performs DML in a SQL query.)
As posted above, the statement will use a single, given quote_number. (You mentioned another column, quote_version_number, that does not appear in your original query. It's unclear what you want with that column.)
You can replace the bind variable :quote_number with an argument to the procedure, as Achyut suggested. It will still only work on a single, given quote_number.
If you want it to work on all quote numbers at once, then omit the last condition (the one that references quote_number), or change it to
AND aqh.quote_number IS NOT NULLdepending on your needs.
If you want more help, post some sample data and the desired results. -
Run Aggregate Without Update Stats
When ever I choose "Roll-up of filled aggreates" in my process chain it does the rollup in 180 seconds and then spends 1 hr with update stats. The update stats does not need to run but once per weekend. Is there a way to do the rollup without the update stats part.
Also does the same if you click the "Rollup" from the infopackage.
Any help will be rewarded !
Thanks
RichardThere is an RSADMIN option that turns off all BW initiated stats collection, at which point you must have an appropriate process in place by running BRCONNECT or other statistics collection approach.
Also saw a new Note <a href="https://websmp104.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=012003146900000053702006">938040</a>that indiates there is some debate at SAP whether the option should continue to be supported beyond 2004s SP7.
Check Notes - Deactivating BW-initiated DB statistics <a href="https://websmp104.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=012006153200001729112002">555030</a> -
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
Maybe you are looking for
-
Can I charge my new ipod using firewire power adapter?
Just got my new 30GB ipod and realised that it doesn't come with power adapter to plug in directly in power outlet. Can I use the firewire power adapter which I have leftover after my 3rd gen ipod died on me? Also can I use the firewire to connect it
-
hi i have the next code: PROVIDE * FROM p0001 FROM p0002 FROM p0006 BETWEEN PN-BEGDA AND PN-ENDDA. if ( P0006-subty = '1' ). it_alv-pernr = pernr-pernr. it_alv-begda = p0001-begda. it_alv-endda = p0001-endda. it_alv
-
Error: ERR_WIS_30270 in BO XI 4.0
Hi Experts!!! I have installed the BO XI 4.0, but in the Web Intelligence when I create a WebI, it happen this error: API 'initInstance' Error: ERR_WIS_30270 any idea? thanks in advance!!!
-
Wants to sync to external HD that's no longer there
I have an IPOD that works wonderfully. At one time I tried syncing it to an external HD that contained more songs than my IPOD had capacity for. At the time I didn't have time to search for the songs I really wanted so I set the task aside for anothe
-
Unmount shares after period of time
I am wondering if there is a way that we can have networked shares unmount after a certain period of inactivity. We have way to many unused shared being mounted and left open, and it seems to be causing some network issues (Once all the shares are un