SQL statement, updateString and updateRow
i need some help by using updateString an updateRow
i have to update some databases ever 3 months.
all together 250,000 datasets.
one row should be read out, modified and written back.
at the moment i do it like that:
rs = dbconnect ...(..."select rrn(database),database.row from database)
while (rs.next())
str = rs.getString(2);
i = rs.getInt(1);
..executeSqlStatement(..."update database set row = " + str + " where rrn(database) = "+i);
rs.close();
but that is very longlasting.
i tryed it with updateString and updateRow, but it didn't work.
Is it possible to say SQL, if one hit made, stop the search?
my statements alsways run through the hole databases, although
its sure that there is only one hit, especially if the "rrn"-statement is
included in the condition.
is
we use our "own" connect-method, called dbconnect:
statement = getConnection(x_systemname).createStatement();
rs = statement.executeQuery(x_sqlstatement);
return rs;You need to explicitly say it whether you want a ResultSet updatable:
stm = getConnection(x_systemname)
.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE
);That way you are able to perform updates with updateXXX() methods and updateRow() at the end.
Similar Messages
-
Capture all SQL statements and archive to file in real time
Want to Capture all SQL statements and archive to file in real time?
Oracle Session Manager is the tool just you need.
Get it at http://www.wangz.net
This tools monitor how connected sessions use database instance resources in real time. You can obtain an overview of session activity sorted by a statistic of your choosing. For any given session, you can then drill down for more detail. You can further customize the information you display by specifying manual or automatic data refresh, the rate of automatic refresh.
In addition to these useful monitoring capabilities, OSM allows you to send LAN pop-up message to users of Oracle sessions.
Features:
--Capture all SQL statement text and archive to files in real time
--Pinpoints problematic database sessions and displays detailed performance and resource consumption data.
--Dynamically list sessions holding locks and other sessions who are waiting for.
--Support to kill several selected sessions
--Send LAN pop-up message to users of Oracle sessions
--Gives hit/miss ratio for library cache,dictionary cache and buffer cache periodically,helps to tune memory
--Export necessary data into file
--Modify the dynamic system parameters on the fly
--Syntax highlight for SQL statements
--An overview of your current connected instance informaiton,such as Version, SGA,License,etc
--Find out object according to File Id and Block Id
Gudu Software
http://www.wangz.netAnkitV wrote:
Hi All
I have 3 statements and I am writing some thing to a file using UTL_FILE.PUT_LINE after each statement is over. Each statement takes mentioned time to complete.
I am opening file in append mode.
statement1 (takes 2 mins)
UTL_FILE.PUT_LINE
statement2 (takes 5 mins)
UTL_FILE.PUT_LINE
statement3 (takes 10 mins)
UTL_FILE.PUT_LINE
I noticed that I am able to see contents written by UTL_FILE.PUT_LINE only after statement3 is over, not IMMEDIATELY after statement1 and statement2 are done ?
Can anybody tell me if this is correct behavior or am I missing something here ?Calling procedure must terminate before data is actually written to the file.
It is expected & correct behavior. -
JDBC Sender Adapter - SQL-Statement
Hi,
I'm using the JDBC-Sender-Adapter and need to use a SQL-Statement like this:
SELECT * FROM myTable WHERE myDate = <current_date>
Is such a dynamic-sql possible, or can I only use static sql-statements. And if yes how can I solve this problem.
many thxHi Werner,
inside the <b>Query SQL Statement</b> you can use <b>SQL EXECUTE</b>
which can execute a stored procedure
in which you can do
SELECT * FROM myTable WHERE myDate = <current_date>
http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions">XI FAQ - Frequently Asked Questions</a> -
Using 1 = 1 in SQL Statements
I have just been told by our DBA that we have to go through
our code and remove the "WHERE 1 = 1" in our SQL statements on a
SQL 2000 database. He said it is a performance issue when nothing
else follows it (no AND's).
For example (the wrong way):
SELECT this_ID FROM thistable WHERE 1 = 1
Versus...
SELECT this_ID FROM thistable WHERE 1 = 1 AND this_ID = 1001
He said Microsoft said that this is causing a performance hit
when there is no AND clauses after the WHERE.
Some of these SQL statements are pretty big and there is no
practical way to do a CFIF beforehand.
Has anyone heard of a performance hit like this? If so, how
much of a hit? The main table in the DB has about 2 million records
with full text indexes.
Thanks,
Rob in TampaPhil,
Thanks for the speedy response. I forgot to mention.. there
are TOP 200 clauses in all the big SQL statements.
And, like I said before... some of the queries are too big to
test to see if at least 1 of the condidtions exsist. More often
than not, the WHERE 1 = 1 clause will not be alone. I personally
think it is a pet peeve of the DBA where he doesn't see any use of
the 1 = 1. He said.. it's always going to be true. Kinda the point
of having it.
This was taught to me years ago.. but, this is the biggest
application I have worked on where SQL performance could be an
issue. It was mentioned that the hit comes when SQL Server is
building its execution plan and has to include the WHERE 1 = 1
clause. How much of a hit can it cause? Most of the empty clauses
with no AND's are most likely in a JOIN clause or something.
The WHERE placeholder is in almost all of our queries in one
way or another. Not a small project.
Thanks,
Rob -
hi
We are getting the following sql statement dump, and i am not able to understand what should be done here, would anyone please advise
Registered qb: SEL$1 0xc4c8a150 (PARSER)
QUERY BLOCK SIGNATURE
signature (): qb_name=SEL$1 nbfros=1 flg=0
fro(0): flg=4 objn=272221 hint_alias="BSAD"@"SEL$1"
SPM: statement not found in SMB
SPM: statement not a candidate for auto-capture
Automatic degree of parallelism (ADOP)
Automatic degree of parallelism is disabled: Parameter.
PM: Considering predicate move-around in query block SEL$1 (#0)
Predicate Move-Around (PM)
PM: PM bypassed: disabled due to star transformation.
OPTIMIZER INFORMATION
----- Current SQL Statement for this session (sql_id=82mdu08rbcnyy) -----
EXPLAIN PLAN SET STATEMENT_ID='SAP_STMT' FOR /*+ 142235 */ SELECT "MANDT" , "BUKRS" , "KUNNR" , "UMSKS" , "UMSKZ" , "AUGDT" , "AUGBL" , "ZUONR"
, "GJAHR" , "BELNR" , "BUZEI" , "BUDAT" , "BLDAT" , "CPUDT" , "WAERS" , "XBLNR" , "BLART" , "MONAT" , "BSCHL" , "ZUMSK" , "SHKZG" , "GSBER" ,
"MWSKZ" , "DMBTR" , "WRBTR" , "MWSTS" , "WMWST" , "BDIFF" , "BDIF2" , "SGTXT" , "PROJN" , "AUFNR" , "ANLN1" , "ANLN2" , "SAKNR" , "HKONT" , "FK
ONT" , "FILKD" , "ZFBDT" , "ZTERM" , "ZBD1T" , "ZBD2T" , "ZBD3T" , "ZBD1P" , "ZBD2P" , "SKFBT" , "SKNTO" , "WSKTO" , "ZLSCH" , "ZLSPR" , "ZBFIX
" , "HBKID" , "BVTYP" , "REBZG" , "REBZJ" , "REBZZ" , "SAMNR" , "ANFBN" , "ANFBJ" , "ANFBU" , "ANFAE" , "MANSP" , "MSCHL" , "MADAT" , "MANST" ,
"MABER" , "XNETB" , "XANET" , "XCPDD" , "XINVE" , "XZAHL" , "MWSK1" , "DMBT1" , "WRBT1" , "MWSK2" , "DMBT2" , "WRBT2" , "MWSK3" , "DMBT3" , "W
RBT3" , "BSTAT" , "VBUND" , "VBELN" , "REBZT" , "INFAE" , "STCEG" , "EGBLD" , "EGLLD" , "RSTGR" , "XNOZA" , "VERTT" , "VERTN" , "VBEWA" , "WVER
W" , "PROJK" , "FIPOS" , "NPLNR" , "AUFPL" , "APLZL" , "XEGDR" , "DMBE2" , "DMBE3" , "DMB21" , "DMB22" , "DMB23" , "DMB31" , "DMB32" , "DMB33"
, "BDIF3" , "XRAGL" , "UZAWE" , "XSTOV" , "MWST2" , "MWST3" , "SKNT2" , "SKNT3" , "XREF1" , "XREF2" , "XARCH" , "PSWSL" , "PSWBT" , "LZBKZ" , "
LANDL" , "IMKEY" , "VBEL2" , "VPOS2" , "POSN2" , "ETEN2" , "FISTL" , "GEBER" , "DABRZ" , "XNEGP" , "KOSTL" , "RFZEI" , "KKBER" , "EMPFB" , "PRC
TR" , "XREF3" , "QSSKZ" , "ZINKZ" , "DTWS1" , "DTWS2" , "DTWS3" , "DTWS4" , "XPYPR" , "KIDNO" , "ABSBT" , "CCBTC" , "PYCUR" , "PYAMT" , "BUPLA"
, "SECCO" , "CESSION_KZ" , "PPDIFF" , "PPDIF2" , "PPDIF3" , "KBLNR" , "KBLPOS" , "GRANT_NBR" , "GMVKZ" , "SRTYPE" , "LOTKZ" , "FKBER" , "INTRE
NO" , "PPRCT" , "BUZID" , "AUGGJ" , "HKTID" , "BUDGET_PD" , "KONTT" , "KONTL" , "UEBGDAT" , "VNAME" , "EGRUP" , "BTYPE" , "PROPMANO" , "YYSTORE
" , "YYDELGRP" , "YYBOLNR" FROM "BSAD" WHERE "MANDT" = :A0 AND "KUNNR" IN ( :A1 , :A2 , :A3 , :A4 , :A5 ) AND "BUKRS" = :A6 AND "AUGDT" = :A7
user_id=27 user_name=SAPSR3 module=RSXPLORA action=7093
sql_id=82mdu08rbcnyy plan_hash_value=1162638466 problem_type=3
----- Current SQL Statement for this session (sql_id=82mdu08rbcnyy) -----
EXPLAIN PLAN SET STATEMENT_ID='SAP_STMT' FOR /*+ 142235 */ SELECT "MANDT" , "BUKRS" , "KUNNR" , "UMSKS" , "UMSKZ" , "AUGDT" , "AUGBL" , "ZUONR"
, "GJAHR" , "BELNR" , "BUZEI" , "BUDAT" , "BLDAT" , "CPUDT" , "WAERS" , "XBLNR" , "BLART" , "MONAT" , "BSCHL" , "ZUMSK" , "SHKZG" , "GSBER" ,
"MWSKZ" , "DMBTR" , "WRBTR" , "MWSTS" , "WMWST" , "BDIFF" , "BDIF2" , "SGTXT" , "PROJN" , "AUFNR" , "ANLN1" , "ANLN2" , "SAKNR" , "HKONT" , "FK
ONT" , "FILKD" , "ZFBDT" , "ZTERM" , "ZBD1T" , "ZBD2T" , "ZBD3T" , "ZBD1P" , "ZBD2P" , "SKFBT" , "SKNTO" , "WSKTO" , "ZLSCH" , "ZLSPR" , "ZBFIX
" , "HBKID" , "BVTYP" , "REBZG" , "REBZJ" , "REBZZ" , "SAMNR" , "ANFBN" , "ANFBJ" , "ANFBU" , "ANFAE" , "MANSP" , "MSCHL" , "MADAT" , "MANST" ,
"MABER" , "XNETB" , "XANET" , "XCPDD" , "XINVE" , "XZAHL" , "MWSK1" , "DMBT1" , "WRBT1" , "MWSK2" , "DMBT2" , "WRBT2" , "MWSK3" , "DMBT3" , "W
RBT3" , "BSTAT" , "VBUND" , "VBELN" , "REBZT" , "INFAE" , "STCEG" , "EGBLD" , "EGLLD" , "RSTGR" , "XNOZA" , "VERTT" , "VERTN" , "VBEWA" , "WVER
W" , "PROJK" , "FIPOS" , "NPLNR" , "AUFPL" , "APLZL" , "XEGDR" , "DMBE2" , "DMBE3" , "DMB21" , "DMB22" , "DMB23" , "DMB31" , "DMB32" , "DMB33"
, "BDIF3" , "XRAGL" , "UZAWE" , "XSTOV" , "MWST2" , "MWST3" , "SKNT2" , "SKNT3" , "XREF1" , "XREF2" , "XARCH" , "PSWSL" , "PSWBT" , "LZBKZ" , "
LANDL" , "IMKEY" , "VBEL2" , "VPOS2" , "POSN2" , "ETEN2" , "FISTL" , "GEBER" , "DABRZ" , "XNEGP" , "KOSTL" , "RFZEI" , "KKBER" , "EMPFB" , "PRC
TR" , "XREF3" , "QSSKZ" , "ZINKZ" , "DTWS1" , "DTWS2" , "DTWS3" , "DTWS4" , "XPYPR" , "KIDNO" , "ABSBT" , "CCBTC" , "PYCUR" , "PYAMT" , "BUPLA"
, "SECCO" , "CESSION_KZ" , "PPDIFF" , "PPDIF2" , "PPDIF3" , "KBLNR" , "KBLPOS" , "GRANT_NBR" , "GMVKZ" , "SRTYPE" , "LOTKZ" , "FKBER" , "INTRE
NO" , "PPRCT" , "BUZID" , "AUGGJ" , "HKTID" , "BUDGET_PD" , "KONTT" , "KONTL" , "UEBGDAT" , "VNAME" , "EGRUP" , "BTYPE" , "PROPMANO" , "YYSTORE
" , "YYDELGRP" , "YYBOLNR" FROM "BSAD" WHERE "MANDT" = :A0 AND "KUNNR" IN ( :A1 , :A2 , :A3 , :A4 , :A5 ) AND "BUKRS" = :A6 AND "AUGDT" = :A7
sql_text_length=2001
----- Explain Plan Dump -----
----- Plan Table -----
============
Plan Table
============
| Id | Operation | Name | Rows | Bytes | Cost | Time |
| 0 | SELECT STATEMENT | | | | 2 | |
| 1 | INLIST ITERATOR | | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID | BSAD | 1 | 601 | 2 | 00:00:01 |
| 3 | INDEX RANGE SCAN | BSAD~1 | 1 | | 1 | 00:00:01 |
Predicate Information:
3 - access("MANDT"=:A0 AND (("KUNNR"=:A1 OR "KUNNR"=:A2 OR "KUNNR"=:A3 OR "KUNNR"=:A4 OR "KUNNR"=:A5)) AND "BUKRS"=:A6 AND "AUGDT"=:A7)
Content of other_xml column
===========================
db_version : 11.2.0.1
parse_schema : SAPSR3
plan_hash : 1162638466
plan_hash_2 : 3684135643
Outline Data:
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.2.0.1')
DB_VERSION('11.2.0.1')
OPT_PARAM('query_rewrite_enabled' 'false')
OPT_PARAM('_optim_peek_user_binds' 'false')
OPT_PARAM('_optimizer_extended_cursor_sharing_rel' 'none')
OPT_PARAM('_optimizer_adaptive_cursor_sharing' 'false')
OPT_PARAM('_optimizer_use_feedback' 'false')
OPT_PARAM('star_transformation_enabled' 'true')
OPT_PARAM('optimizer_index_cost_adj' 20)
OPT_PARAM('_fix_control' '4728348:0 5483301:0 5705630:1 6626018:1 6440977:1 6972291:1 6399597:1 6430500:1 5099019:1 9196440:1 9495669:1 8
937971:1')
ALL_ROWS
OUTLINE_LEAF(@"SEL$1")
INDEX_RS_ASC(@"SEL$1" "BSAD"@"SEL$1" ("BSAD"."MANDT" "BSAD"."KUNNR" "BSAD"."BUKRS" "BSAD"."AUGDT" "BSAD"."AUGBL" "BSAD"."GJAHR" "BSAD"."B
ELNR" "BSAD"."BUZEI" "BSAD"."BUDAT"))
END_OUTLINE_DATA
Query Block Registry:
SEL$1 0xc4c8a150 (PARSER) [FINAL]
call(in-use=194136, alloc=229336), compile(in-use=233336, alloc=338904), execution(in-use=540368, alloc=544176)
End of Optimizer State Dump
Dumping Hints
=============
====================== END SQL Statement Dump ======================
thx
Jonu Joywould anyone please advise It looks OK to me.
-
Run sql statement in green screen
dear as/400 guru,
i wonder how to execute sql statement in green screen ?
my statement would be something as below
select mandt from sapr3.usr02 where bname='kent';
basically i want to check my id "kent" is available in which clients in an instance. and i was advised to run above sql statement.
comment and advice will be highly appreciated.
thanks
regards,
kent
as/400 newbieHi Kent,
if you are looking for something, that reminds the old SQLs and uses a "/" for the delimiter, get the free STR(CON)SQL tool :
http://www.easymarketplace.de/strsql-sqlutil.php
If you do not receive a mail within 15 minutes, please drop me a mail, I will then reply with the user & pwd ...
Regards
Volker Gueldenpfennig, consolut international ag
http://www.consolut.de - http://www.4soi.de - http://www.easymarketplace.de -
SQL STATEMENT , PLEASE HELP
Hi,
I want some help in writing a SQL Query .Its besically a hierarchical query. Let me lay down the table structure first to explain my requirements better.
PORP_TABLE(NODE_LEVEL int, WBS_ID int, WBS_NUMBER varchar(60), LFT int,RGT int)
SELECT NODE_LEVEL, WBS_ID, LFT,RGT FROM PROPOSAL_WBS PW WHERE PROPOSAL_REV_ID = 7000
(SAMPLE DATA)
NODE WBS
LEVEL WBS_ID NUMBER LFT RGT
0 7055 ROOT 1 24
1 7056 1 2 5
1 7088 2 6 9
2 7057 1.1 3 4
2 7089 2.1 7 8
2 7091 3.1 11 14
2 7103 3.2 15 16
2 7105 4.1 19 20
1 7090 3 10 17
3 7092 3.1.1 12 13
1 7104 4 18 23
2 7106 4.2 21 22
ALLOCATION_DETAIL( WBS_ID int, COST_ID int, PERIOD Date, AMOUNT Float)
sample data
WBS_ID , COST_ID , PERIOD , AMOUNT
7057 100 01-jan-2005 5000
7057 100 01-feb-2005 2000
7057 100 01-mar-2005 1000
7057 100 01-apr-2005 6000
7057 100 01-may-2005 3000
7057 100 01-jun-2005 45000
7106 100 01-mar-2005 8000
7106 100 01-apr-2005 7000
7106 100 01-may-2005 9000
Now the PORP_TABLE has got the parents and childs. Only the leaf nodes in the hierarchy has the values stored in the ALLOCATION_DETAIL table. Now here is the scenario
In the example 7055 is the root WBS . The Leaf WBS are the one with max extension in the wbs number ( in this case it is 1.1, 2.1, 3.1.1, 3.2, 4.1 and 4.2)
Now the Starting period for each leaf node in the ALLOCATION_TABLE could be differrent . What that means is WBS 1.1 could start in Jan -2003 and WBS 3.1 Could be Jul-2005 . So the ending perios are also differrent for differrent WBS . Some can span 2 years some can 5 years.
So how to write a query so it retrieves the value for all the Wbs starting from the MIN ( PERIOD ) upto the MAX(PERIOD), and it should roll up also. Now there is No connect by Prior or any analytic functions available for this . THIS NEEDS TO BE DONE ONLY THROUGH TRADITIONAL SQL STATEMENT . And NO DB FUNCTIONS CAN BE USED .
Now if the WBS is a parent node then it should have the sum of all its child nodes for the COST category.
SO THE RESULT SET SHOULD BRING LIKE THIS
WBS_NUMBER, PERIOD_NUMER, COST_CATEGORY , AMOUNT
ROOT
1
1.1
2
2.1
3
3.1
3.1.1
3.2
4
4.1
4.2
......Thanks for all your thoughtfull replies and feedbacks. Yes it is in Sybase platform . Though I have been woking all along in Oracle , Unfortunately this one is in Sybase, and no the customer cant and wont move to Oracle. So I have to work with it . And if you want to see the table structure . Here are they :
CREATE TABLE PROPOSAL_WBS (
BURDEN_CENTER_ID numeric(18,0) NULL,
START_DATE datetime NULL,
END_DATE datetime NULL,
WBS_ID int NOT NULL,
MODIFIED_DATE datetime NULL,
CREATED_DATE datetime NULL,
MODIFIED_BY varchar(127) NULL,
CREATED_BY varchar(127) NULL,
FEE_PERCENT float NULL,
PROPOSAL_REV_ID int NOT NULL,
PARENT_WBS_ID int NULL,
NAME varchar(127) NULL,
COMMENT varchar(255) NULL,
TARGET_COST float NULL,
MONTHS_REMAINING int NULL,
DEFAULT_STAFF_FTE float NULL,
ANNUAL_GRA_SALARY float NULL,
NUMBER_OF_GRA int NULL,
MANAGEMENT_ADJUSTMENT_TOTAL float NULL,
MA_UNALLOCATED_FUNDS float NULL,
FEE_TOTAL float NULL,
FEE_UNALLOCATED_FUNDS float NULL,
TRAVEL_COMMENTS varchar(255) NULL,
ODC_COMMENTS varchar(255) NULL,
SORT_ORDER int NULL,
LFT int NULL,
RGT int NULL,
NODE_LEVEL int NULL,
WBS_NUMBER varchar(50) NOT NULL,
TOTAL_COST float NULL,
TOTAL_COST_PLUS_FEE float NULL,
PER_MILE_COST float NULL,
PER_DIEM float NULL,
TAX_RATE float NULL,
RENTAL_CAR_PER_DAY_COST float NULL,
TAXI_PER_TRIP_COST float NULL,
CONSTRAINT PK_PROPOSAL_WBS PRIMARY KEY(WBS_ID)
CREATE TABLE PROPOSAL_WBS_ALLOC_DETAIL (
WBS_ID int NOT NULL,
OBJECT_CODE_ID numeric(18,0) NOT NULL,
PERIOD_NUMBER int NOT NULL,
ALLOCATION_AMOUNT float NULL,
PERIOD_YEAR datetime NULL,
CONSTRAINT PK_PROPOSAL_WBS_AD PRIMARY KEY(WBS_ID,OBJECT_CODE_ID,PERIOD_NUMBER)
CREATE TABLE WBS_PERIOD (
PERIOD_NUMBER int NOT NULL
CREATE VIEW WBS_COST_CAT AS
SELECT PROPOSAL_WBS.PROPOSAL_REV_ID,
PROPOSAL_WBS.WBS_ID,
PROPOSAL_WBS.NAME, PROPOSAL_WBS.SORT_ORDER,
PROPOSAL_WBS.NODE_LEVEL, PROPOSAL_WBS.WBS_NUMBER,
CODES.CODE_ID COST_CATEGORY, CODES.CODE_NAME COST_CAT_NAME
FROM PROPOSAL_WBS, CODES
CREATE TABLE CODES (
CODE_ID numeric(18,0) NOT NULL,
CODE_VALUE varchar(254) NULL,
CODE_NAME varchar(254) NULL,
CODE_TYPE numeric(18,0) NULL,
CODE_PARENT_ID numeric(18,0) NULL,
CONSTRAINT PK_CODE_ID PRIMARY KEY(CODE_ID)
So let me explain little bit more . The WBSs are categorized into two differrent types. One as INPUT and the second one as NON INPUT. Now assme the the WBS in a tree structure . So only the LEAF WBSs will have the AMOUNT and they are the INPUT WBSs and all non leaf WBSs are NON INPUT. Now lets say there are 5 LEAF WBSs. Each LEAF WBS will have differrent start period ex: WBS 1.1 starts in January 2003 and goes for 48 periods . WBS 2.1 starts in November 2003 and goes for 35 periods . WBS 3.1 starts in March 2004 and goes for 52 periods. and so on .
Now as there is no Allocation Amount entry for all other WBSs except the LEAF WBSs. So how do I get the roll up . For example if you imagine the parent of WBS 1.1 is WBS 1 , and the parent of WBS 2.1 is WBS 2 and the Parent of WBS 3.1 is WBS 3 , and the parent for WBS 1, WBS 2, WBS 3 is "ROOT WBS". As I said there is no entry for WBS 1, WBS 2 , WBS 3 and the "ROOT WBS". So how do I have a roll up of the Leaf WBS data for their parent WBSs.
Now if u think of the data in a matrix report, the WBSs and the COST CATEGORY will be the row values, the Period Numbers will the column values and the Allocation Amount will be the cross values. so lets say the WBS 1 has got two leaf nodes, WBS 1.1 and WBS 1.2 then WBS 1 will have the summed amount for each period starting the minumum period of the two of its leaf nodes and for all the cost categories of both the leaf nodes. and the "ROOT WBS" will have all the cost categories of al the Leaf nodes . for all the periods , period wise. -
Procedure not checking each sql statement.
Hi All,
I have created 2 tables names are A1 and B1. A1 table has some fields. Fields are no,sal,comm.,load_date. In A1 table NO (column) is the primary key.
Second table is B1. this table has id,phone_no and load_date. In this table constraint
ID column is the Not null.
After that I have created 2 procedures one for A1 and one for B1. with in those procedures I used SQL insert statements.
In procedures I used some valid sql statements and some invalid statements ( invalid statements means that I have specified constraint that’s why I specified duplicated and null values). While executing the procedures procedure shows error because of invalid statement and in that procedures I did not specify any Exceptions.
If I specify Exceptions in procedures executing successfully some records are not loading procedure is comeing out. How do we mention server needs to be check and every insert sql startement.
EX:
If I give 6 records from 1 to 3 valid statements. I mentioned 4 th record copy of previos record( duplicated). 5 th record and 6 th valid records.
Procedure executing successfully. Procedure loaded 1 to 4 records after that not loaded 5,6 and 7 records. How do we specify for record inserts 7. actually 7 th record is valid statement we should be insert this record. Please tell me how do we handle sql statements each and every one successfully or not.
create or replace procedure a_proc as
--declare
begin
insert into a1 values (100,2000,300,sysdate);
insert into a1 values(200,1000,400,sysdate);
insert into a1 values(300,3000,500,sysdate);
insert into a1 values(400,6000,600,sysdate);
insert into a1 values(400,900,700,sysdate);
insert into a1 values(400,10000,1200,sysdate);
insert into a1 values(900,11000,1300,sysdate);
commit;
EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR - '||sqlerrm);
end a_proc;
In B1 table colums are ID,PHONE_NO and Load_date. ID is not null column.
For B1 population I have created one procedure
create or replace procedure b_proc as
--declare
begin
insert into b1 values(1,123456,sysdate); -- 1 record
insert into b1 (phone_no,load_date) values (7896538,sysdate); --2 record
insert into b1 (phone_no) values(6763723458); ----3 record
insert into b1 (phone_no) values(453465778); --4 record
insert into b1 values(400,72894894,sysdate); --5 record
insert into b1 values(500,72894894,sysdate); --6 record
commit;
EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR - '||sqlerrm);
end b_proc;
if I execute above procedure procedure executing successfully but procedure inserting only first record not inserting 5th and 6th record. How do we exception for 5th and 6th records also.
Thanks and Regards,
Venkat{color:#808080}{color:#333300}Hi,
Please find answer to your question below:{color}
Venkat: Procedure executing successfully. Procedure loaded 1 to 4 records after that not loaded 5,6 and 7 records. How do we specify for record inserts 7. actually 7 th record is valid statement we should be insert this record. Please tell me how do we handle sql statements each and every one successfully or not.
{color}
{color:#0000ff}Guna: The procedure hits an exception after 4th record, and does not process anymore as it exits out of the procedure, I believe the data is not committed as well. You need handle exceptions if the processing has to continue. Same is the belwo case as well
{color}{color:#333300}Regards,
Guna{color} -
How to push sql statements eariler in kodojdo
Hi,
I am using Websphere Studio Application Developer ver 5.0.1 and Kodo
2.5.2.
Is there any way of pushing the sql statements eariler,
i have a table which has some columns with UNIQUE attribute, in my process
i try to catch if any errors during the insert (persist in jdo)
but, it doesn't throw any exception during persist call, it allows the
process to go to next step then finaly through the exception (during the
commit)
is there any option to push the sql statements earlier and get the
exception rather than doing at the end.
one option i can think to put into new transaction, but it won't suite for
all my cases.
Thanks
karup.You can cast the PersistenceManager to
com.solarmetric.kodo.runtime.PersistenceManagerImpl and call flush ().
See our JavaDoc for more info.
kailasam.k wrote:
Hi,
I am using Websphere Studio Application Developer ver 5.0.1 and Kodo
2.5.2.
Is there any way of pushing the sql statements eariler,
i have a table which has some columns with UNIQUE attribute, in my process
i try to catch if any errors during the insert (persist in jdo)
but, it doesn't throw any exception during persist call, it allows the
process to go to next step then finaly through the exception (during the
commit)
is there any option to push the sql statements earlier and get the
exception rather than doing at the end.
one option i can think to put into new transaction, but it won't suite for
all my cases.
Thanks
karup.
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com -
ADDM Findings Top SQL Statements
Hi,
I have run addmrpt.sql for 1 month of time using snapshots and every ADDM report says that sql statement having id **** listed under top sql statements findings and recommendation is to tune using sql tunning advisor. It has 2-4 seconds elapsed time.But when i go through AWR report instance efficiency report and all are normal.
Can anyone please confirm whether I should recommend to tune this SQL statement to my vendor ?
Thanks,
TKbelow is the sql I found in ADDM. As I understood it is an intername SQL not an application SQL. When i searched it in internet found that it is related with check_oracle_health plugin. can you please help me to understand this nagios concept and the relationship it has with oracle software. And also how should I identify which methods we are using to monitor database internally?
SELECT
a.tablespace_name "Tablespace",
b.status "Status",
b.contents "Type",
b.extent_management "Extent Mgmt",
a.bytes bytes,
a.maxbytes bytes_max,
c.bytes_free + NVL(d.bytes_expired,0) bytes_free
FROM
-- belegter und maximal verfuegbarer platz pro datafile
-- nach tablespacenamen zusammengefasst
-- => bytes
-- => maxbytes
SELECT
a.tablespace_name,
SUM(a.bytes) bytes,
SUM(DECODE(a.autoextensible, 'YES', a.maxbytes, 'NO', a.bytes))
maxbytes
FROM
dba_data_files a
GROUP BY
tablespace_name
) a,
sys.dba_tablespaces b,
-- freier platz pro tablespace
-- => bytes_free
SELECT
a.tablespace_name,
SUM(a.bytes) bytes_free
FROM
dba_free_space a
GROUP BY
tablespace_name
) c,
-- freier platz durch expired extents
-- speziell fuer undo tablespaces
-- => bytes_expired
SELECT
a.tablespace_name,
SUM(a.bytes) bytes_expired
FROM
dba_undo_extents a
WHERE
status = 'EXPIRED'
GROUP BY
tablespace_name
) d
WHERE
a.tablespace_name = c.tablespace_name
AND a.tablespace_name = b.tablespace_name@@@@@@@@
AND a.tablespace_name = d.tablespace_name
UNION ALL
SELECT
d.tablespace_name "Tablespace",
b.status "Status",
b.contents "Type",
b.extent_management "Extent Mgmt",
sum(a.bytes_free + a.bytes_used) bytes, -- allocated
SUM(DECODE(d.autoextensible, 'YES', d.maxbytes, 'NO', d.bytes))
bytes_max,
SUM(a.bytes_free + a.bytes_used - NVL(c.bytes_used, 0)) bytes_free
FROM
sys.v_$TEMP_SPACE_HEADER a,
sys.dba_tablespaces b,
sys.v_$Temp_extent_pool c,
dba_temp_files d
WHERE
c.file_id(+) = a.file_id
and c.tablespace_name(+) = a.tablespace_name
and d.file_id = a.file_id
and d.tablespace_name = a.tablespace_name
and b.tablespace_name = a.tablespace_name
GROUP BY
b.status,
b.contents,
b.extent_management,
d.tablespace_name
ORDER BY
1 -
SQL statements through web based decelopment approach
Hi,
I am using the web based development workbench. I wish to create, insert and select tables using SQL statements only and not through HDBD language. Please let me know how it is possible. as of now, i see a tutorial which makes use of the HDBD language constructs only.
Thanks,
Murali.Hi Murali,
I assume you are using a HANA Trial instance on HANA Cloud Platform. Also I assume that you already managed the web-base development workbench there.
If you are in the workbench, you can open the catalog view like this (Check for the "plus" symbol in the upper left corner):
In the catalog view, then check the "SQL" Button, again in the upper left corner:
You now have a shell to execute SQL directly.
Please consider: If you are using a HANA Trial instance, certain queries might not work because of missing permissions.
Best,
Thomas. -
Batch executing SQL Statements stored in a file in SAP DB
hi,
I am using SAP DB as database in my j2ee application. As a part of the application purpose, i need to insert a large no. of records in to the database directly. I have created the SQL file which contains the insert statements for the records
Now i need to execute this file sothat the insert statement which are inside the file get executed. I am using SQL Studio to access to the Database.
I would like to know whether any options are available in SQL Studio to for executing a SQL File.
Kindly help
Best regards,
Sudheesh...Hi,
I believe that the solution to your problem lies in creating sql studio objects.Please refer to the link below.Select the link "sql dialog" on the page.
The following options are available for sql dialog.
The following options are available in the SQL dialog:
· Creating and executing SQL statements
· Setting parameters for SQL statements
· Importing and exporting SQL statements
Select the "Importing and exporting sql statements" link on this page to know more about it.This will tell you how to import sql statements from ascii files.
Basically,what you need to do is From the context menu for the SQL dialog, choose Import File or Export File.
The link I have provided,gives a lot of other information as well.
http://help.sap.com/saphelp_nw04s/helpdata/en/ee/1c5bdfeba711d4aa2800a0c9430730/frameset.htm
Hope this helps.
Regards,
Harish
(Please award points for helpful answers)
Message was edited by: HARISH SUBRAMANIAN -
Hi All
HOw oracle SQL statements executes ? Can anyone explain me for SELECT, INSERT,UPDATE and COMMIT statements works ?
Regards
KrishnaKrishna,
Search for SQL Statement Execution and see the Flow Chart.
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/sqlplsql.htm
-Anantha -
SQL Statements in ABAP and meaning
Hello Friends,
Please, can anybody provide me a documentation on the different ABAP SQL statements and there usage/meanings.
Thanks,
Shreekanthi,
goto abapdocu->abap Database access->open Sql you will get examples.
for documnetation got se38->specify the command and press F1.
SELECT:
Put the curson on that word and press F1 . You can see the whole documentation for select statements.
SELECT result
FROM source
INTO|APPENDING target
[[FOR ALL ENTRIES IN itab] WHERE sql_cond]
Effect
SELECT is an Open-SQL-statement for reading data from one or several database tables into data objects.
The select statement reads a result set (whose structure is determined in result ) from the database tables specified in source, and assigns the data from the result set to the data objects specified in target. You can restrict the result set using the WHERE addition. The addition GROUP BY compresses several database rows into a single row of the result set. The addition HAVING restricts the compressed rows. The addition ORDER BY sorts the result set.
The data objects specified in target must match the result set result. This means that the result set is either assigned to the data objects in one step, or by row, or by packets of rows. In the second and third case, the SELECT statement opens a loop, which which must be closed using ENDSELECT. For every loop pass, the SELECT-statement assigns a row or a packet of rows to the data objects specified in target. If the last row was assigned or if the result set is empty, then SELECT branches to ENDSELECT . A database cursor is opened implicitly to process a SELECT-loop, and is closed again when the loop is ended. You can end the loop using the statements from section leave loops.
Up to the INTO resp. APPENDING addition, the entries in the SELECTstatement define which data should be read by the database in which form. This requirement is translated in the database interface for the database system´s programming interface and is then passed to the database system. The data are read in packets by the database and are transported to the application server by the database server. On the application server, the data are transferred to the ABAP program´s data objects in accordance with the data specified in the INTO and APPENDING additions.
System Fields
The SELECT statement sets the values of the system fields sy-subrc and sy-dbcnt.
sy-subrc Relevance
0 The SELECT statement sets sy-subrc to 0 for every pass by value to an ABAP data object. The ENDSELECT statement sets sy-subrc to 0 if at least one row was transferred in the SELECT loop.
4 The SELECT statement sets sy-subrc to 4 if the result set is empty, that is, if no data was found in the database.
8 The SELECT statement sets sy-subrc to 8 if the FOR UPDATE addition is used in result, without the primary key being specified fully after WHERE.
After every value that is transferred to an ABAP data object, the SELECT statement sets sy-dbcnt to the number of rows that were transferred. If the result set is empty, sy-dbcnt is set to 0.
Notes
Outside classes, you do not need to specify the target area with INTO or APPENDING if a single database table or a single view is specified statically after FROM, and a table work area dbtab was declared with the TABLES statement for the corresponding database table or view. In this case, the system supplements the SELECT-statement implicitly with the addition INTO dbtab.
Although the WHERE-condition is optional, you should always specify it for performance reasons, and the result set should not be restricted on the application server.
SELECT-loops can be nested. For performance reasons, you should check whether a join or a sub-query would be more effective.
Within a SELECT-loop you cannot execute any statements that lead to a database commit and consequently cause the corresponding database cursor to close.
SELECT - result
Syntax
... lines columns ... .
Effect The data in result defines whether the resulting set consists of multiple rows (table-like structure) or a single row ( flat structure). It specifies the columns to be read and defines their names in the resulting set. Note that column names from the database table can be changed. For single columns, aggregate expressions can be used to specify aggregates. Identical rows in the resulting set can be excluded, and individual rows can be protected from parallel changes by another program.
The data in result consists of data for the rows lines and for the columns columns.
SELECT - lines
Syntax
... { SINGLE }
| { { } } ... .
Alternatives:
1. ... SINGLE
2. ... { }
Effect
The data in lines specifies that the resulting set has either multiple lines or a single line.
Alternative 1
... SINGLE
Effect
If SINGLE is specified, the resulting set has a single line. If the remaining additions to the SELECT command select more than one line from the database, the first line that is found is entered into the resulting set. The data objects specified after INTO may not be internal tables, and the APPENDING addition may not be used.
An exclusive lock can be set for this line using the FOR UPDATE addition when a single line is being read with SINGLE. The SELECT command is used in this case only if all primary key fields in logical expressions linked by AND are checked to make sure they are the same in the WHERE condition. Otherwise, the resulting set is empty and sy-subrc is set to 8. If the lock causes a deadlock, an exception occurs. If the FOR UPDATE addition is used, the SELECT command circumvents SAP buffering.
Note
When SINGLE is being specified, the lines to be read should be clearly specified in the WHERE condition, for the sake of efficiency. When the data is read from a database table, the system does this by specifying comparison values for the primary key.
Alternative 2
Effect
If SINGLE is not specified and if columns does not contain only aggregate expressions, the resulting set has multiple lines. All database lines that are selected by the remaining additions of the SELECT command are included in the resulting list. If the ORDER BY addition is not used, the order of the lines in the resulting list is not defined and, if the same SELECT command is executed multiple times, the order may be different each time. A data object specified after INTO can be an internal table and the APPENDING addition can be used. If no internal table is specified after INTO or APPENDING, the SELECT command triggers a loop that has to be closed using ENDSELECT.
If multiple lines are read without SINGLE, the DISTINCT addition can be used to exclude duplicate lines from the resulting list. If DISTINCT is used, the SELECT command circumvents SAP buffering. DISTINCT cannot be used in the following situations:
If a column specified in columns has the type STRING, RAWSTRING, LCHAR or LRAW
If the system tries to access pool or cluster tables and single columns are specified in columns.
Note
When specifying DISTINCT, note that you have to carry out sort operations in the database system for this.
SELECT - columns
Syntax
| { {col1|aggregate( col1 )}
{col2|aggregate( col2 )} ... }
| (column_syntax) ... .
Alternatives:
1. ... *
2. ... {col1|aggregate( col1 )}
{col2|aggregate( col2 )} ...
3. ... (column_syntax)
Effect
The input in columns determines which columns are used to build the resulting set.
Alternative 1
Effect
If * is specified, the resulting set is built based on all columns in the database tables or views specified after FROM, in the order given there. The columns in the resulting set take on the name and data type from the database tables or views. Only one data object can be specified after INTO.
Note
If multiple database tables are specified after FROM, you cannot prevent multiple columns from getting the same name when you specify *.
Alternative 2
... {col1|aggregate( col1 )}
{col2|aggregate( col2 )} ...
Effect
A list of column labels col1 col2 ... is specified in order to build the resulting list from individual columns. An individual column can be specified directly or as an argument of an aggregate function aggregate. The order in which the column labels are specified is up to you and defines the order of the columns in the resulting list. Only if a column of the type LCHAR or LRAW is listed does the corresponding length field also have to be specified directly before it. An individual column can be specified multiple times.
The addition AS can be used to define an alternative column name a1 a2 ... with a maximum of fourteen digits in the resulting set for every column label col1 col2 .... The system uses the alternative column name in the additions INTO|APPENDING CORRESPONDING FIELDS and ORDER BY. .
http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm -
Find start and end execution time of a sql statement?
I am have databases with 10.2.0.3 and 9.2.0.8 on HP UNIX 11i and Windows 200x.
I am not in a position to turn on sql tracing in production environment. Yet, I want to find when a sql statement started executing and when it ended. When I look at v$sql, it has information such FIRST_LOAD_TIME, LAST_LOAD_TIME etc. No where it has information last time statement began execution and when it ended execution.. It shows no of executions, elapsed time etc, but they are cumulative. Is there a way to find individual times (time information each time a sql statement was executed. – its start time, its end time ….)? If I were to write my own program how will I do it?
Along the same line, when an AWR snapshot is shown, does it only include statements executed during that snapshot or it can have statements from the past if they have not been flushed from shared memory. If it only has statements executed in the snapshot period, how does it know when statement began execution?Hi,
For oracle 10g you can use below query to find start and end time, you can see data for last seven days.
select min(to_char(a.sample_time,'DD-MON-YY HH24:MI:SS')) "Start time", max(to_char(a.sample_time,'DD-MON-YY HH24:MI:SS')) "End Time", b.sql_text
from dba_HIST_ACTIVE_SESS_HISTORY a,DBA_HIST_SQLTEXT b where
a.sql_id=b.sql_id
order by 1;
Regards
Jafar
Maybe you are looking for
-
Hi, I am trying to sign the jar, but I am getting this exception- [exec] jarsigner: Certificate chain not found for: pvktmp:e40b0b30-dcc9-4aef-8450-15c2437a4959. pvktmp:e40b0b30-dcc9-4aef-8450-15c2437a4959 must reference a valid KeyStore key entry co
-
Dear guru, We cut a PO to vendor and later we decided to cancel the PO. However the vendor wants to charge a 15% cancellation fee(or restocking fee). I need your opinion on how to handle this situation: 1. if this is a stocked/valuated material, ca
-
Loading journal with description through FDM
Can journals be loaded with line level description (not header level description) through FDM? System is taking the file with descriptions, when you generate the upload .jle file manually and use load journals in workspace. But when you trying to loa
-
Can't load custom camera profiles
I'm using both Lightroom 3.5 and Photoshop CS5 on a 64-bit Windowx XP-Pro system with 8GB of RAM and plenty of disk space. I use an X-rite color checker to generate custom camera profiles whenever I do portraits or other color critical photo sessions
-
Can I retrieve cursor's value with variable columns?
I have a loop to check a bunch of columns in a cursor, I'd like to use a variable columns like following: cursor cur while .... loop cur.XXX end loop; here XXX are dynamical generated VARCHAR2. Could you please tell me is it possible, or not? Thanks