Using Select Aggregate Statements
Hi Experts,
I am getting mixed response regarding the use of aggregate statements in select query. My concerns are:
1) Using aggregate function in select query or processing in internal table is more efficient ?
2) If it is database dependent (as some may argue ), for which databases we have to use aggregate function and for which we should avoid to use it ?
3) Is there any relevant study regarding this topic, I mean some statistics with the no of records, and the underlying database used.
Sam.
Hi Sam,
I agree with Aarif, but you can make use of aggregate functions while writing select query rather than using loops on internal tables to find Max. Value for example as this is more efficient.
Please refer to the link below for more information on Aggregate statements.
ABAP Keyword Documentation
Regards,
Ashvin
Similar Messages
-
Using SELECT INTO statement to transfer data from one DB to another?
Hello,
I need to move data from an SAP table to another downstream SQL server box without flat file in between. I have set up the DBCON interface, so that my ABAP code on SAP can connect to the remote SQL Server, then I can run INSERT command as Native SQL inside the ABAP.
However, INSERT has performance problem. The best performer as I can find is SELECT INTO statement. But then I am stuck at how to use SELECT INTO to query my local SAP table and send (via INTO) to remote database. I am not even sure whether I should use Open SQL or Native SQL.
Any suggestion? BTW, I understand the limitation of Native SQL, but we are OK to use it.
Thanks!It appears that this is some kind of migration project due to the scope of the data contained in the single file? If so whatever you do is like ly to be trow away once the migration of data is completed.
You have a couple of options:
1) Get the data extracted from HFM in multiple files instead of one bulk file, broken down by scanario,year & period
2) Take the single data dump file produced by FDM and manipulate it yourself to get the data in a more usuable format for processing through FDM.
Option 2 could be achieved via any ETL tool or a custom file parsing script. What may be more attractive to you and allow you to fully leverage your investment in FDM is that you could use the PULL adapter that ships as part of the FDM adapter suite to perform this transformation exercise. The PULL adapter takes a flat file input and allows you to use all the in built functionality of FDM to transform it and output a modified flat file (or series of flat files). You could use it to produce multioload files or a series of files broken down by scenario,year,period.
Whatever you do I would suggest that break the single data file down into smaller chunks as this will help with the iterative debugging process you will inevitably have to undetake whislt migrating the data to the new application. -
Obtain Param Array using SELECT SQL statement
Hi,
I was trying to use array processing to fetch an array of data from a database. Here is the problem I am facing (I am new to this, so I am sorry if I am doing something silly):
I am using the following statements in C++:
OParamArray idParam;
OParamArray colorParam;
OParameterCollection paramCol = odb.GetParameters();
idParam= paramCol.AddTable("idParam",OPARAMETER_OUTVAR,OTYPE_NUMBER,100,10);
colorParam= paramCol.AddTable("colorParam",OPARAMETER_OUTVAR,OTYPE_VARCHAR2,100,10);
oresult res1 = odb.ExecuteSQL("select :idParam=MYID, :colorParam=COLOR from MYTABLE"); // MYID and COLOR are the column names
But after the "ExecuteSQL" call when I check for the values in idParam and miColorParam, I find no values....
What am I doing wrong? How do I use the SELECT statement with Array Parameters?
Thanks in advance.
Gopinathprepare:
copy:
build:
[javac] Compiling 1 source file to C:\jwsdp-1.3\garland\build\WEB-INF\classe
s
[javac] C:\jwsdp-1.3\garland\src\LogonBean.java:20: cannot resolve symbol
[javac] symbol : variable data
[javac] location: class logonApp.LogonBean
[javac] String SQLState2 = "SELECT PASSWORD FROM MASTER WHERE PASSWORD L
IKE '"+data+"' ";
[javac]
^
[javac] C:\jwsdp-1.3\garland\src\LogonBean.java:79: cannot resolve symbol
[javac] symbol : variable SQLState1
[javac] location: class logonApp.LogonBean
[javac] rs = stmt.executeQuery(SQLState1);
[javac] ^
[javac] 2 errors
Thats the compiler error, but it still works on a normal java file. ill try a prepared statement in the mean time.
ChrisG -
SMALL PROBLEM IN USING SELECTION-OPTIONS STATEMENT
Hello ABAP Gurus,
I am trying to write a simple program that takes 'FROM' and 'TO' dates which will be used to generate a report..
However the requirement is that the 'FROM' date should have a default value that is read from a file and the 'TO' date should have a default value of today's date. The Client wants to option of changing these dates if needed.
However, when I wrote the following program, it first doesn't read the text file for the 'FROM' date and therefore it is by default filling only 'TO' date and leaving the 'FROM' field blank. Can some one please let me konw what I am not doing correctly.
The simple code that i have written is
=======================================================================================
REPORT Z_PROGRAM1.
DATA: DAYSTMP(40),
FROMDATE LIKE SY-DATUM.
DAYSTMP = 'C:\EXTRACTEDDATA\ExtractedDate.txt'.
OPEN DATASET DAYSTMP FOR INPUT IN TEXT MODE ENCODING DEFAULT.
READ DATASET DAYSTMP INTO FROMDATE.
CLOSE DATASET DAYSTMP.
SELECTION-SCREEN: BEGIN OF BLOCK MAIN WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_DATE FOR SY-DATUM DEFAULT FROMDATE TO SY-DATUM
OPTION BT SIGN I.
SELECTION-SCREEN: END OF BLOCK MAIN.
========================================================================================
Any suggestions/feedback will be greatly appreciated.
Thanks
Ram
Edited by: Prasad Ram on Oct 28, 2009 5:34 PM... and please use the above <<>> code button after selecting the code with the mouse. Then formatting is preserved and readabilty is enabled.
Many people (including me) refuse to read unformatted coding.
Regards,
Clemens -
IS ITCOMPULSARY TO USE SELECT ENDSELETC IN LDB
Hello All,
Am freshaer in ABAP . In a code we use a LDB named PNM . in that LDB there is a table named PLPOD from this table we get the workcentre number then from it we will be going to database table crhd and crtx to get the description of that particular work centre . While selecting the data it is asking for endselect statement though i use the target as a interanl table .Hi,
if u want multiple entries of description ,U can use
Select with into table it statement. then it do not ask u for endselect.
for eg.
SELECT
matnr mtart mbrsh matkl
FROM mara
INTO CORRESPONDING FIELDS OF TABLE it
WHERE matnr IN p_matnr.
if u want single entries of description , u can use
select single statement.
For eg.
select single KWERT
from KONV
into IT-ZADM
where KNUMV = IT-KNUMV
and KPOSN = IT-POSNR
and KSCHL = 'ZADM'.
Regards,
Digesh Panchal -
How to get the sum in BSEG table using select statement
hai all
i made the internal tale "itab1" .. i want to get the som feild of DMBTR in BSG table my code is here but its not working gave som error massage (Aggregate functions and the addition DISTINCT are not supported in field lists for pooled and cluster tables.) plz tel me how should i do it..... i want to get the som of that feild....
loop at itab1
SELECT sum( DMBTR ) from bseg INTO itab1-DMBTR141_45
where GJAHR = itab1-GJAHR
and BELNR = itab1-BELNR.
endloop.
regard
nawaSELECT BELNR GJAHR SHKZG DMBTR
from bseg
INTO table it_bseg
for all entries in itab1
where GJAHR = itab1-GJAHR
and BELNR = itab1-BELNR.
loop at it_bseg.
IF it_bseg-shkzg = 'H'.
it_bseg-dmbtr = it_bseg-dmbtr * ( -1 ).
ELSE.
it_bseg-dmbtr = it_bseg-dmbtr.
ENDIF.
MODIFY it_bseg.
endloop.
loop at it_bseg.
READ TABLE itab1 with key belnr = it_bseg-belnr
gjahr = it_bseg-gjahr.
if sy-subrc = 0.
collect it_bseg into it_bseg_amount.
endif.
endloop.
U can use the collect statement
Regards
Gopi -
How to get all values from an interval using select statement
Hi,
Is it possible to write a select statement that returns all values from an interval? Interval boundaries are variable.
something like this:
select (for x in 1,1024 loop x end loop) from dual
(this, of course, doesn't work)
The result in this example should be 1024 rows of numbers from 1 to 1024. These numbers are parameters, so it is not possible to create a table with predefined values.
Thanks in advance for your help,
Mia.For your simple case, with a lower boundary of 1, you can use:
SELECT rownum
FROM all_objects
WHERE rownum <= 1024For a set of number between say 50 - 100, you can use something like:
SELECT rownum + (50 - 1)
FROM all_objects
WHERE rownum <= (100 - 50 + 1)Note, that all_objects was used only because it generally has a lot of rows. Any table with at least the number of rows in your range will work.
TTFN
John -
How can I use an IF statement in the SELECT
Hi People,
I have a procedure called ENQUEUE_PROC which takes 3 parameters.
and I am trying to use an if statement in the select. I appreciate the help with this task.
here is my code.
Please have a look at my Select statement. What I have does not compile, however it might give you an idea of what i need.
PROCEDURE ENQUEUE_PROC(P_SUBMISSION_ID NUMBER,
P_EVENT VARCHAR2,
CASE_TYPE_CODE NUMBER;
) AS
XMLDATA XMLTYPE;
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message SYS.AQ$_JMS_TEXT_MESSAGE;
BEGIN
SELECT
XMLELEMENT("caseFileEvent", XMLATTRIBUTES('http://www.ussc.gov/soa/casefile/event/types' AS "xmlns",
'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns:ns0"),
XMLELEMENT("caseFileUploadEvent", XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
'http://www.ussc.gov/soa/casefile/event/types ../xsd/Case_META.xsd' AS "xsi:schemaLocation",
'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns"),
XMLELEMENT("taskEvent", P_EVENT), --eg - 'SUBMIT', 'REJECT', 'RESUBMIT'
XMLELEMENT("defendentDetails",
XMLELEMENT("sentensingDate", SMD.SENT_VIO_DATE),
XMLELEMENT("personDetails",
// Here is where I want my IF statement, *********************************
IF CASE_TYPE_CODE = 10 THEN
XMLELEMENT("personNameDetails",
XMLELEMENT("firstName", SMD.FIRST_NAME),
XMLELEMENT("middleName", SMD.MIDDLE_NAME),
XMLELEMENT("lastName", SMD.LAST_NAME)
), -- personNameDetails
ELSE
XMLELEMENT("personNameDetails",
XMLELEMENT("corpname", SMD.CORPNAME),
), -- personNameDetails
XMLELEMENT("dateOfBirth", SMD.BIRTH_DATE)
) -- personDetails
), -- defendentDetails
XMLELEMENT("documentStatusDetails",
XMLELEMENT("otherStatus",
XMLELEMENT("intCode", NULL),
XMLELEMENT("description", NULL)
) -- otherStatus
), -- documentStatusDetails
XMLELEMENT("uploadOtherDetails",
XMLELEMENT("submissionId", SUB.SUBMISSION_ID),
XMLELEMENT("submissionSessionId", SUB.SUB_SESSION_ID),
XMLELEMENT("submissionMethod",
XMLELEMENT("intCode", SUB.SUB_MTHD_CODE),
XMLELEMENT("description", SM.DESCRIP)
), -- submissionMethod
XMLELEMENT("submissionReason",
XMLELEMENT("intCode", SUB.SUB_TYPE_CODE),
XMLELEMENT("description", SR.DESCRIP)
), -- submissionReason
XMLELEMENT("district",
XMLELEMENT("intCode", SMD.DIST_ID),
XMLELEMENT("description", D.DISTRICT_NAME)
), -- district
XMLELEMENT("caseFileType",
XMLELEMENT("intCode", SUB.CASE_TYPE_CODE),
XMLELEMENT("description", C.DESCRIP)
), -- caseFileType
XMLELEMENT("primaryDocketInfo",
XMLELEMENT("yearYY", SUBSTR(SMD.DOCKET, 1, 2)),
XMLELEMENT("id", SUBSTR(SMD.DOCKET, 3, 7)),
XMLELEMENT("defendentNumber", SMD.DEF_NUM)
), -- primaryDocketInfo
XMLELEMENT("PACTSId", SMD.PACTS_ID), -- PACTSId
XMLELEMENT("AOJudgeId",
XMLELEMENT("intCode", SMD.AO_JUDGE_ID),
XMLELEMENT("description", J.LAST_NAME || ', ' || J.FIRST_NAME || ', ' || J.MIDDLE_NAME)
), -- AOJudgeId
XMLELEMENT("missingCasefile", SUB.MISSING_CASE), -- missingCasefile
XMLELEMENT("creator",
XMLELEMENT("firstName", NULL),
XMLELEMENT("lastName", NULL),
XMLELEMENT("email", SUB.CREATOR_ID),
XMLELEMENT("actionDate", REGEXP_REPLACE( TO_CHAR(SUB.CREATE_TIME, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZR'), '...(......)$', '\1'))
), -- creator
XMLELEMENT("lastModifier",
XMLELEMENT("firstName", NULL),
XMLELEMENT("lastName", NULL),
XMLELEMENT("email", H.USER_ID),
XMLELEMENT("actionDate", TO_CHAR(H.ACTION_DATE, 'YYYY-MM-DD"T"HH24:MI:SS".000-05:00"'))
) -- lastModifier
) -- uploadOtherDetails
) -- caseFileUploadEvent
) -- caseFileEvent
INTO XMLDATA
FROM USSC_CASES.SUBMISSION SUB,
USSC_CASES.SUBMISSION_METADATA SMD,
USSC_CASES.CASE_HISTORY H,
LOOKUP.CASE_SUB_MTHD SM,
LOOKUP.CASE_SUB_TYPE SR,
LOOKUP.DISTRICTS D,
LOOKUP.JUDGES J,
LOOKUP.CASE_TYPES C
WHERE SUB.SUBMISSION_ID = SMD.SUBMISSION_ID
AND SUB.SUBMISSION_ID = H.SUBMISSION_ID
AND SUB.SUB_MTHD_CODE = SM.SUBMTHD_CODE
AND SUB.SUB_TYPE_CODE = SR.SUBTYPE_CODE
AND SUB.CASE_TYPE_CODE = C.CASE_TYPE_CODE
AND SMD.DIST_ID = D.USSC_DISTRICT_ID
AND SMD.AO_JUDGE_ID = J.AO_JUDGE_ID
AND H.ACTION_DATE IN (SELECT MAX(A.ACTION_DATE)
FROM USSC_CASES.CASE_HISTORY A
WHERE A.SUBMISSION_ID = P_SUBMISSION_ID)
AND SUB.SUBMISSION_ID = P_SUBMISSION_ID;
--dbms_output.put_line('queue start '|| xmldata.getclobval());
--insert into test1 values(xmldata);
message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
message.set_text(xmldata.getStringVal());
DBMS_AQ.ENQUEUE(queue_name => 'case_file_queue', -- aqadm.cases_queue
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
COMMIT;
END ENQUEUE_PROC;thanks for the help,
I believe I almost got it to compilw, however I am getting Error(29,19): PL/SQL: ORA-00918: column ambiguously defined.
Of course CASE_TYPE_CODE is ambiguously because its passed in, is there a way around this.
Here is what i have so far.
PROCEDURE ENQUEUE_PROC(P_SUBMISSION_ID NUMBER,
P_EVENT VARCHAR2,
CASE_TYPE_CODE NUMBER // passed in field
) AS
XMLDATA XMLTYPE;
enqueue_options dbms_aq.enqueue_options_t;
message_properties dbms_aq.message_properties_t;
message_handle RAW(16);
message SYS.AQ$_JMS_TEXT_MESSAGE;
BEGIN
SELECT
XMLELEMENT("caseFileEvent", XMLATTRIBUTES('http://www.ussc.gov/soa/casefile/event/types' AS "xmlns",
'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns:ns0"),
XMLELEMENT("caseFileUploadEvent", XMLATTRIBUTES('http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi",
'http://www.ussc.gov/soa/casefile/event/types ../xsd/Case_META.xsd' AS "xsi:schemaLocation",
'http://www.ussc.gov/soa/casefile/event/types' AS "xmlns"),
XMLELEMENT("taskEvent", P_EVENT), --eg - 'SUBMIT', 'REJECT', 'RESUBMIT'
XMLELEMENT("defendentDetails",
XMLELEMENT("sentensingDate", SMD.SENT_VIO_DATE),
CASE
WHEN CASE_TYPE_CODE = 10 THEN
XMLELEMENT("personDetails",
XMLELEMENT("personNameDetails",
XMLELEMENT("firstName", SMD.FIRST_NAME),
XMLELEMENT("middleName", SMD.MIDDLE_NAME),
XMLELEMENT("lastName", SMD.LAST_NAME)
), -- personNameDetails
XMLELEMENT("dateOfBirth", SMD.BIRTH_DATE)
) -- personDetails
ELSE
XMLELEMENT("corporationDetails",
XMLELEMENT("organizationName", SMD.CORP_NAME)
) -- corporationDetails
END
), -- defendentDetails
XMLELEMENT("documentStatusDetails",
XMLELEMENT("otherStatus",
XMLELEMENT("intCode", NULL),
XMLELEMENT("description", NULL)
) -- otherStatus
), -- documentStatusDetails
XMLELEMENT("uploadOtherDetails",
XMLELEMENT("submissionId", SUB.SUBMISSION_ID),
XMLELEMENT("submissionSessionId", SUB.SUB_SESSION_ID),
XMLELEMENT("submissionMethod",
XMLELEMENT("intCode", SUB.SUB_MTHD_CODE),
XMLELEMENT("description", SM.DESCRIP)
), -- submissionMethod
XMLELEMENT("submissionReason",
XMLELEMENT("intCode", SUB.SUB_TYPE_CODE),
XMLELEMENT("description", SR.DESCRIP)
), -- submissionReason
XMLELEMENT("district",
XMLELEMENT("intCode", SMD.DIST_ID),
XMLELEMENT("description", D.DISTRICT_NAME)
), -- district
XMLELEMENT("caseFileType",
XMLELEMENT("intCode", SUB.CASE_TYPE_CODE),
XMLELEMENT("description", C.DESCRIP)
), -- caseFileType
XMLELEMENT("primaryDocketInfo",
XMLELEMENT("yearYY", SUBSTR(SMD.DOCKET, 1, 2)),
XMLELEMENT("id", SUBSTR(SMD.DOCKET, 3, 7)),
XMLELEMENT("defendentNumber", SMD.DEF_NUM)
), -- primaryDocketInfo
XMLELEMENT("PACTSId", SMD.PACTS_ID), -- PACTSId
XMLELEMENT("AOJudgeId",
XMLELEMENT("intCode", SMD.AO_JUDGE_ID),
XMLELEMENT("description", J.LAST_NAME || ', ' || J.FIRST_NAME || ', ' || J.MIDDLE_NAME)
), -- AOJudgeId
XMLELEMENT("missingCasefile", SUB.MISSING_CASE), -- missingCasefile
XMLELEMENT("creator",
XMLELEMENT("firstName", NULL),
XMLELEMENT("lastName", NULL),
XMLELEMENT("email", SUB.CREATOR_ID),
XMLELEMENT("actionDate", REGEXP_REPLACE( TO_CHAR(SUB.CREATE_TIME, 'YYYY-MM-DD"T"HH24:MI:SS.FFTZR'), '...(......)$', '\1'))
), -- creator
XMLELEMENT("lastModifier",
XMLELEMENT("firstName", NULL),
XMLELEMENT("lastName", NULL),
XMLELEMENT("email", H.USER_ID),
XMLELEMENT("actionDate", TO_CHAR(H.ACTION_DATE, 'YYYY-MM-DD"T"HH24:MI:SS".000-05:00"'))
) -- lastModifier
) -- uploadOtherDetails
) -- caseFileUploadEvent
) -- caseFileEvent
INTO XMLDATA
FROM USSC_CASES.SUBMISSION SUB,
USSC_CASES.SUBMISSION_METADATA SMD,
USSC_CASES.CASE_HISTORY H,
LOOKUP.CASE_SUB_MTHD SM,
LOOKUP.CASE_SUB_TYPE SR,
LOOKUP.DISTRICTS D,
LOOKUP.JUDGES J,
LOOKUP.CASE_TYPES C
WHERE SUB.SUBMISSION_ID = SMD.SUBMISSION_ID
AND SUB.SUBMISSION_ID = H.SUBMISSION_ID
AND SUB.SUB_MTHD_CODE = SM.SUBMTHD_CODE
AND SUB.SUB_TYPE_CODE = SR.SUBTYPE_CODE
AND SUB.CASE_TYPE_CODE = C.CASE_TYPE_CODE
AND SMD.DIST_ID = D.USSC_DISTRICT_ID
AND SMD.AO_JUDGE_ID = J.AO_JUDGE_ID
AND H.ACTION_DATE IN (SELECT MAX(A.ACTION_DATE)
FROM USSC_CASES.CASE_HISTORY A
WHERE A.SUBMISSION_ID = P_SUBMISSION_ID)
AND SUB.SUBMISSION_ID = P_SUBMISSION_ID;
--dbms_output.put_line('queue start '|| xmldata.getclobval());
--insert into test1 values(xmldata);
message := SYS.AQ$_JMS_TEXT_MESSAGE.construct;
message.set_text(xmldata.getStringVal());
DBMS_AQ.ENQUEUE(queue_name => 'case_file_queue', -- aqadm.cases_queue
enqueue_options => enqueue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
COMMIT;
END ENQUEUE_PROC;Edited by: Rooney on Jan 31, 2012 1:55 PM -
What happen if i use controll break statement in between select & endselect
Hi all,
what happen if i use controll break statement in between select & endselect ?
Thanks in Advance
KRHi for reference u can go through this code example
data:
fs_tab like sflight.
data:
t_tab like standard table of fs_tab.
select * from sflight into table t_tab.
loop at t_tab into fs_tab.
write: / fs_tab-carrid.
endloop.
refresh t_tab.
clear fs_tab.
select * from sflight into fs_tab.
at new fs_tab-carrid.
append fs_tab to t_tab.
endat.
endselect. -
Using Select statement in IF condition?
hi all,
Can i use select statement in IF COndition in pl sql ?
eg like- if( select 1 from ASD) then
end if;There is no way to do any kind of select statement inside if conditions.
Why don't test simple cases like this first?
An example to show it.
SQL> begin
2 if exists (select 1 from dual) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if exists (select 1 from dual) then
ERRORE alla riga 2:
ORA-06550: line 2, column 5:
PLS-00204: function or pseudo-column 'EXISTS' may be used inside a SQL
statement only
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
SQL> begin
2 if ( (select count(*) from dual) > 0 ) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if ( (select count(*) from dual) > 0 ) then
ERRORE alla riga 2:
ORA-06550: line 2, column 8:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + case mod new not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternativ
ORA-06550: line 2, column 33:
PLS-00103: Encountered the symbol ")" when expecting one of the following:
. , @ ; for <an identifier>
<a double-quoted delimited-identifier> group having intersect
minus order partition start subpartition union where connect
SQL> begin
2 if ( 0 in (select count(*) from dual) ) then
3 dbms_output.put_line('ok');
4 end if;
5 end;
6 /
if ( 0 in (select count(*) from dual) ) then
ERRORE alla riga 2:
ORA-06550: line 2, column 12:
PLS-00405: subquery not allowed in this context
ORA-06550: line 2, column 2:
PL/SQL: Statement ignoredBye Alessandro -
How to use SELECT statement to extract KNA1-NAME1 and KNB1-ZSABE
In building table I_KNA1 in form f_extract_data, an additional select statement is needed to select and append datafrom (KNA1 and KNB1) to existing I_KNA1
In form f_extract_data table i_kna1 is populated with data from zd_kna101.(where ZD_KNA101 is a view of KNA1, KNB1 and KNBK. It's a joint of these three tables.) This will take care of all customers with KNBK-BANKL and KNBK-BANLN populated. But this does not include new customers created in SAP CRM (no KNBK records). Therefore a separate SELECT statement is needed to extract KNA1-NAME1 and KNB1-ZSABE for customers created in SAP CRM(the customers who do do not have BANKL and BANKN). These selected records are then need to be appended to I_KNA1. It's possible that new selection statement might extract records that are already in existing I_KNA1 table. IF this is the case, right after the append, sort I_KNA1 and remove duplicate records.
form f_extract_data.
select kunnr " Customer Number
name1 " Name
zsabe " Business Unit
bankl " Legacy Bank Key
bankn " Legacy Bank Account
from zd_kna101 " View of KNA1, KNB1, and KNBK
into table i_kna1
for all entries in i_doc_by_ref
where kunnr = i_doc_by_ref-kunnr
and zsabe in s_zsabe.
if sy-subrc <> 0.
message a116 with 'customer'. " Customer Table is empty. HALT!!!
else.
sort i_kna1 by kunnr.
endif.
will I have to use the join statement(for KNA1-NAME1 and KNB1-ZSABE using the key as KUNNR) here or give two seperate select statements for extracting data from KNA1 and KNB1 using the key as KUNNR.
THANKS FOR THE HELP.I would suggest using the join on KUNNR. Maybe something like this.
data: begin of itab occurs 0,
kunnr type kna1-kunnr,
name1 type kna1-name1,
ZSABE type knb1-ZSABE,
end of itab.
select kna1~kunnr kna1~name1 knb1~zsabe
into table itab
from kna1
inner join knb1
on kna1~kunnr = knb1~kunnr
where ........
Regards,
Rich Heilman -
I don't know the correct terminology, so I don't think that I've posed my question very well. Employees will be using the form that I'm trying to make, and I want for them to be able to select a city from a large number of cities, and for that city to ultimately show up on the form (not merely in the data that is output.)
I thought that the clearest way for them to select a city would be for them to start by selecting the pertinent state first. That would allow the list of cities in that state to be shorter and more manageable. So I'd like for them to be able to select a state, and then by virtue of that selection, have a list of cities pop up. I sort of achieved that by using buttons for the states, and then under "actions", I chose "open a file". Then I set it up to open a file that contained the cities that are options,and set each city with a button.
The result is that it goes from my form to a second window, containing states and then to a third window, containing cities. (Actually, there are multiple "city" windows because there's a list of cities for each state.) But then I'd like for the city that they select to wind up being on my original form. Is there an "action" that I can choose that will make that happen?
Or is there a better way to accomplish what I'm trying to accomplish? Maybe I'm just going about this all wrong(?) Any suggestions would be very much appreciated Thank you!Yes, there is a much better way. I'd recommend using a combo box for the list of states. When the user selects a state, the list of associated cities would populate a second combo box, allowing the user to select a city. This type of functionality relies on JavaScript. If you are unfamiliar with with JavaScript in Acrobat, I'd suggest starting with the following article: http://acrobatusers.com/tutorials/2007/js_list_combo_livecycle/
Ignore anything to do with LiveCycle Designer. If you get stuck, post again. -
Number of rows inserted is different in bulk insert using select statement
I am facing a problem in bulk insert using SELECT statement.
My sql statement is like below.
strQuery :='INSERT INTO TAB3
(SELECT t1.c1,t2.c2
FROM TAB1 t1, TAB2 t2
WHERE t1.c1 = t2.c1
AND t1.c3 between 10 and 15 AND)' ....... some other conditions.
EXECUTE IMMEDIATE strQuery ;
These SQL statements are inside a procedure. And this procedure is called from C#.
The number of rows returned by the "SELECT" query is 70.
On the very first time call of this procedure, the number rows inserted using strQuery is *70*.
But in the next time call (in the same transaction) of the procedure, the number rows inserted is only *50*.
And further if we are repeating calling this procedure, it will insert sometimes 70 or 50 etc. It is showing some inconsistency.
On my initial analysis it is found that, the default optimizer is "ALL_ROWS". When i changed the optimizer mode to "rule", this issue is not coming.
Anybody faced these kind of issues?
Can anyone tell what would be the reason of this issue..? any other work around for this...?
I am using Oracle 10g R2 version.
Edited by: user13339527 on Jun 29, 2010 3:55 AM
Edited by: user13339527 on Jun 29, 2010 3:56 AMYou have very likely concurrent transactions on the database:
>
By default, Oracle Database permits concurrently running transactions to modify, add, or delete rows in the same table, and in the same data block. Changes made by one transaction are not seen by another concurrent transaction until the transaction that made the changes commits.
>
If you want to make sure that the same query always retrieves the same rows in a given transaction you need to use transaction isolation level serializable instead of read committed which is the default in Oracle.
Please read http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_sqlproc.htm#ADFNS00204.
You can try to run your test with:
set transaction isolation level serializable;If the problem is not solved, you need to search possible Oracle bugs on My Oracle Support with keywords
like:
wrong results 10.2Edited by: P. Forstmann on 29 juin 2010 13:46 -
How to pass parameter in Function by using select statement?
Hi,
I got a problem. I cant pass in parameter to function by using select statement. But it can pass in parameter by using 'hardcode' method. How can I solve this problem?
Eg,
select * from table (SplitFunction('HS750020,HS750021')) <<< this work.
but
select * from table (SplitFunction(select LOT_NO from TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) <<< do not work.
Thanks for who try to help. Thanks.skymonster84 wrote:
I have try this before. But it not work.here is an example
create or replace type stringlist as table of varchar2(100)
create or replace function splitstring(pstring in varchar2) return stringlist
as
lstringlist stringlist;
begin
select regexp_substr(pstring,'[^,]+',1, level) bulk collect into lstringlist
from dual
connect by level <= length(pstring)-length(replace(pstring,','))+1;
return lstringlist;
end;
select * from table(select splitstring('xx,yy,zz') from dual)
create table t(str varchar2(100))
insert into t values('x,y,z')
insert into t values('a,b,c')
select * from table(select splitstring(str) from t where rownum<2)
/If you supply multiple values then it will fail.
select * from table(select splitstring(str) from t)
/ -
Hi,
I am trying to insert values using select statement. But this is not working
INSERT INTO contribution_temp_upgrade
(PRO_ID,
OBJECT_NAME,
DELIVERY_DATE,
MODULE_NAME,
INDUSTRY_CATERGORIZATION,
ADVANTAGES,
REUSE_DETAILS)
VALUES
SELECT
:P1_PROJECTS,
wwv_flow.g_f08(vRow),
wwv_flow.g_f09(vRow),
wwv_flow.g_f10(vRow),
wwv_flow.g_f11(vRow),
wwv_flow.g_f12(vRow),
wwv_flow.g_f13(vRow)
FROM DUAL;
Please let me know what i am missing..
Thanks
SudhirTry this
INSERT INTO contribution_temp_upgrade
(PRO_ID,
OBJECT_NAME,
DELIVERY_DATE,
MODULE_NAME,
INDUSTRY_CATERGORIZATION,
ADVANTAGES,
REUSE_DETAILS)
SELECT
:P1_PROJECTS,
wwv_flow.g_f08(vRow),
wwv_flow.g_f09(vRow),
wwv_flow.g_f10(vRow),
wwv_flow.g_f11(vRow),
wwv_flow.g_f12(vRow),
wwv_flow.g_f13(vRow)
FROM DUAL;Note: when you are selecting a value using select statement, you should not specify the keyword "values".
i assume you have already assigned value for your bind variable :P1_PROJECTS and rest of the functions will return some value.
Regards,
Prazy
Maybe you are looking for
-
Bridge and PS not communicating with scripts and automation.
CS4 PS and Bridge is not communicating correctly. When opening an image from Bridge it opens whiteout any issues but when choosing Tools and PS and any form of automation or script it will not open and start the requested action. Then when choosing s
-
Safari 6 bug (Can't download software files) - file not in download window
Dear Everybody, I insatlled Safari 6 and also afterwards ML, everything works fine on my macbook air but on my 2009 (early) iMac safari 6 has a severe problem. When I download software files such as a adove flash player dmg file, The file (link) load
-
Single TO for same GR number in LT10
Hi, I have a requirement to create a single TO for the same GR number or create single to for multiple storage unit. i have tried using LT10, but it creates multiple TO for me. is there any way/config that can do this? Thanks fung
-
Question...basically, about best practice. I have made a VI that I use very often in many different applications. (a special path stripping thing for help with executable stuff) Right now, I have used it in so many places always making a copy
-
I am learning how to do photo editing and I am not gonna buy photoshop so please do not tell me to buy it but so should I use Gimp or Gimpshop? I have to learn an interface anyway so I figured I should use Gimpshop so that if I needed to I would be a