Help with rewrite INSERT statement
Hi,
is there any way to rewrite this statement in 9.2.0.8 ,so I can compare execution plans ?
INSERT INTO tasks
(id , data
(SELECT :b17, NVL (:b12, SYSDATE)
FROM DUAL
WHERE EXISTS (
SELECT 1
FROM queue_definitions
WHERE df_id = :b17
AND ( df_max_depth = 0
OR df_max_depth >
(SELECT COUNT (*)
FROM tasks
WHERE t_df_id = :b17 AND t_audit_stat != 0)
Regards
GregG
GregG wrote:
Hi,
is there any way to rewrite this statement in 9.2.0.8 ,so I can compare execution plans ?
INSERT INTO tasks
(id , data
(SELECT :b17, NVL (:b12, SYSDATE)
FROM DUAL
WHERE EXISTS (
SELECT 1
FROM queue_definitions
WHERE df_id = :b17
AND ( df_max_depth = 0
OR df_max_depth >
(SELECT COUNT (*)
FROM tasks
WHERE t_df_id = :b17 AND t_audit_stat != 0)
)));Regards
GregGCan you eliminate the DUAL portion of the select, putting the insert bind varibles where 'SELECT 1' is instead using ROWNUM to restrict the number of rows to 1?
Similar Messages
-
Looking for some help with building insert statements...
Hi, I am using some sql to build some insert statements for me to update a set of tables in our qa environments. The scripts that I have created were working great until someone added a column to some of the tables in the qa env which in turn makes my scripts break because I was simply building the statment to do someting like this...
insert into dest_table (select * from source_table@dblink);
But now when the coumns in the tables do not match it breaks...
This is the dynamic create script I use, can anyone help or suggest a better way to be able to build update statements update to qa tables when the columns are mismatched?
spool insert.sql
select
'insert into ' || table_name || ' (select * from ' || table_name || '@prod );' || chr(10) || ' commit;'
from user_tables
where table_name in
(select * from refresh_tablesl)
any help is greatly appreciated,
Thanks.See my reply to your duplicate post
looking for help building dynamic insert statements... -
Help with simple INSERT statement?
How can I do an insert into Oracle without having to
specify EVERY field name in the table? This isn't necessary
with Access or
SQL Server, which will insert null's in the non-specified
fields, the Oracle SQL
tool tells me that there aren't enough field values when I run
this SQL Statement:
INSERT INTO TABLE_NAME VALUES (1234, 'test', 'test')
There are over 10 different fields, but I get the error message:
Native Error Code 947, Not enough values.
TIA
Kris
nullKristofer Goss (guest) wrote:
: How can I do an insert into Oracle without having to
: specify EVERY field name in the table? This isn't necessary
: with Access or
: SQL Server, which will insert null's in the non-specified
: fields, the Oracle SQL
: tool tells me that there aren't enough field values when I run
: this SQL Statement:
: INSERT INTO TABLE_NAME VALUES (1234, 'test', 'test')
: There are over 10 different fields, but I get the error
message:
: Native Error Code 947, Not enough values.
: TIA
: Kris
You may omit the columns list, but if you do then the VALUES
clause must provide values for every column in the table.
FOR EXAMPLE: if your table were created as follows:
COLUMN_1 NOT NULL, VARCHAR2(4)
COLUMN_2 NUMBER(6)
COLUMN_3 DATE
COLUMN_4 VARCHAR2(4)
You could submit a statement like:
insert into my_table VALUES ('ALLA', , , 'XYZ');
You could also submit a statement like:
insert into my_table (column_1, column_4) VALUES ('ALLA', 'XYZ');
If you do not want to store any value in a particular column,
then that column must be allowed to accept NULLs.
Hope this helps.
null -
Need help with the session state value items.
I need help with the session state value items.
Trigger is created (on After delete, insert action) on table A.
When insert in table B at least one row, then trigger update value to 'Y'
in table A.
When delete all rows from a table B,, then trigger update value to 'N'
in table A.
In detail report changes are visible, but the trigger replacement value is not set in session value.
How can I implement this?You'll have to create a process which runs after your database update process that does a query and loads the result into your page item.
For example
SELECT YN_COLUMN
FROM My_TABLE
INTO My_Page_Item
WHERE Key_value = My_Page_Item_Holding_Key_ValueThe DML process will only return key values after updating, such as an ID primary key updated by a sequence in a trigger.
If the value is showing in a report, make sure the report refreshes on reload of the page.
Edited by: Bob37 on Dec 6, 2011 10:36 AM -
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 -
Inserting multiple rows with single insert statement ?
Hi ,,
Consider a PL/SQL procedure.
I want to pass an array of values and insert in a table with a single statement.
Moreover I want to call this procedure to insert multiple rows from OCI program.
Can some body help ? :(
Thanks
ChanduHi Vincent,
Regular array insert which you have mentioned works in case of insert statement(This is to eliminate multiple calls to server)
Will it work for passing array to Stored procedure, in this case procedure will be called only once with an array.
It will be of great help if you give an example.
Thanks
Chandra -
Help with the insert table/form tool in BIP 10.1.3.2.1
Hi, I'm trying to use the insert table/form tool in BIP, and running into some issues that I don't understand. First off, my data coming in looks like this (left column of tool):
Rowset
--- Row
------ Customer ID
------ Customer Name
------ Customer City
------ Product
------ Amount Sold
I would like the output to do the following:
a) have one page per customer. Customer should be determined by customer ID, and has attributes of customer ID, customer Name, Customer City
b) Show a table of all products and the total Amount Sold by product for that customer
c) Give a "grand total" for the customer
Can someone help with the steps needed to do this? I've tried several variations of the following without much luck:
1) Added Rowset and all children to the "Template" pane
2) Clicked on the "Row" group, and set Grouping = Customer ID, with a break of "New page per Element"
3) Clicked on the newly created (from step 2) Cust ID group, and set it to group by Product
4) Moved "amount sold" to be at same level as Product
5) Moved all of the customer attributes (name, address, etc.) to be at same level as Cust ID
6) On the Cust ID level, set the style to table
7) on row and rowset levels, set style to free form
This seems to be VERY close, except that it isn't creating a total amount for the sum of all products purchased by a customer. What do I need to do inside the tool to get a total per customer to show up?
Thanks in advance!
Scott
p.s. the final hierarchy in the template window looks like this:
Rowset (style = freeform, no grouping/sort by/breaks)
--- Row (style = freeform, group by customer ID, break new page per element)
------ Customer ID (style = table, group by product, no breaks)
--------- Product (nothing special)
--------- Amount Sold (calc for grouping = SUM)
------ Customer Name (nothing special)
------ Customer City (nothing special)
Thanks very much for the help!
ScottTo anyone else who sees this post, the answer is to do the following. Insert the Amount Sold field using the "Insert Field" tool, and set the function to sum, with the grouping checkbox turned on.
Thanks,
Scott -
Please help me with a CASE Statement:
- When ID = 15, 16, 17, 18 then "Bad"
- when ID = 19, then "Average"
- when ID = 21, then "Good"
- else "Null"
Thank you!!Well the 1st thing to do would be to correct my poor spelling... change Delault : to Default :
Don't know why you would get an error stating "The result of selection formula must be a boolean". It's working fine on my machine.
If your ID field is numbers stored text you have a couple different options...
1) Convert the ID to a number...
Select ToNumber({home.noone_ID})
2) Wrap the ID values in double quotes...
Case "15", "16", "17", "18" :
"BAD"
Even if this were your problem... the error should be something other than the boolean thing...
Jason -
Help with a return statement please!
hey, just hoping somone can help me with this return statement
i have to add a method called "specialReport" this method takes a year as it's parameter. if the parameter is not a year between 1930 and 1969 inclusive it displays an error message, "not a valid year"
if the parameter is a valid year, then it compares the parameter with the year field. if they are the same, and is the movie has been rented at least five times, the method will display the message "a good year for movies" if the years are different or the movie has NOT been rented at least five times, the method displays the message "try a different year"
btw, the Year field is : yearReleased
all help is very much appreciated!public void specialReport(int year){
//add functionality to process here
return;
} -
Help with multiple case statements
Hello,
I am new to BO. I am on XI 3.0. SQL 2005. In Designer, I am trying to create a measure in a financial universe that would end up being multiple case statements within one select. This is what I tried to do, but it doesn't work with the two case statements. Can I use an ELSE leading into the second CASE WHEN somehow? How can I accomplish this? Sorry for my ignorance!
CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 12 THEN dbo.ClientBudgetMonth.Stage1Sales END
CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 11 THEN dbo.ClientBudgetMonth.Stage1Sales END
Any Suggestions?
Thanks,
HollyHolly,
I don't know enough about your data or requirement to provide a solution, however, the construct that you post will not work because it causes you to build an object with multiple case statements when only one case statement per object is permitted. From what I see in your code I would be inclined to combine the two statements into one as such:
CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month in (11,12) THEN dbo.ClientBudgetMonth.Stage1Sales else null END
Thanks,
John -
Help with a select statement from a SQL Server within a DTS !!
Hello Gurus!
I help with the script bellow, when I run it within DTS (in SQL Sever 2000), I got the error Invalid number/or not a valid month.
Please bellow with the WHERE CLASUE '08/01/2001' AND '03/09/2002'
And in the other hand I change this forma to '01-AUG-01' AND
'03-MAR-2002', the DTS start and run witha successful messages, but it does not returns row, which is wrong.
Somebady please help!
Thanks Gurus!
GET Total ANIs with Trafic By Area Code
select
substr(b.ct_num, 0,3) as Area_Codes,
COUNT(DISTINCT B.CT_NUM) AS ANIS
from
wasabi.v_trans A,
wasabi.V_Sur_Universal B,
wasabi.V_Sub C,
wasabi.V_Trans_Typ D
where
D.Trans_typ = A.Trans_Typ AND
A.Sur_ID = B.Sur_ID AND
C.Sub_ID = A.Sub_ID AND
a.trans_stat != 'X' AND
a.Trans_DTTM >= '08/01/2001'AND
a.Trans_DTTM < '03/09/2002 AND
B.AMA3 = 'PHONE1'
AND C.SUB_ID not in (100117)
GROUP BY
substr(b.ct_num, 0,3)
ORDER BY
Area_CodesI think that you need a "to_date" function eg
change '08/01/2001' to to_date('08/01/2001','dd/mm/yyyy') -
Help with sql insert single quotes
String insert = "INSERT INTO users(firstName, lastName, emailAdd, password) VALUES("+ firstNameForm + "," + lastNameForm + "," + emailForm + "," + passwordForm + ")";
Statement stmt = conn.createStatement();
int ResultSet = stmt.executeUpdate(insert);
I have that sql insert statment in my servlet the servlet compiles fine but does not insert into the users table, i have been told that it is something to do with single quotes in sql statement, can anybody help me out?Or can i change my sql table is there a autonumber which would increase everytime this servlet runs?make your field autoincrement :-)
example
ALTER TABLE `users` CHANGE `user_id` `user_id` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL AUTO_INCREMENT To insert record in the table.
example:
you have a table test and got two fields,
id = (INT) autoincrement
name = VARCHAR / TEXT etc.
to insert data to the table test try something like this:
String SQLStatement = "INSERT INTO test";
SQLStatement += "(name)";
SQLStatement += " VALUES (?)";
statement = Conn.prepareStatement(SQLStatement);
statement.setString(1, "Duke");
statement.executeUpdate();
statement.close();
Conn.close();Note we dont provide the field for id on our sql statement since it is set as auto-increment ;-)
regards,
Message was edited by:
jie2ee -
Hello SQL Buddies,
I am trying to run a BULK insert.
Here is my code:
Code start:
use Lagerliste
drop table Import
use Lagerliste
create table Import
TOTALQTY float null,
PARTNO nvarchar (255) null,
[DESC] nvarchar (255) null,
CO nvarchar (255) null,
BIN nvarchar (255) null,
PRICE float null,
DISCOUNT nvarchar (255) null,
LASTPURC nvarchar (255) null,
AGECODE nvarchar (255) null,
MANFPART nvarchar (255) null
use Lagerliste
bulk
insert Import
from 'D:\FTP\RG\Stockfile.csv'
with
formatfile = 'D:\FormatFile\test.xml',
Errorfile = 'D:\FormatFile\error.txt'
Code stop..
My format file code is here:
Code start:
<?xml version="1.0"?>
<BCPFORMAT xmlns = "http://schemas.microsoft.com/sqlserver/2004/bulkload/format"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<FIELD ID="1" xsi:type="CharTerm" TERMINATOR= ',"' />
<FIELD ID="2" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="3" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="4" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="5" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '",' />
<FIELD ID="6" xsi:type="CharTerm" TERMINATOR= ',"' />
<FIELD ID="7" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="8" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="9" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="10" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '"' />
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="TOTALQTY" xsi:type="SQLFLT8"/>
<COLUMN SOURCE="2" NAME="PARTNO" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="3" NAME="DESC" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="4" NAME="CO" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="5" NAME="BIN" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="6" NAME="PRICE" xsi:type="SQLFLT8"/>
<COLUMN SOURCE="7" NAME="DISCOUNT" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="8" NAME="LASTPURC" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="9" NAME="AGECODE" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="10" NAME="MANFPART" xsi:type="SQLNVARCHAR"/>
</ROW>
</BCPFORMAT>
Code stop..
If i run the code it says:
Msg 4832, Level 16, State 1, Line 20
Bulk load: An unexpected end of file was encountered in the data file.
Msg 7399, Level 16, State 1, Line 20
The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.
Msg 7330, Level 16, State 2, Line 20
Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
And the error file says:
Row 473629 File Offset 42503226 ErrorFile Offset 0 - HRESULT 0x80004005
If i then in my bulk insert adds: "Lastrow = '473629' it works all fine. So it will mean that it gets an error at the last line where there is no more data? But this sql query should run every day, so i have to do so it dont gets the error.
Can someone help me?
Looking forward to an answer, i hope someone have a solution.
Regards Christian.Try the below format file,
<?xml version="1.0"?>
<BCPFORMAT xmlns = "http://schemas.microsoft.com/sqlserver/2004/bulkload/format"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<FIELD ID="1" xsi:type="CharTerm" TERMINATOR= ',"' />
<FIELD ID="2" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="3" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="4" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="5" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '",' />
<FIELD ID="6" xsi:type="CharTerm" TERMINATOR= ',"' />
<FIELD ID="7" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="8" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="9" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '","' />
<FIELD ID="10" xsi:type="CharTerm" MAX_LENGTH="255" TERMINATOR= '"\r\n' />
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="TOTALQTY" xsi:type="SQLFLT8"/>
<COLUMN SOURCE="2" NAME="PARTNO" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="3" NAME="DESC" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="4" NAME="CO" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="5" NAME="BIN" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="6" NAME="PRICE" xsi:type="SQLFLT8"/>
<COLUMN SOURCE="7" NAME="DISCOUNT" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="8" NAME="LASTPURC" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="9" NAME="AGECODE" xsi:type="SQLNVARCHAR"/>
<COLUMN SOURCE="10" NAME="MANFPART" xsi:type="SQLNVARCHAR"/>
</ROW>
</BCPFORMAT>
Refer
http://stackoverflow.com/questions/8530353/sql-bulk-insert-xml-format-file-with-double-quotes-in-terminator
http://technet.microsoft.com/en-us/library/ms191234(v=sql.105).aspx
Regards, RSingh -
Simple help with a delete statement
hello guys
i have a table like such
CREATE TABLE FWENCUM
"FWENCUM_FUND" VARCHAR2(6 BYTE),
"FWENCUM_GRNT" VARCHAR2(9 BYTE),
"FWENCUM_ORG" VARCHAR2(6 BYTE),
"FWENCUM_PROG" VARCHAR2(6 BYTE),
"FWENCUM_ACCT" VARCHAR2(6 BYTE),
"FWENCUM_ACTV" VARCHAR2(6 BYTE),
"FWENCUM_LOCN" VARCHAR2(6 BYTE),
"FWENCUM_INDCOST_BUDGET" NUMBER(17,2),
"FWENCUM_GRANT_TOTAL" NUMBER(17,2),
"FWENCUM_FUND_TOTAL" NUMBER(17,2),
"FWENCUM_BUDGET_FUND" NUMBER(17,2),
"FWENCUM_YTD_FUND" NUMBER(17,2),
"FWENCUM_INDCOST_YTD" NUMBER(17,2),
"FWENCUM_INDCOST_COMM" NUMBER(17,2),
"FWENCUM_ERROR" VARCHAR2(2 BYTE),
"FWENCUM_AMOUNT_ENCUMBER" NUMBER(17,2)
)with these values
REM INSERTING into FWENCUM
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('240051','240051','07171','01','7623',' ',' ',131635,34865.08,96873.92,-104,null,null,null,null,-104);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420461','420420','04720','02','7623',' ',' ',15600,12287.6,0,124783.52,null,null,null,null,3312.4);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420462','420420','04330','02','7623',' ',' ',15600,7372.56,0,124783.52,null,null,null,null,8227.44);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420456','420420','23040','02','7623',' ',' ',26000,5810.01,0,124783.52,null,null,null,null,20189.99);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420421','420420','04100','02','7623',' ',' ',15600,12287.6,0,124783.52,null,null,null,null,3312.4);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420422','420420','06370','02','7623',' ',' ',31200,27066.52,0,124783.52,null,null,null,null,4133.48);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420423','420420','23050','02','7623',' ',' ',15600,10171.91,0,124783.52,null,null,null,null,5428.09);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420424','420420','04340','02','7623',' ',' ',15600,0,0,124783.52,null,null,null,null,15600);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420451','420420','23050','02','7623',' ',' ',26000,24078.7,0,124783.52,null,null,null,null,1921.3);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420452','420420','22070','02','7623',' ',' ',26000,4050.97,0,124783.52,null,null,null,null,21949.03);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420453','420420','18350','02','7623',' ',' ',26000,9502.1,0,124783.52,null,null,null,null,16497.9);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420454','420420','04340','02','7623',' ',' ',26000,426.38,0,124783.52,null,null,null,null,25573.62);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420455','420420','09060','02','7623',' ',' ',26000,1561.25,0,124783.52,null,null,null,null,24438.75);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420460','420420','04310','02','7623',' ',' ',15600,12287.6,0,124783.52,null,null,null,null,3312.4);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420458','420420','05690','02','7623',' ',' ',26000,0,0,124783.52,null,null,null,null,26000);
Insert into FWENCUM (FWENCUM_FUND,FWENCUM_GRNT,FWENCUM_ORG,FWENCUM_PROG,FWENCUM_ACCT,FWENCUM_ACTV,FWENCUM_LOCN,FWENCUM_INDCOST_BUDGET,FWENCUM_INDCOST_YTD,FWENCUM_INDCOST_COMM,FWENCUM_GRANT_TOTAL,FWENCUM_FUND_TOTAL,FWENCUM_BUDGET_FUND,FWENCUM_YTD_FUND,FWENCUM_ERROR,FWENCUM_AMOUNT_ENCUMBER) values ('420457','420420','18110','02','7623',' ',' ',26000,3543.58,0,124783.52,null,null,null,null,22456.42);i basically want to delete all the rows where the sum of fwencum_amount_ecumber greater then the single value under fwencum_grant_total for that grant by grant code in other words the expected output should be to delete 15 rows.
because the sum of fwencum_Amount_encumber for grant 420420 would be greater then the 124,783.52 under the fwencum_grant_Total
i have tried doing this but i keep getting errors can i get a little advise.
here is my poor attempt
DELETE fwencum
WHERE (select sum(f.fwencum_amount_encumber) from fwencum f) > (SELECT DISTINCT
FWENCUM_GRANT_TOTAL
FROM fwencum F, FWENCUM F2
WHERE F.fwencum_grnt=F2.FWENCUM_GRNT);Edited by: mlov83 on Sep 22, 2011 7:24 PMHi,
Thanks for posting the CREATE TABLE and INSERT statemnts; that's very helpful.
It looks like only 3 columns play any role in this problem. If so, why are you posting 16 colummns?
One way to do what you want (as I understand the problem) is to do a Correlated Sub-Query , where the sub-query references something in the main statement, and therefore (potentially) does something different for each row in the main statement, like this:
DELETE fwencum m -- m is for main
WHERE fwencum_grant_total < (
SELECT SUM (fwencum_amount_encumber)
FROM fwencum
WHERE fwencum_grnt = m.fwencum_grnt
; -
Help with a COLLECT statement.
I had to make changes to some code and these changes required me to add some fields to an internal table. Below is what the table looked like before I made any changes:
DATA : BEGIN OF t_frgroup OCCURS 0,
BEGIN CHANGE 02/11/03
hazmat TYPE c,
END CHANGE 02/11/03
mfrgr LIKE lips-mfrgr,
brgew LIKE lips-brgew,
lfimg LIKE lips-lfimg,
qtypal LIKE w_nbr_palletsx,
qtypce LIKE w_nbr_palletsx,
vstel LIKE likp-vstel,
no_cnvrt TYPE c,
END OF t_frgroup.
This is what it looked like after I made the changes:
DATA : BEGIN OF t_frgroup OCCURS 0,
BEGIN CHANGE 02/11/03
hazmat TYPE c,
END CHANGE 02/11/03
mfrgr LIKE lips-mfrgr,
brgew LIKE lips-brgew,
lfimg LIKE lips-lfimg,
qtypal LIKE w_nbr_palletsx,
qtypce LIKE w_nbr_palletsx,
vstel LIKE likp-vstel,
no_cnvrt TYPE c,
matnr TYPE lips-matnr,
vbeln TYPE lips-vbeln,
posnr TYPE lips-posnr,
qty LIKE vblkp-lfimg,
vrkme LIKE lips-vrkme,
converted(1) TYPE c VALUE 'N',
END OF t_frgroup.
My issue is, after adding those fields, my collect statement no longer works:
LOOP AT t_lips.
MOVE-CORRESPONDING t_lips TO t_frgroup.
COLLECT t_frgroup.
ENDLOOP.
I need it to collect with the key being mfrgr. How can I do this? After adding the fields the collect statement now acts as an insert (I assume that matnr is now acting as the key) instead of collect.
Regards,
AaronHi Aaron,
1. Define the table keys while defining your internal table.
2. The order of the fields in the structure should be that the key fields come first , then the quantity fields and amount fields next.
3. Sort the table by the key fields before the loop.
The collect statment is creating news entries because If the system finds an entry with the key fields , the numeric fields that are not part of the table key are added to the sum total of the existing entries. If it does not find an entry, the system creates a new entry instead. Clearly the system is unable to find the existing entry because the key fields are not defined in your internal table or the fields are are out of order.
Hope this helps.
A simple example depicting this is as follows :
TYPES: BEGIN OF COMPANY,
NAME(20) TYPE C,
SALES TYPE I,
END OF COMPANY.
DATA: COMP TYPE COMPANY,
COMPTAB TYPE HASHED TABLE OF COMPANY
WITH UNIQUE KEY NAME.
COMP-NAME = 'Duck'. COMP-SALES = 10. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Tiger'. COMP-SALES = 20. COLLECT COMP INTO COMPTAB.
COMP-NAME = 'Duck'. COMP-SALES = 30. COLLECT COMP INTO COMPTAB.
regards,
Advait Gode.
Edited by: Advait Gode on Mar 28, 2008 3:50 PM
Maybe you are looking for
-
XI system idoc transfer to SAP system.
hi , this is parthasarathi,i am using ALE/IDOC.basically i need to transfer idoc from XI system to SAP system. can any one help me out in this case. my system is SAP system ie inbound system. i am using message type HRMD_A and idoc type is HRMD_A04.
-
Reading message contexts from WCF custom behavior
Hi, I'm trying to create a WCF custom behavior extension because I can't simply use out of box WCF adapters without this customization. I'm trying to write some custom code in BeforeSendRequest() method in the message inspector, and I wonder from her
-
HT4623 how can i get the numbers and keynote app to work on my imac?Help!
I downloaded the numbers and keynote apps but how do i get them to open and work on my imac or ipad?
-
Update the Purchase requesition and item fields in ME22N
Dear Friends, I need a sample BDC program to update the Purchase requesition and item fields in ME22N Tcode. if any one is having it pls send me. Thanks, Sridhar
-
Firefox hangs when opening PDF links
I have tried the suggestions, but none of them worked. If I click on a link to access a PDF file, Firefox hangs. I seem to be able to download other files OK.