Sender JDBC: help to construct Update statement
Hi,
I need help in writing a update statement to DB2 database in sender JDBC adapter.
The sender adapter picks up only few records say 10 at a time which match the Select query condition. So I would need to update only those selected "n" records and not all the records that match the Select query condition.
Select looks like :
Select * from <table> where <condition> fetch first <n> rows only.
But it is not allowing the following update
update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> fetch first <n> rows only)
The above statement errors because DB2 does not allows u201CFetchu201D statement within the update sub query.
Any pointers to a write update statement for n records is highly appreciatedu2026
~SaNvu2026
Hi Santosh,
In JDBC Sender Adapter provide the following select & update statements
Select Statement:
select * from <table> where <condition> AND ROWNUM<N (N==No.of Rows)
Update Statement:
update <table> set <field> = <value> where <field> IN (Select * from <table> where <condition> AND ROWNUM<N)
(N==No.of Rows)
And for the error you are facing is because of the server communication link failure between the two systems.
Check the connections and try to stop & start communication channels once.
Regards
Venkat Rao .G
Similar Messages
-
Help with this update statement..
Hi everyone,
I am trying to update a column in a table .I need to update that column
with a function that takes patient_nbr and type_x column values as a parameter.
That table has almost "300,000" records. It is taking long time to complete
almost 60 min to 90 min.
Is it usual to take that much time to update that many records?
I dont know why it is taking this much time.Please help with this update statement.
select get_partner_id(SUBSTR(patient_nbr,1,9),type_x) partner_id from test_load;
(it is just taking 20 - 30 sec)
I am sure that it is not the problem with my function.
I tried the following update and merge statements .Please correct me if i am wrong
in the syntax and give me some suggestions how can i make the update statement fast.
update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
merge into test_load a
using (select patient_nbr,type_x from test_load) b
on (a.patient_nbr = b.patient_nbr)
when matched
then
update
set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
there is a index on patient_nbr column
and the statistics are gathered on this table.Hi Justin,
As requested here are the explain plans for my update statements.Please correct if i am doing anything wrong.
update test_load set partner_id = get_partner_id(SUBSTR(patient_nbr,1,9),type_x);
"PLAN_TABLE_OUTPUT"
"Plan hash value: 3793814442"
"| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |"
"| 0 | UPDATE STATEMENT | | 274K| 4552K| 1488 (1)| 00:00:18 |"
"| 1 | UPDATE | TEST_LOAD | | | | |"
"| 2 | TABLE ACCESS FULL| TEST_LOAD | 274K| 4552K| 1488 (1)| 00:00:18 |"
merge into test_load a
using (select patient_nbr,type_x from test_load) b
on (a.patient_nbr = b.patient_nbr)
when matched
then
update
set a.partner_id = get_partner_id(SUBSTR(b.patient_nbr,1,9),b.type_x);
"PLAN_TABLE_OUTPUT"
"Plan hash value: 1188928691"
"| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |"
"| 0 | MERGE STATEMENT | | 274K| 3213K| | 6660 (1)| 00:01:20 |"
"| 1 | MERGE | TEST_LOAD | | | | | |"
"| 2 | VIEW | | | | | | |"
"|* 3 | HASH JOIN | | 274K| 43M| 7232K| 6660 (1)| 00:01:20 |"
"| 4 | TABLE ACCESS FULL| TEST_LOAD | 274K| 4017K| | 1482 (1)| 00:00:18 |"
"| 5 | TABLE ACCESS FULL| TEST_LOAD | 274K| 40M| | 1496 (2)| 00:00:18 |"
"Predicate Information (identified by operation id):"
" 3 - access("A"."patient_nbr"="patient_nbr")"Please give some suggestions..
what's the best approach for doing the updates for huge tables?
Thanks -
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 -
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. -
Regex help for SQL update statement
Hello,
need help from IPS regex guru - trying to build the signature to detect SQL update statement in HTTP requests.
1) Am I correct with regex below specified as Request-Regex?
[Uu][Pp][Dd][Aa][Tt][Ee]([%]20|[+])[\x20-\x7e]+[Ss][Ee][Tt]([%]20|[+])[\x20-\x7e]+=
2) How do I make sure that it detects 'Update' in URI and Arguments only and not in the body on entire webserver response (currently looks like the case)?1) It looks correct to me
2) Typically, the "service HTTP" engine is used to inspect requests and the "TCP string" engine is used to inspect HTTP server responses. If you only want to inspect requests, use the service HTTP engine. -
Help need on update statements
Hi,
How can i write a single update statement instead of these 2 update statements
UPDATE ACCOUNT_TEMP SET REPO_ASSIGN_FLAG = 1
WHERE ARR_ID_ACCT IN
(SELECT LTRIM(ASR1.ARR_ID_ACCT)
FROM ODS_ACCT_STAT_REL ASR1
WHERE ASR1.ACCT_STAT_TYPE = 'SECONDARY'
AND ASR1.ACCT_STAT_CDE IN ('RA','RV'))
UPDATE ACCOUNT_TEMP SET LE_LI_FLAG = 1
WHERE ARR_ID_ACCT IN
(SELECT LTRIM(ASR1.ARR_ID_ACCT)
FROM ODS_ACCT_STAT_REL ASR1
WHERE ASR1.ACCT_STAT_TYPE = 'SECONDARY'
AND ASR1.ACCT_STAT_CDE IN ( 'LI','LV'))
Thanks for your helpupdate account_temp
set repo_assign_flag = case when
arr_id_action in (select ltrim(asr1.apr_id_acct)
from ods_acct_stat_relasr1
where asr1.acct_stat_type = 'SECONDARY'
and asr1.acct_stat_cde in ('RA','RV') then 1
set LE_LI_FLAG = case when
arr_id_acct in (select ltrim(asr1.arr_id_acct)
from ods_acct_stat_rel.asr1
where asr1.acct_stat_type = 'SECONDARY'
and asr1.acct_stat_cde in ('LI', 'LV') THEN 1
;But remember this code will have performace issues dont combine your updated statements if you dont need to.
Code not tested . . .
HTH
Ghulam -
Need help on the update statement
Hi,
I have a small requirement. I have a table called test1 and it has 2 columns, nam and seq. nam is a VARCHAR2(100) and seq is a NUMBER.
In the seq I have values like, 2, 3, 7, 9, 25. I would like to update the seq value in an order such that it will be modifed like, 1, 2, 3, 4 and 5.
Here is the scripts, I have used.
CREATE TABLE test1
(nam VARCHAR2(100),
seq NUMBER);
INSERT INTO test1 VALUES('AAA', 2);
INSERT INTO test1 VALUES('BBB', 3);
INSERT INTO test1 VALUES('CCC', 7);
INSERT INTO test1 VALUES('DDD', 9);
INSERT INTO test1 VALUES('EEE', 25);
COMMIT;
And, I would like to achive this in a simple single DML statement. (The required output would be something like, AAA - 1, BBB - 2 etc,...)
I have tried the following query. It is working fine. But If I have a better solution to it, I would to implement the same.
UPDATE test1 a
SET seq =
(SELECT rn
FROM (SELECT ROW_NUMBER() OVER(ORDER BY seq) rn FROM test1) x
WHERE a.rowid = x.rowid);
PS: I am using Oracle 11.2.0.2.0 (11g)
Thanks In Advance!
With Regards,
VSTSQL> CREATE TABLE test1
2 (nam VARCHAR2(100),
3 seq NUMBER);
Table created.
SQL> INSERT INTO test1 VALUES('AAA', 2);
1 row created.
SQL> INSERT INTO test1 VALUES('BBB', 3);
1 row created.
SQL> INSERT INTO test1 VALUES('CCC', 7);
1 row created.
SQL> INSERT INTO test1 VALUES('DDD', 9);
1 row created.
SQL> INSERT INTO test1 VALUES('EEE', 25);
1 row created.
SQL> COMMIT;
Commit complete.
SQL> select * from test1;
NAM SEQ
AAA 2
BBB 3
CCC 7
DDD 9
EEE 25
5 rows selected.
SQL> update test1 set seq = rownum;
5 rows updated.
SQL> select * from test1;
NAM SEQ
AAA 1
BBB 2
CCC 3
DDD 4
EEE 5
5 rows selected. -
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 -
Help automate an UPDATE Statement with PL/SQL
Hello, I am on 10g R2, I am slowly learning PL/SQL, got a few books, watching videos on youtube and other things about like Best Practices and etc. I wanted to automate this SQL:
Basically each month I have to update a whole bunch of older Tables against the current months Table.
Older Table = ta
Newer Table = tt
I was thinking maybe I can like put into a list (like an array), and list all the older tables in there for ta, I have 26 so far and each month I add +1.
The tt table is just one, that's why I was thinking I could automate that inside a loop ?
UPDATE OLDER_TABLE_DATE ta
SET (ta.GTP, ta.UPDATE_DT) =
(SELECT tt.GTP, SYSDATE
FROM NEWEST_TABLE_UPDATED tt
WHERE ta.customer_id = tt.customer_id
AND ta.STAMP_DATE = tt.STAMP_DATE)
WHERE EXISTS (SELECT 1
FROM NEWEST_TABLE_UPDATED tt
WHERE ta.customer_id = tt.customer_id
AND ta.STAMP_DATE = tt.STAMP_DATE
AND (NVL(ta.GTP, 'X') != NVL(tt.GTP, 'X')));
COMMIT;What do you guys think ? example or help would be appreciated. I can run this as an anonymous block for now, that's fine, thank you!Assumptions:-
-Your all old/new tables are in same schema.
- Their names have word "OLDER".
- You will run the procedure from the same schema where all old and new tables exits.
NOTE: - Please handle exceptions in the given code accordingly, for example, when update fails then handle the exceptions.
-As mention earlier, this approach does not sound very good. A good solution will be change in design such a way that one table(partition on months) stores all the monthly data.
CREATE OR REPLACE PROCEDURE UPDATE_TABLES_PROC
AS
cursor c1 is
select table_name from user_tables
where table_name like '%OLDER%';
type t_current_table is table of c1%rowtype;
v_current_table t_current_table;
SQL_STMT VARCHAR2(3000):=0;
BEGIN
OPEN C1;
LOOP
FETCH C1 BULK COLLECT INTO v_current_table LIMIT 10;
IF v_current_table.count>0 then
FOR i in v_current_table .first..v_current_table .last
LOOP
SQL_STMT:='UPDATE ' ||v_current_table(i).table_name|| ' ta
SET (ta.GTP, ta.UPDATE_DT) =
(SELECT tt.GTP, SYSDATE
FROM NEWEST_TABLE_UPDATED tt
WHERE ta.customer_id = tt.customer_id
AND ta.STAMP_DATE = tt.STAMP_DATE)
WHERE EXISTS (SELECT 1
FROM NEWEST_TABLE_UPDATED tt
WHERE ta.customer_id = tt.customer_id
AND ta.STAMP_DATE = tt.STAMP_DATE
AND (NVL(ta.GTP, ''X'') != NVL(tt.GTP, ''X'')))';
EXECUTE IMMEDIATE SQL_STMT;
EXIT WHEN c1%NOTFOUND;
END LOOP;
END IF;
COMMIT;
EXIT WHEN c1%NOTFOUND;
END LOOP;
CLOSE C1;
END UPDATE_TABLES_PROC; -
Urgent ==can somebody help in constructing SQL statement
Hi,
I have a table called cgryrel with data and fieldnames like below:
CGRYREL
======
crpcgnbr crccgnbr
502 510
502 511
502 512
510 515
511 516
512 517
515 518
516 519
517 520
503 540
503 541
I am trying to get a count of rows that are related to crpcgnbr=502.
To get this information I tried with below SQL statement and ,I get only top level.
select count(*) from cgryrel where crpcgnbr=502
result : 3
I want all rows that are connected to 502?
can somebody in the forum tell me,what I am doing wrong???
Thanks
JackHi limeybrit9,
Lluis ...Doesn't that method sort of require that you already know how
many indentation levels there are if you want all numbers related to
502?Yes, it does. I already said that in my post. I understand that making a select with, lets say, 100 tables supporting 100 indentation levels might be, at least, ugly to see. But it works and it's fast enough. -
Need help reg sender JDBC adapter
Hi,
I am having a requirement like, i need to fetch the data from two data base tables. and after fetching the data, i need to update those two tables.
For selecting the data from two tables, two select statements i need to write, how i can give two select statements in sender JDBC comm channel.
In sender JDBC channel, only one update query we can give...how i can update two tables?
Regards,
Venkata Ramana.Hello Venkat,
For your requirement, go for stored procedure and find the below thread.
Fetching data from JDBC without using JDBC sender adapter
Re: Executing an Oracle Stored Procedure from Sender JDBC adapter
Re: Sender JDBC adapter not picking up data
Re: Retrive data from two diffirent tables
hope this will help you
Thanks,
Venky -
Can some one help me with the following error please?
I just want to read store column from Oracle database table SA_BO_SALES_TEST and create a Flat File. I have JDBC-XI-FILE scenario. I use the same Data Type for Sender(JDBC) and receiver(FILE) Message Type.
the data type is
DT_STSSales_SA_BO_SALES
resultset
row
STORE
The message type is
MT_STSSales_SA_BO_SALES
resultset
row
STORE
The message mapping is between the same message type(MT_STSSales_SA_BO_SALES) for source interface and destination interface.
The sender JDBC Adapter has
Query SQL Statement -
SELECT STORE FROM SA_BO_SALES_TEST WHERE PROCESS_DATE IS NULL
Update SQL Statement -
UPDATE SA_BO_SALES_TEST SET PROCESS_DATE='01-JAN-2006' WHERE PROCESS_DATE IS NULL
Document Name -
resultset
When i execute this scenario, The payload from any pipeline steps is
<?xml version="1.0" encoding="utf-8" ?>
- <resultset>
- <row>
<STORE>1021</STORE>
</row>
- <row>
<STORE>1021</STORE>
</row>
- <row>
<STORE>1021</STORE>
</row>
</resultset>
and it updates the Oracle table with PROCESS_DATE='01-JAN-2006' . But
One of the pipe line step "Request Message Mapping" is failed with the error.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <!-- Request Message Mapping
-->
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
<SAP:Category>Application</SAP:Category>
<SAP:Code area="MAPPING">EXCEPTION_DURING_EXECUTE</SAP:Code>
<SAP:P1>com/sap/xi/tf/_MM_STSSales_IDOC_BAPI_POSTR_CREATE~</SAP:P1>
<SAP:P2>com.sap.aii.utilxi.misc.api.BaseRuntimeException</SAP:P2>
<SAP:P3>RuntimeException in Message-Mapping transformatio~</SAP:P3>
<SAP:P4 />
<SAP:AdditionalText />
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>During the application mapping com/sap/xi/tf/_MM_STSSales_IDOC_BAPI_POSTR_CREATE~ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformatio~</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>Hi Prasad,
<i>converted into the following XML wihtout any errors</i>
<i><?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_STSSales_SA_BO_SALES xmlns:ns0="http://zalecorp.com/sts_posdm_sales_10"><resultset><row><STORE>1021</STORE></row><row><STORE>1021</STORE></row><row><STORE>1021</STORE></row></resultset></ns0:MT_STSSales_SA_BO_SALES></i>
If you have given the name for your Datatype as "<ns0:MT_STSSales_SA_BO_SALES xmlns:ns0="http://zalecorp.com/sts_posdm_sales_10">", then the RESULTSET tag is not to be used.
You will have to enter this Value <b>MT_STSSales_SA_BO_SALES</b> in the SENDER JDBC ADAPTER > DOCUMENT NAME and <b>http://zalecorp.com/sts_posdm_sales_10</b> in SENDER JDBC ADAPTER> DOCUMENT NAMESPACE and then <b>Remove the Result Set tag.</b>
just take a look at the Document Name part of the JDBC adapter in this link,
http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
Regards,
Bhavesh -
Hi all, consider the tables and data below
CREATE TABLE table1 (id NUMBER, a NUMBER, b NUMBER) ;
CREATE TABLE table2 (id NUMBER, c NUMBER, d NUMBER);
INSERT INTO table1 VALUES(111,2,0);
INSERT INTO table1 VALUES(111,1,2);
INSERT INTO table1 VALUES(111,1,3);
INSERT INTO table1 VALUES(222,1,3);
INSERT INTO table2 VALUES(111,5,8);
INSERT INTO table2 VALUES(222,6,7);
what i want to do is write a UPDATE STATEMENT that joins the two tables BY id
and update table1 rows. i want to include the following CASE statement
UPDATE COLUMN a intable1 according to this logic
case
WHEN b >0
THEN nvl(c,b)
ELSE
d
END
so table1 after the update should look like this
id a b
111 8 0
111 5 2
111 5 3
222 6 3can somebody help write a update statement that update table1 according to case statement and joins both tables to get the values necessary? thanksHooray for sample tables!
SQL> alter table table2 add constraint table2_pk primary key (id);
Table altered.
SQL> update
2 (select t1.a
3 ,case when t1.b > 0 then nvl(t2.c, t1.b)
4 else t2.d
5 end new_value
6 from table1 t1
7 join table2 t2
8 on t1.id = t2.id
9 )
10 set a = new_value;
4 rows updated.
SQL> select * from table1;
ID A B
111 8 0
111 5 2
111 5 3
222 6 3 -
Execution time difference between SELECT & UPDATE statement in JDBC Sender.
Hi Experts,
In my scenario, I have used the JDBC Sender Adapter with the SELECT and UPDATE statement.
Now the problem is in between the execution of Select and update statement, few more entries are coming in the same DB Table.
So result of this is updation take place for those entries which are not even picked up by the select statement.
Can we avoid this execution time difference between the SELECT & UPDATE statemet on JDBC Sender side???
Thanks & Regards
JageshHi
Use serializable option in additional parameters, now all new entries would also be updated. -
Sender JDBC adapter : Update SQL Statement : stored procedure
Hi,
Can we use a stored procedure in the sender jdbc adapter in 'Update SQL Statement'.
The problem i am facing is like, we are selecting data from two tables in 'SQL statement for query' and then in 'Update SQL Statement' , we need to delete that data from these two tables.
Please let me know if it is possible.
Thanks,
Rohityou can use a Stored procedure in the
Query SQL Statement
You have the following options:
· Specify a valid SQL SELECT statement to select the data to be sent from the specified database.
· Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
The expression must correspond to the SQL variant supported by the relevant JDBC driver. It can also contain table JOINs.
so have your whole select and update as part of this single Stored procedure
Maybe you are looking for
-
Sales order replication to ECC
Hi All, We are working on CRM 2007. Our problem is that the sales orders created in IC Web are not flowing to ECC. The BDoc is in F04 state but showing error messages like "No upload into R/3" and "R/3 Adapter is called". We are not able to figure ou
-
Can't find newly purchased movies
I just bought Spider-Man trilogy on my Mac mini and it shows up as a charge on my account- but I can't find the movies (the spider-man movies). Not in my library, not in available downloads. ??
-
Just swapped the RAM on my mini Solo - Easy Peezy No Scaring
and that dudes directions: http://www.123macmini.com/news/story/456.html were right on. All I needed was a putty knife which I was able to find the exact one he used on the site at ace hardware for 4.99. Look for the black handle with the gold top, s
-
Can anyone explain why all of my Spry Assets on a live website have suddenly stopped working?
Can anyone explain why all of my Spry Assets on a live website have stopped responding? I have checked that the Spry CSS and JS files are in place. Then checked the files on Dreamweavers live view and they are not working there either. It was fine a
-
Error when connecting iPod Video
Hi I have owned my iPod Video for a couple of months now, and my Macbook for 6 months. iTunes and iPod have been working well together, no problems. However today when I connected my iPod into my Macbook, iTunes freezes for about 5 seconds then "quit