Get PERAS Returning Mulitple Records For PERNR
I have a program that is preloading PNPPERNR with PERNRS from a database before the GET PERAS statement. We just did an upgrade of some of our HR SAP Components and now the GET PERAS statement is triggering every time if sees a given PERNR in the PNPPERNR whereas before it only did it once even though the number of PERNRS in the PNPPERNR table is exactly the same.
We upgraded all of our SAP-HR* components from Release 604 SP-Level 67 to SP-Level 75 and the EA-HR* from Release 605 SP-Level 0044 to SP-Level 0052. We've tested the program in a client that hasn't been updated and then ran in an updated one and that is how we found the problem. Obviously SAP has updated something. Has anybody experienced this problem?
Hello,
The max rows operation is applied independently from the firstResults opperation, and is applied first. So in setting max rows to 2, you are getting rows 1 and 2, and then by applying firstResults=2, you are skipping past the second row, hence getting 0 back. This is because Max rows is applied to the statement before execution, where as firstResult is applied to the returned resultset. You will need to use firstresults=2 and maxrows=4 to get rows 3+4.
Also, you can change the query parameters on a named query. It is not recommended though only because named queries are stored on the session, and so in a multi-threaded app can cause problems when two threads try to execute the same query with, for example, different max results set. In a multithreaded environment you might want to get the named query and clone it before changing first/max rows, but for single threaded app there shouldn't be any problems.
Best Regards,
Chris
Similar Messages
-
Query is returning multiple records for a bank account id and party id
Hi All,
I am not getting why this query is returning multiple records for a particular bank account id and party id:
SELECT instrument_payment_use_id
,instrument_type
,instrument_id
,start_date
,ext_pmt_party_id
FROM iby_pmt_instr_uses_all
WHERE instrument_id =:lv_num_ext_bank_account_id
and exists (select 1 from iby_external_payees_all b where PAYEE_PARTY_ID= :lv_num_party_id and b.ext_payee_id = ext_pmt_party_id)
I want above values to be used in api iby_disbursement_setup_pub.set_payee_instr_assignment in R12.
Please help asap.
ThanksO/P of query run for
SELECT rowid, instrument_payment_use_id
FROM iby_pmt_instr_uses_all
WHERE instrument_id =6642
AND EXISTS (
SELECT 1
FROM iby_external_payees_all b
WHERE payee_party_id= 85470
AND b.ext_payee_id = ext_pmt_party_id);
is below:
Rowid INSTRUMENT_PAYMENT_USE_ID
AABiDXAGIAABhiKAAS 236586
AABiDXAGRAABSjtAAz 148437
The version is R12 -
How do I get ALL the info records for a materials plants using an SAP FM?
I need to get all of the info records from the EINE table for a material - all of its sites (plants, we are using SAP retail).
The problem is this: I call the FM MD_INFORECORDS_READ - here is the code for my call:
CALL FUNCTION 'MD_INFORECORDS_READ'
EXPORTING
imatnr = t_output_data-article <-- the material number
iliefnr = lv_eina_key < -- see below on how I get this
importing
eeine =
TABLES
exp_eina = it_eina
exp_eine = it_eine
EXCEPTIONS
no_eina_record_found = 2
no_eine_record_found = 3.
lv_eina_key is taken from this call:
SELECT SINGLE altkn INTO lv_vendor_no
FROM lfb1
WHERE lifnr = lv_site (plant)
AND bukrs = t_output_data-company_code.
The probelm is it only returns the first record it finds for each site. There could be multiple info records, each one based a a different Valid From date for each site. I need either ALL of the EINE records for each site OR the most current one
I know I am not using ALl of the parms in the FM - but are there maybe there are other ones should I be using.
Perhaps there is there another FM I should be using - cause I do not have the info record number to pass.
Thanks.
ScottNever mind - the FM does work - this was bad data.
-
DCDIAG /test:dns result is pested here.
C:\Users\administrator.SUD>dcdiag /test:dns
Directory Server Diagnosis
Performing initial setup:
Trying to find home server...
Home Server = MUM-ADS-01
* Identified AD Forest.
Done gathering initial info.
Doing initial required tests
Testing server: Default-First-Site-Name\MUM-ADS-01
Starting test: Connectivity
......................... MUM-ADS-01 passed test Connectivity
Doing primary tests
Testing server: Default-First-Site-Name\MUM-ADS-01
Starting test: DNS
DNS Tests are running and not hung. Please wait a few minutes...
......................... MUM-ADS-01 passed test DNS
Running partition tests on : ForestDnsZones
Running partition tests on : DomainDnsZones
Running partition tests on : Schema
Running partition tests on : Configuration
Running partition tests on : sud
Running enterprise tests on : sud.in
Starting test: DNS
Test results for domain controllers:
DC: MUM-ADS-01.sud.in
Domain: sud.in
TEST: Basic (Basc)
Warning: The AAAA record for this DC was not found
TEST: Forwarders/Root hints (Forw)
Error: Root hints list has invalid root hint server:
a.root-servers.net. (198.41.0.4)
Error: Root hints list has invalid root hint server:
b.root-servers.net. (128.9.0.107)
Error: Root hints list has invalid root hint server:
c.root-servers.net. (192.33.4.12)
Error: Root hints list has invalid root hint server:
d.root-servers.net. (128.8.10.90)
Error: Root hints list has invalid root hint server:
e.root-servers.net. (192.203.230.10)
Error: Root hints list has invalid root hint server:
f.root-servers.net. (192.5.5.241)
Error: Root hints list has invalid root hint server:
g.root-servers.net. (192.112.36.4)
Error: Root hints list has invalid root hint server:
h.root-servers.net. (128.63.2.53)
Error: Root hints list has invalid root hint server:
i.root-servers.net. (192.36.148.17)
Error: Root hints list has invalid root hint server:
j.root-servers.net. (192.58.128.30)
Error: Root hints list has invalid root hint server:
k.root-servers.net. (193.0.14.129)
Error: Root hints list has invalid root hint server:
l.root-servers.net. (198.32.64.12)
Error: Root hints list has invalid root hint server:
m.root-servers.net. (202.12.27.33)
TEST: Delegations (Del)
Error: DNS server: sud-ad.sud.in. IP:<Unavailable>
[Missing glue A record]
TEST: Records registration (RReg)
Network Adapter
[00000006] Intel(R) PRO/1000 MT Network Connection:
Warning:
Missing AAAA record at DNS server 10.1.6.132:
MUM-ADS-01.sud.in
Warning:
Missing AAAA record at DNS server 10.1.6.132:
gc._msdcs.sud.in
Warning:
Missing AAAA record at DNS server 10.1.6.133:
MUM-ADS-01.sud.in
Warning:
Missing AAAA record at DNS server 10.1.6.133:
gc._msdcs.sud.in
Warning: Record Registrations not found in some network adapters
Summary of test results for DNS servers used by the above domain
controllers:
DNS server: 128.63.2.53 (h.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 128.63.2.53
DNS server: 128.8.10.90 (d.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 128.8.10.90
DNS server: 128.9.0.107 (b.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 128.9.0.107
DNS server: 192.112.36.4 (g.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 192.112.36.4
DNS server: 192.203.230.10 (e.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 192.203.230.10
DNS server: 192.33.4.12 (c.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 192.33.4.12
DNS server: 192.36.148.17 (i.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 192.36.148.17
DNS server: 192.5.5.241 (f.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 192.5.5.241
DNS server: 192.58.128.30 (j.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 192.58.128.30
DNS server: 193.0.14.129 (k.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 193.0.14.129
DNS server: 198.32.64.12 (l.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 198.32.64.12
DNS server: 198.41.0.4 (a.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 198.41.0.4
DNS server: 202.12.27.33 (m.root-servers.net.)
1 test failure on this DNS server
PTR record query for the 1.0.0.127.in-addr.arpa. failed on the DN
S server 202.12.27.33
Summary of DNS test results:
Auth Basc Forw Del Dyn RReg Ext
Domain: sud.in
MUM-ADS-01 PASS WARN FAIL FAIL PASS WARN n/a
......................... sud.in failed test DNSHi Meinolf,
Please find the IP Details as well as DNS test results.
C:\Users\Administrator.SCI>dcdiag /test:dns
Directory Server Diagnosis
Performing initial setup:
Trying to find home server...
Home Server = MDCDCDNS
* Identified AD Forest.
Done gathering initial info.
Doing initial required tests
Testing server: MDC-Powai\MDCDCDNS
Starting test: Connectivity
......................... MDCDCDNS passed test Connectivity
Doing primary tests
Testing server: MDC-Powai\MDCDCDNS
Starting test: DNS
DNS Tests are running and not hung. Please wait a few minutes...
ERROR: NO DNS servers for IPV6 stack was found
......................... MDCDCDNS passed test DNS
Running partition tests on : ForestDnsZones
Running partition tests on : DomainDnsZones
Running partition tests on : Schema
Running partition tests on : Configuration
Running partition tests on : sci
Running enterprise tests on : sci.com
Starting test: DNS
Test results for domain controllers:
DC: MDCDCDNS.sci.com
Domain: sci.com
TEST: Basic (Basc)
Warning: The AAAA record for this DC was not found
TEST: Records registration (RReg)
Network Adapter
[00000009] Microsoft Virtual Network Switch Adapter:
Warning:
Missing AAAA record at DNS server 10.64.7.32:
MDCDCDNS.sci.com
Warning:
Missing AAAA record at DNS server 10.64.7.32:
gc._msdcs.sci.com
Warning:
Missing AAAA record at DNS server 10.64.7.35:
MDCDCDNS.sci.com
Warning:
Missing AAAA record at DNS server 10.64.7.35:
gc._msdcs.sci.com
Warning:
Missing AAAA record at DNS server 10.20.33.72:
MDCDCDNS.sci.com
Warning:
Missing AAAA record at DNS server 10.20.33.72:
gc._msdcs.sci.com
Warning:
Missing AAAA record at DNS server 10.20.33.71:
MDCDCDNS.sci.com
Warning:
Missing AAAA record at DNS server 10.20.33.71:
gc._msdcs.sci.com
Warning: Record Registrations not found in some network adapters
MDCDCDNS PASS WARN PASS PASS PASS WARN n/a
......................... sci.com passed test DNS
C:\Users\Administrator.SCI>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : MDCDCDNS
Primary Dns Suffix . . . . . . . : sci.com
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : sci.com
Ethernet adapter Local Area Connection 7:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : External Internal Virtual Network
Physical Address. . . . . . . . . : 00-14-4F-CA-83-AC
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv4 Address. . . . . . . . . . . : 10.64.7.32(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 10.64.7.1
DNS Servers . . . . . . . . . . . : 10.64.7.32
10.64.7.35
10.20.33.72
10.20.33.71
NetBIOS over Tcpip. . . . . . . . : Disabled
Ethernet adapter Local Area Connection 6:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : TEAM : Team #1
Physical Address. . . . . . . . . : 00-14-4F-CA-83-AC
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Autoconfiguration IPv4 Address. . : 169.254.105.163(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapter Local Area Connection* 8:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : isatap.{2D5A4A27-298F-48E5-A376-EA886EF1E
42A}
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Tunnel adapter Local Area Connection* 9:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : isatap.{14FA7CD4-8B69-4C86-A58B-056793B7D
901}
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Please check and revert back for any queries..
Thanks...
Deva Self-trust is the first secret of success. -
Returning all records for a query
Hi,
still working on this library. I have the majority of it working (not pretty but it works). One problem I have run into is that when I query an authors name I would like all records for that author to be shown. However, it is only showing the final record.
public void Search_a()throws Exception{
String S_author1 = JOptionPane.showInputDialog(null,"Please enter the authors name");
String query = ("select * from library where Author=('"+S_author1+"')");
ResultSet rs = db_statement.executeQuery(query);
while (rs.next()) {
String s = rs.getString("Author");
output.setText(rs.getString("ISBN")+"\t"+rs.getString("Title")+"\t"+ s +"\t"+ rs.getString("Publisher")+"\t"+rs.getString("Genre")+"\t"+rs.getString("Details")+"\n");
}//end while
}// end search_aI cannot see where the error is. I think maybe I am overwriting the previous records but thought that the inclusion of +"\n" would force each result to a new line.
Any ideas?Thanks for that. Not really sure how I would implement that (new to programming) but I have managed to solve it using output.setText(output.getText()+rs.getString("ISBN")+"\t"+rs.getString("Title")+"\t"+ s +"\t"+ rs.getString("Publisher")+"\t"+rs.getString("Genre")+"\t"+rs.getString("Details")+"\n");Thanks for the reply though.
-
Report to get all the infotype maintained for pernr.
Hi all Experts,
i wanted to know whether there is any report which gives all the infotype which are maintained for some pernr.
Thx.
Raj.SE38 HTWLINF0
RPUAUD00 both fo these reports are used for ur requirment and also when an user has modified the infotype
Edited by: Sikindar on Jan 8, 2009 10:27 AM -
Hi how will get subquery returns multiple values for main query
Hi all ;
here i given one sql query
1)select decode(a.FLG,'Y','yes','N','no','null')||'] '||a.p_type||' : '|| initcap(replace(substr(b.mgr,0,instr(b.mgr,'@')-1),'.',' '))||' - '||
b.name||' ('|| substr(a.name,0,instr(a.name,'-')-1)||')'
from table1 a
join table3 c on c.emptype = a.emptype
left outer join table2 b on a.name = b.name
where a.mgrid = 100;
if i run this above query returning multiple values depend on sa.mgr values.
like output coming like this
yes:2000-anbarasan
yes:2700-anb
yes:2000-rasan
yes:2807-anbarasan
yes:2700-anbanu
yes:2000-null
2) this sub query i am passing with main query
select sa.mgrid,sa.sal,(select decode(a.FLG,'Y','yes','N','no','null')||'] '||a.p_type||' : '||
initcap(replace(substr(b.mgr,0,instr(b.mgr,'@')-1),'.',' '))||' - '||
b .name||' ('|| substr(a.name,0,instr(a.name,'-')-1)||')'
from table1 a
join table3 c on c.emptype = a.emptype
left outer join table2 b on a.name = b.name
where a.mgrid = 100)" test " from table4 sa,table5 te ,table6 ft where sa.id(+)=te.id and sa.mgr=ft.mgr;
my final out put required like this:
mgrid sal test
100 20000 yes:2000-anbarasan
yes:2700-anb
yes:2000-rasan
yes:2807-anbarasan
yes:2700-anbanu
yes:2000-null
but i am getting erro:
1)missing paranths
2)single row subquery return more then one row.
hi kindly give me answer to me as soon as possible
Edited by: anbarasan on Sep 29, 2008 9:48 PMI refuse to read all of that code and guess what error message you are getting. Apparently others feel the same way.
Run the final SQL statement and then cut and paste the code and full error statement into a post.
Also include your full version number to three decimal places.
My refusal is not an unwillingness to help you but rather an unwillingness to spend 10 minutes reconstructing what you could have pasted in in a fraction of a second. We are all volunteers here and there are many people that need help. I hope you understand. -
Returning latest records based on specific conditions
Hi Everyone, Thanks for everyone response for my queries. All responses are highly appreciated. I need one help in developing Sql query. I am
using Oracle 11.2.
I have table Test as below having columns as, ID;Name;Position;Level;Date_Added;Flag_Name;
Suppose I have below data in table:
ID Name Position Level Date_Added Flag_Name
1 Jack Manager 10 10/29/2013 11:00:00 PM Match
2 Tom Supervisor 20 10/31/2013 9:00:00 AM NoMatch
1 Jack Manager 15 11/1/2013 10:00:00 AM Error
1 Jack Manager 20 10/1/2013 9:00:00 AM NoMatch
3 John Salesman 5 10/4/2013 2:00:00 PM Error
1 Jack Manager 17 9/28/2013 2:00:00 AM NoMatch
2 Tom Supervisor 12 11/2/2013 10:00:00 AM NoMatch
4 Remy Accountant 12 11/4/2013 1:00:00 PM Error
4 Remy Accountant 19 11/3/2013 2:00:00 AM Error
2 Tom Supervisor 10 10/29/2013 7:00:00 PM Error
I need to return latest data in query based on combination of (ID;Name;Position) and date range with below conditions:
1) Need to return latest records for Flag_Name other than Match.
2) If latest record for combination of (ID;Name;Position) will come with Flag_Name as Error in that specified date range, then we need to look for this combination has Flag_Name as NoMatch anywhere before in table.
3) If Flag_Name as NoMatch is found for this, then we need to return it. In this case also, if we found multiple records with Flag_Name as NoMatch for combination of (ID;Name;Position), then we need to return latest one.
4) Else we find no record for combination of (ID;Name;Position) with Flag_Name as NoMatch in table, then we can return the latest record with Flag_Name as Error.
While select ID;Name;Position should be unique combination, as we always return latest data for it.
As per above table, if I need to return data for date range between 29-Oct-2013 and 5-Nov-2013, expected result will be like below:
ID Name Position Level Date_Added Flag_Name
1 Jack Manager 20 10/1/2013 9:00:00 AM NoMatch
2 Tom Supervisor 12 11/2/2013 10:00:00 AM NoMatch
3 John Salesman 5 10/4/2013 2:00:00 PM Error
4 Remy Accountant 12 11/4/2013 1:00:00 PM Error
Please let me know if anyone has any doubt about the logic. Is it possible if we can do it in select statement rather than pl/sql code?
All comments/suggestions will be highly appreciated.
Thanks in advance.
Regards
DevFirst i didn't read topic exactly )))
here is second way. I get with stmt from Karthick (thanks)
with t
as
select 1 id, 'Jack' name, 'Manager' position, 10 lvl, to_date('10/29/2013 11:00:00 PM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Match' flag_name
from dual union all
select 2 id, 'Tom' name, 'Supervisor' position, 20 lvl, to_date('10/31/2013 09:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'NoMatch' flag_name
from dual union all
select 1 id, 'Jack' name, 'Manager' position, 15 lvl, to_date('11/1/2013 10:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error' flag_name
from dual union all
select 1 id, 'Jack' name, 'Manager' position, 20 lvl, to_date('10/1/2013 09:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'NoMatch' flag_name
from dual union all
select 3 id, 'John' name, 'Salesman' position, 5 lvl, to_date('10/4/2013 02:00:00 PM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error' flag_name
from dual union all
select 1 id, 'Jack' name, 'Manager' position, 17 lvl, to_date('9/28/2013 02:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'NoMatch' flag_name
from dual union all
select 2 id, 'Tom' name, 'Supervisor' position, 12 lvl, to_date('11/2/2013 10:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'NoMatch' flag_name
from dual union all
select 4 id, 'Remy' name, 'Accountant' position, 12 lvl, to_date('11/4/2013 01:00:00 PM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error' flag_name
from dual union all
select 4 id, 'Remy' name, 'Accountant' position, 19 lvl, to_date('11/3/2013 02:00:00 AM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error' flag_name
from dual union all
select 2 id, 'Tom' name, 'Supervisor' position, 10 lvl, to_date('10/29/2013 07:00:00 PM', 'mm/dd/yyyy hh:mi:ss am') date_added, 'Error' flag_name
from dual
select ID,
Name,
Position,
max(lvl) keep (dense_rank first order by с desc, Date_Added desc) lvl,
max(Date_Added) keep (dense_rank first order by с desc, Date_Added desc) Date_Added,
min(Flag_Name) keep (dense_rank first order by с desc, Date_Added desc) Flag_Name
from(
select ID,
Name,
Position,
lvl,
Date_Added,
Flag_Name,
decode(flag_name, 'Error', -1, 1) с
from T
where flag_name != 'Match'
group by ID,Name,Position
ID
NAME
POSITION
LVL
DATE_ADDED
FLAG_NAME
1
Jack
Manager
20
01.10.2013 09:00:00
NoMatch
2
Tom
Supervisor
12
02.11.2013 10:00:00
NoMatch
3
John
Salesman
5
04.10.2013 14:00:00
Error
4
Remy
Accountant
12
04.11.2013 13:00:00
Error
Ramin Hashimzade
Message was edited by: RaminHashimzadeh -
Extractors in CRM returning 0 records
hello evryone,
could anyone please let me know, if they have come across these Extractors such as 0CRM_CONTACT_OUT,0CRM_OPPT_H,0CRM_OPPT_I how do they really work, upon some requirement i need these datasources in use. when i try to extractor check in rsa3 all these 3 extractors are returning 0 records for the full mode. could anyone please let me know, how to work on them to pull the data from these extractors to BI.Hi dear,
if you are working with LC datasource, you have to tun setup job to fill setup table in order to be able to see something with RSA3 !
Try OLI7BW for orders (application comp.11)
OLI8BW for 12
OLI9BW for 13
(don't forget to empty via LBWG these tables before filling them to avoid data duplication!!!)
Hope it helps!
Bye,
Roberto -
Help with pulling records for the last 24 hours
Post Author: kbrinton
CA Forum: Formula
Hi,
I don't know what is wrong with me but I can not figure out how to get Crystal to pull records for the last 24 hours. I have a date field I can key off of but I can not figure out the formula or correct syntax to put in the Selection formula. Any help would be great!! ThanksPost Author: SKodidine
CA Forum: Formula
No need to create any formula. In your record selection criteria type:
{table.date} in dateadd("h",-24,currentdatetime) to currentdatetime
If you just want the prior 24hrs and do not care about the time then replace 'currentdatetime' with 'currentdate'.
(currentdatetime - 24) will give you 24 days before and not 24 hours. -
Need help with a SQL qurey that returns multiple rows for one record?
I have the following query where I use a CASE WHEN clause to determine the date of a shift that begins with "FRLO" on day1 - day14 of the pay period. It works great if a schedule record contains one day that begins "FRLO", but if more than one day is "FRLO" then it only returns the first day it finds and not the others. Is there some way to get the query to return a ron for every day 1 - 14 that begins "FRLO"? System if Oracle 11G
Order of the results is not important as this is part of a larger query that orders the results.
Thanks in advance for any help,
George
SELECT s.empid,
CASE
WHEN UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO'
THEN
pp.startpp
WHEN UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO'
THEN
pp.startpp + 1
WHEN UPPER (SUBSTR (s.Day3, 0, 4)) = 'FRLO'
THEN
pp.startpp + 2
WHEN UPPER (SUBSTR (s.Day4, 0, 4)) = 'FRLO'
THEN
pp.startpp + 3
WHEN UPPER (SUBSTR (s.Day5, 0, 4)) = 'FRLO'
THEN
pp.startpp + 4
WHEN UPPER (SUBSTR (s.Day6, 0, 4)) = 'FRLO'
THEN
pp.startpp + 5
WHEN UPPER (SUBSTR (s.Day7, 0, 4)) = 'FRLO'
THEN
pp.startpp + 6
WHEN UPPER (SUBSTR (s.Day8, 0, 4)) = 'FRLO'
THEN
pp.startpp + 7
WHEN UPPER (SUBSTR (s.Day9, 0, 4)) = 'FRLO'
THEN
pp.startpp + 8
WHEN UPPER (SUBSTR (s.Day10, 0, 4)) = 'FRLO'
THEN
pp.startpp + 9
WHEN UPPER (SUBSTR (s.Day11, 0, 4)) = 'FRLO'
THEN
pp.startpp + 10
WHEN UPPER (SUBSTR (s.Day12, 0, 4)) = 'FRLO'
THEN
pp.startpp + 11
WHEN UPPER (SUBSTR (s.Day13, 0, 4)) = 'FRLO'
THEN
pp.startpp + 12
WHEN UPPER (SUBSTR (s.Day14, 0, 4)) = 'FRLO'
THEN
pp.startpp + 13
END
startdate,
NULL starttime,
NULL endtime,
8 hours,
0 minutes
FROM schedules s
JOIN
payperiods pp
ON pp.periodid = s.periodid
WHERE UPPER (SUBSTR (s.Day1, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day2, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day3, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day4, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day5, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day6, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day7, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day8, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day9, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day10, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day11, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day12, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day13, 0, 4)) = 'FRLO'
OR UPPER (SUBSTR (s.Day14, 0, 4)) = 'FRLO';
CURRENT OUTPUT
EMPID STARTDATE STARTTIME ENDTIME HOURS MINUTES
753738, 3/25/2013 , , ,8 ,0
753740, 3/25/2013 , , ,8 ,0
753748, 3/25/2013 , , ,8 ,0
DESIRED OUTPUT
EMPID STARTDATE STARTTIME ENDTIME HOURS MINUTES
753738, 3/25/2013 , , ,8 ,0
753740, 3/25/2013 , , ,8 ,0
753748, 3/25/2013 , , ,8 ,0
753738, 3/26/2013 , , ,8 ,0
753740, 3/26/2013 , , ,8 ,0
753740, 3/28/2013 , , ,8 ,0
753748, 1/1/2013 , , ,8 ,0
753738, 4/3/2013 , , ,8 ,0
753748, 4/3/2013 , , ,8 ,0
CREATE TABLE SCHEDULES
SCHEDULEID NUMBER(12) NOT NULL,
EMPID NUMBER(12) NOT NULL,
PERIODID VARCHAR2(6 BYTE) NOT NULL,
AREAID NUMBER(12) NOT NULL,
DAY1 VARCHAR2(50 BYTE),
DAY2 VARCHAR2(50 BYTE),
DAY3 VARCHAR2(50 BYTE),
DAY4 VARCHAR2(50 BYTE),
DAY5 VARCHAR2(50 BYTE),
DAY6 VARCHAR2(50 BYTE),
DAY7 VARCHAR2(50 BYTE),
DAY8 VARCHAR2(50 BYTE),
DAY9 VARCHAR2(50 BYTE),
DAY10 VARCHAR2(50 BYTE),
DAY11 VARCHAR2(50 BYTE),
DAY12 VARCHAR2(50 BYTE),
DAY13 VARCHAR2(50 BYTE),
DAY14 VARCHAR2(50 BYTE),
NOPTIND1 INTEGER DEFAULT 0,
NOPTIND2 INTEGER DEFAULT 0,
NOPTIND3 INTEGER DEFAULT 0,
NOPTIND4 INTEGER DEFAULT 0,
NOPTIND5 INTEGER DEFAULT 0,
NOPTIND6 INTEGER DEFAULT 0,
NOPTIND7 INTEGER DEFAULT 0,
NOPTIND8 INTEGER DEFAULT 0,
NOPTIND9 INTEGER DEFAULT 0,
NOPTIND10 INTEGER DEFAULT 0,
NOPTIND11 INTEGER DEFAULT 0,
NOPTIND12 INTEGER DEFAULT 0,
NOPTIND13 INTEGER DEFAULT 0,
NOPTIND14 INTEGER DEFAULT 0
CREATE TABLE PAYPERIODS
PERIODID VARCHAR2(6 BYTE) NOT NULL,
STARTPP DATE,
ENDPP DATE
Insert into SCHEDULES
(SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
DAY2, DAY3, DAY4, DAY5, DAY6,
DAY7, DAY8, DAY9, DAY10, DAY11,
DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693744, 753738, '082013', 2167, 'X',
'FRLO<1530>', 'FRLO<1530>', '1530', '1530', '1530',
'X', 'X', '1530', '1530', 'FRLO',
'1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0);
Insert into SCHEDULES
(SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
DAY2, DAY3, DAY4, DAY5, DAY6,
DAY7, DAY8, DAY9, DAY10, DAY11,
DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693745, 753740, '082013', 2167, 'X',
'FRLO<1530>', 'FRLO<1530>', '1530', 'FRLO', '1530',
'X', 'X', '1530', '1530', '1530',
'1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0);
Insert into SCHEDULES
(SCHEDULEID, EMPID, PERIODID, AREAID, DAY1,
DAY2, DAY3, DAY4, DAY5, DAY6,
DAY7, DAY8, DAY9, DAY10, DAY11,
DAY12, DAY13, DAY14, NOPTIND1, NOPTIND2,
NOPTIND3, NOPTIND4, NOPTIND5, NOPTIND6, NOPTIND7,
NOPTIND8, NOPTIND9, NOPTIND10, NOPTIND11, NOPTIND12,
NOPTIND13, NOPTIND14)
Values
(3693746, 753748, '082013', 2167, 'X',
'FRLO<1530>', '1530', '1530', '1530', '1530',
'X', 'X', 'FRLO<1530>', '1530', 'FRLO',
'1530', '1530', 'X', 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0);
COMMIT;
Insert into PAYPERIODS
(PERIODID, STARTPP)
Values
('082013', TO_DATE('03/24/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
COMMIT;Do you have the opportunity to change the data model to have one day per row ? It would make this easier to get this result without the need for a 14-way CASE or UNION.
If not...
The case statement will return as soon as it matches one of the conditions. Since you want a match when any column in the row starts with FRLO you can use a UNION ALL treating each column as a separate result. There may be more efficient ways to do this, but here is one way:
Select S.Empid, Pp.Startpp Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day1, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+1 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day2, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+2 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day3, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+3 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day4, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+4 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day5, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+5 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day6, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+6 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day7, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+7 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day8, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+8 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day9, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+9 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day10, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+10 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day11, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+11 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day12, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+12 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day13, 0, 4)) = 'FRLO'
Union All
Select S.Empid, Pp.Startpp+13 Startdate, Null Starttime, Null Endtime, 8 Hours, 0 Minutes
From Schedules S Join Payperiods Pp On Pp.Periodid = S.Periodid
Where Upper (Substr (S.Day14, 0, 4)) = 'FRLO'
; -
SQL help: return number of records for each day of last month.
Hi: I have records in the database with a field in the table which contains the Unix epoch time for each record. Letz say the Table name is ED and the field utime contains the Unix epoch time.
Is there a way to get a count of number of records for each day of the last one month? Essentially I want a query which returns a list of count (number of records for each day) with the utime field containing the Unix epoch time. If a particular day does not have any records I want the query to return 0 for that day. I have no clue where to start. Would I need another table which has the list of days?
Thanks
RayPeter: thanks. That helps but not completely.
When I run the query to include only records for July using a statement such as following
============
SELECT /*+ FIRST_ROWS */ COUNT(ED.UTIMESTAMP), TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD') AS DATA
FROM EVENT_DATA ED
WHERE AGENT_ID = 160
AND (TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY')+(ED.UTIMESTAMP/86400)), 'MM/YYYY') = TO_CHAR(SYSDATE-15, 'MM/YYYY'))
GROUP BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD')
ORDER BY TO_CHAR((TO_DATE('01/01/1970','MM/DD/YYYY') + (ED.UTIMESTAMP/86400)), 'MM/DD');
=============
I get the following
COUNT(ED.UTIMESTAMP) DATA
1 07/20
1 07/21
1 07/24
2 07/25
2 07/27
2 07/28
2 07/29
1 07/30
2 07/31
Some dates donot have any records and so no output. Is there a way to show the missing dates with a COUNT value = 0?
Thanks
Ray -
Get only one record for an id for a date if multiple record exists
Hi,
I need help with below mentioned scenario.
DB Version: 11.2.0.3.0.
Requirement:
Fetch account records that were created after last run of program
Get latest record for an account on a given date if there are multiple records for same account.
If there is a gap of more than 1 day from last run of program, then get latest record for an account for each date if there are multiple records for same account.
Create table t_test
Id number not null,
cust_id number not null,
cust_Acct_id number not null,
ins_date date not null
insert into t_test values
(1, 12345, 678905, to_date('05/31/2012 12:05:10 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(2, 12345, 678905, to_date('05/31/2012 05:25:46 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(3, 12345, 678905, to_date('05/31/2012 11:48:00 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(4, 12345, 678905, to_date('06/01/2012 12:05:10 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(5, 12345, 678905, to_date('06/01/2012 05:25:46 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(6, 12345, 678905, to_date('06/01/2012 11:48:00 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(7, 12345, 678905, to_date('06/02/2012 12:05:10 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(8, 12345, 678905, to_date('06/02/2012 05:25:46 PM','MM/DD/YYYY HH:MI:SS PM'));
insert into t_test values
(9, 12345, 678905, to_date('06/02/2012 11:48:00 PM','MM/DD/YYYY HH:MI:SS PM'));
create table t_log
id number not null,
prgrm_id number not null,
last_run_date date not null
insert into t_log values
(1,1009,to_date('5/30/2012 07:05:12 AM','MM/DD/YYYY HH:MI:SS PM'));Result required:
id cust_id cust_acct_id ins_date
3 12345 678905 '05/31/2012 11:48:00 PM'
6 12345 678905 '06/01/2012 11:48:00 PM'
9 12345 678905 '06/02/2012 11:48:00 PM'
I tried below sql but it will return only id 9 record.
select
id,
cust_id,
cust_acct_id,
ins_date
from
select
id,
cust_id,
cust_acct_id,
ins_date,
row_number() over (partition by cust_acct_id order by ins_date desc) rn
from
t_test t
where
t.ins_date > (
select
last_run_date
from
t_log l
where
l.prgrm_id = 1009
where rn = 1;Thanks in advance.Try:
SQL> select
2 id,
3 cust_id,
4 cust_acct_id,
5 ins_date
6 from
7 (
8 select
9 t.id,
10 t.cust_id,
11 t.cust_acct_id,
12 t.ins_date,
13 row_number() over (partition by cust_acct_id, trunc(ins_date) order by ins_date desc) r
n
14 from
15 t_test t
16 , t_log l
17 where
18 t.ins_date >= l.last_run_date
19 and l.prgrm_id = 1009
20 )
21 where rn = 1;
ID CUST_ID CUST_ACCT_ID INS_DATE
3 12345 678905 31-05-2012 23:48:00
6 12345 678905 01-06-2012 23:48:00
9 12345 678905 02-06-2012 23:48:00But I now see that Bob already nailed it, while I was testing it ;) -
Can select statement return 'No Record found' for each of invalid inputs.
Let say when you select a invalid booking number, oracle will
return nothing, but do u know how to make oracle return a record
saying it's invalid?
Example, the following sql normally return 3 records cause
only 3 numbers are valid, is there anyway to make it return
4 records and indicate those invalid ones are invalid somehow.
select booking_service, BOOKING_NO from tb_booking where booking_no in ('valid1','INVALID', 'valid2', 'valid3')Along the same lines you could use object types to achieve the same result. This would remove the need for a temporary table, and also allow you to create the list of ids to check with PL/SQL without i/o. As an example
CREATE TYPE booking_id_typ IS OBJECT (id NUMBER);
CREATE TYPE booking_id_list_typ IS TABLE OF booking_id_typ;
CREATE TABLE bookings (booking_id booking_id_typ);
(you could have booking_id as type NUMBER, but for consistency with subsequent SQL I've used booking_id_typ)
INSERT INTO bookings VALUES (booking_id_typ(10));
INSERT INTO bookings VALUES (booking_id_typ(20));
INSERT INTO bookings VALUES (booking_id_typ(40));
INSERT INTO bookings VALUES (booking_id_typ(50));
The following SQL statement creates a collection on the fly, rather than using an IN clause.
SELECT i.id booking_id, DECODE(b.booking_id.id, NULL, 'Invalid', 'Ok') status
FROM bookings b,
SELECT id
FROM TABLE(booking_id_list_typ(booking_id_typ(10), booking_id_typ(20), booking_id_typ(30), booking_id_typ(40)))
) i
WHERE i.id = b.booking_id.id (+)
BOOKING_ID STATUS
10 Ok
20 Ok
30 Invalid
40 Ok
This SQL statement works in 9i. I get the following error in 8i, but you might be able to CAST the TABLE to booking_id_list_typ, or depending on your application, create a PL/SQL variable of type booking_id_list_typ and CAST that instead.
ERROR at line 5:
ORA-22905: cannot access rows from a non-nested table item -
When I open iTunes it is slow to open for one, and two when it does see my iPhone and i go to sync it this is what I get in return... The iPhone "My Name here" could not be synced because the iPhone could not be found on the network. that is a pop up box in middle of screen that says that it does it like every time I go to sync the phone after i do app updates. I am getting very frustrated by this can someone please help. I have made 2 other discussion topics about this and no replies on them. Please if anyone can help I ask for help. This has occurred ever since the iOS 5.1 update and the iTunes 10.6.0 and still continues with the iTunes 10.6.1 update just yesterday and perhaps even worse now. PLEASE HELP IF YOU CAN. I have looked through my network settings etc and everything looks good here on my side.
When I open iTunes it is slow to open for one, and two when it does see my iPhone and i go to sync it this is what I get in return... The iPhone "My Name here" could not be synced because the iPhone could not be found on the network. that is a pop up box in middle of screen that says that it does it like every time I go to sync the phone after i do app updates. I am getting very frustrated by this can someone please help. I have made 2 other discussion topics about this and no replies on them. Please if anyone can help I ask for help. This has occurred ever since the iOS 5.1 update and the iTunes 10.6.0 and still continues with the iTunes 10.6.1 update just yesterday and perhaps even worse now. PLEASE HELP IF YOU CAN. I have looked through my network settings etc and everything looks good here on my side.
Maybe you are looking for
-
Report Does Not Follow Select Column Order
Hi all, Apex 2.2 on 10gXE I always encounter this problem, the display column on report does not follow the select column sequence order in the "region source". It is very tedious clicking the up/down arrow one-by-one in the "report attributes" espec
-
Change the colour of the prompt and the value
Hi, I have an Item MessageStyledText with some value on an OAF Page. By default the colour of the Prompt and the value of this Item are black. But i need to change the Colour to Blue. Fast response highly appreciated. Thanks, Palepu.
-
One of our DPs has stopped loading content. I've research for quite a bit and cannot find a clear cut reason to this. This server only has a DP role, I verified sharing permissions, all looked good. This DP has been running just fine for the last y
-
DW CS3 Unexpected table row growth.
upgraded to CS3 from DW8, DWMX and found the following problem with my pages. I should say with the way they display in DW CS3. The problem is that the row expands in design view to accommodate the variable names, unlike previous prevouse versions th
-
Only a novice Ipod gen 4 user and was trying to figure out how to build a library. After figuring this out and trying to re-sync my ipod, I get the msg,"Ipod Sync Complete, but there are 0 songs on my ipd even though I have 37 albums. Any ideas are g