Need help with SQL*Loader not working
Hi all,
I am trying to run SQL*Loader on Oracle 10g UNIX platform (Red Hat Linux) with below command:
sqlldr userid='ldm/password' control=issue.ctl bad=issue.bad discard=issue.txt direct=true log=issue.log
And get below errors:
SQL*Loader-128: unable to begin a session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Can anyone help me out with this problem that I am having with SQL*Loader? Thanks!
Ben Prusinski
Hi Frank,
More progress, I exported the ORACLE_SID and tried again but now have new errors! We are trying to load an Excel CSV file into a new table on our Oracle 10g database. I created the new table in Oracle and loaded with SQL*Loader with below problems.
$ export ORACLE_SID=PROD
$ sqlldr 'ldm/password@PROD' control=prod.ctl log=issue.log bad=bad.log discard=discard.log
SQL*Loader: Release 10.2.0.1.0 - Production on Tue May 23 11:04:28 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL*Loader: Release 10.2.0.1.0 - Production on Tue May 23 11:04:28 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Control File: prod.ctl
Data File: prod.csv
Bad File: bad.log
Discard File: discard.log
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table TESTLD, loaded from every logical record.
Insert option in effect for this table: REPLACE
Column Name Position Len Term Encl Datatype
ISSUE_KEY FIRST * , CHARACTER
TIME_DIM_KEY NEXT * , CHARACTER
PRODUCT_CATEGORY_KEY NEXT * , CHARACTER
PRODUCT_KEY NEXT * , CHARACTER
SALES_CHANNEL_DIM_KEY NEXT * , CHARACTER
TIME_OF_DAY_DIM_KEY NEXT * , CHARACTER
ACCOUNT_DIM_KEY NEXT * , CHARACTER
ESN_KEY NEXT * , CHARACTER
DISCOUNT_DIM_KEY NEXT * , CHARACTER
INVOICE_NUMBER NEXT * , CHARACTER
ISSUE_QTY NEXT * , CHARACTER
GROSS_PRICE NEXT * , CHARACTER
DISCOUNT_AMT NEXT * , CHARACTER
NET_PRICE NEXT * , CHARACTER
COST NEXT * , CHARACTER
SALES_GEOGRAPHY_DIM_KEY NEXT * , CHARACTER
value used for ROWS parameter changed from 64 to 62
Record 1: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 2: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 3: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 4: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 5: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 6: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 7: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 8: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 9: Rejected - Error on table ISSUE_FACT_TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 10: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 11: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 12: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 13: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 14: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 15: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 16: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 17: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 18: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 19: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 20: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 21: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 22: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 23: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 24: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
Record 39: Rejected - Error on table TESTLD, column DISCOUNT_AMT.
Column not found before end of logical record (use TRAILING NULLCOLS)
MAXIMUM ERROR COUNT EXCEEDED - Above statistics reflect partial run.
Table TESTLD:
0 Rows successfully loaded.
51 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 255936 bytes(62 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 51
Total logical records rejected: 51
Total logical records discarded: 0
Run began on Tue May 23 11:04:28 2006
Run ended on Tue May 23 11:04:28 2006
Elapsed time was: 00:00:00.14
CPU time was: 00:00:00.01
[oracle@casanbdb11 sql_loader]$
Here is the control file:
LOAD DATA
INFILE issue_fact.csv
REPLACE
INTO TABLE TESTLD
FIELDS TERMINATED BY ','
ISSUE_KEY,
TIME_DIM_KEY,
PRODUCT_CATEGORY_KEY,
PRODUCT_KEY,
SALES_CHANNEL_DIM_KEY,
TIME_OF_DAY_DIM_KEY,
ACCOUNT_DIM_KEY,
ESN_KEY,
DISCOUNT_DIM_KEY,
INVOICE_NUMBER,
ISSUE_QTY,
GROSS_PRICE,
DISCOUNT_AMT,
NET_PRICE,
COST,
SALES_GEOGRAPHY_DIM_KEY
)
Similar Messages
-
Need help with SQL Query with Inline View + Group by
Hello Gurus,
I would really appreciate your time and effort regarding this query. I have the following data set.
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
Please Ignore '----', added it for clarity
I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
The query should return the following data set
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
The following is my query. I am kind of lost.
select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
from (
select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
from INVOICE
group by sequence_id,check_date, check_number, invoice_number, vendor_number
) A, INVOICE B
where A.sequence_id = B.sequence_id
Thanks,
NickIt looks like it is a duplicate thread - correct me if i'm wrong in this case ->
Need help with SQL Query with Inline View + Group by
Regards.
Satyaki De. -
I have Oracle 11g R2 running on Windows Server 2008 R2
In trying to load data (csv file) with SQL Loader in Enterprise Manager it tells me the job completed successfully, but there is no data in the table. The bat file is created as is the ctl and sh file. I have checked that sqldr is in my $ORACLE_HOME$\bin directory and I have checked that this "path" is also in my path environment variable. When I try to run from command line I get not recognized as an internal or external command, operable program or batch file. I try to run it in SQL Developer and after it runs it says task cancelled. Can you help. I am expecting a 70-90 million record file next week and I want to use SQL Loader.
Message in Enterprise Manager
Status Succeeded
Exit Code 0
Step ID 31327
Targets leads.global
Started May 10, 2013 3:55:14 PM (UTC-07:00)
Ended May 10, 2013 3:55:22 PM (UTC-07:00)
Step Elapsed Time 8 seconds
Management Service WIN-D1CINRVM11K:1158_Management_Service
TIP Management Service from which the job step was dispatched.
Output Log
Username:
SQL*Loader: Release 11.2.0.1.0 - Production on Fri May 10 15:55:15 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Load completed - logical record count 51.I usually run SQL*Loader from SQL*Plus, so that it avoids some of the privilege issues. I also use a log file, so that I can check that afterwards to see what happened and why. For example:
host sqlldr scott/tiger control=test.ctl log=test.log
A frequent issue is lack of privileges to the data file to be loaded. You can edit a blank file in SQL*Plus and copy and paste the data into it, to eliminate such problems or identify them, so that you can check privileges on the original file.
To provide much else, we would need more complete information, such as a few rows of sample data, your SQL*Loader control file, and your table structure. -
Need help with ACE Load Balancing Base on URL pattern
This is the first time for me trying to configure something like this on the ACE load balancer. I need help configuring a load balancing policy base on URL pattern. URL https://ineedhelp.com base on /willuhelpme and /imlost
Key: ineedhelp_key
cert: ineedhelp_cert
serverfarmA
serverA 10.1.1.1 443
serverfarmB
serverB 10.1.1.2 443
ineedhelp.com/willuhelpme-------serverfarmA
ineedhelp.ocm/imlost---------------serverfarmBThis is the first time for me trying to configure something like this on the ACE load balancer. I need help configuring a load balancing policy base on URL pattern. URL https://ineedhelp.com base on /willuhelpme and /imlost
Key: ineedhelp_key
cert: ineedhelp_cert
serverfarmA
serverA 10.1.1.1 443
serverfarmB
serverB 10.1.1.2 443
ineedhelp.com/willuhelpme-------serverfarmA
ineedhelp.ocm/imlost---------------serverfarmB -
I was wondering if anyone could assist me with a sql loader question. I am trying to use it to load some hungarian data. It always turns the Ő character into an upside down question mark. I understand that it is because the database doesn't understand what that character is. Can someone help me find out how to resolve that? The database is UTF-8. If I paste the character in to the application, it takes it. I have tried all kinds of values for the CHARSET parameter in the .ctl file, but nothing seems to work....
I believe we are using iso 8859-1.
I am having a difficult time thinking that it could be we don't have the appropriate installations - because if we paste it in via the oracle application we can see it in a form. If we sql load that same character and look at it in an oracle form, we see the question marks.
i've looked at many of the documents on tahiti already, and found some helpful stuff, but no explanation for the problem i am having so far :) -
Really need help with a loading screen
Ok, here's my problem, I'm making a puzzle game and I can't seem to make my loading screen work with my main menu. The loading screen is represented by an image filling up with colour where the colouring takes place by means of a thread (and there's a string as well that paints the %) . Now the loading screen is supposed to appear after i click the start button from the main menu and after completely filling up (or when the tread dies) the game panel is suppposed to be show on screen. Between the loading I initialize all the components for the game. Now, when I press the start button, the whole screen freezes (for the duration of the loading thread) after which the game screen appears. What puzzles me more is that if i don't add the game screen the loading screen works like a charm.
Here's some of the code:
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().compareTo("Start")==0){
//initializing the panel for the loading
ds=new Load();
//initializing the thread that makes the panel rainbow dream
anm=new Ompy();
x.remove(pent); //pent is the jpanel containing the main menu with the customised buttons, and x is the reference to the current JFrame's content pane
x.add(ds);
pack();
/* MediaTracker tracker=new MediaTracker(this);
tracker.addImage(ds.pic.im,2); //i tried using a media tracker to wait for the image of the loading jpanel
tracker.addImage(ds.fill.im,2);
try{tracker.waitForID(2);}
catch(InterruptedException ie){} */
anm.start(); //i start the thread
//without the folowing code the loading screen works perfectly
some code
Winx gs=new Winx(); //the panel containing the game interface
some code
while(anm.isAlive()){}
x.remove(ds); // i remove the loading screen
x.add(gs); //i add the game screen
anm=null;
ds=null;
setVisible(true);
gigaslave.requestFocusInWindow();
pack();
//here ends the code that shadows my loading screen :((
else {System.exit(0);}}
}I appreciate your help.Thanks for all your help ...this is what i have so far and am working with:
import javax.swing.JOptionPane;
public class TVRemote{
int volume = 5;
int channel = 5;
public void channelUp(){
if(channel < 25){
channel++;
public void channelDown(){
if(channel > 1){
channel--;
public void volumeUp(){
if(volume < 10){
volume++;
public void volumeDown(){
if(volume > 1){
volume--;
public class VCRemote extends TVRemote{
String tape = null;
String mode = "Stop";
public void insertTape(String t){
tape = t;
public void ejectTape(){
tape = null;
public void setMode(String m){
mode = m;
public String getMode(){
return mode;
public String getMode(){
if(tape == null){
System.out.println("There is no tape");
return mode;
I know it does have to be set as 2 files....I still need to put in a rewind and fast forward option would that be done the same way that public void insetTape is done? also I was wondering how i will interface it with the user? Cause the only output i see is a display message that there isn't any tape in the vcr.
Thankgs again for everyones help. -
A similar issue is posted on http://www.dbforums.com/database-concepts-design/927987-using-sql-loader-load-data-multiple-files.html, but not a solution yet there, any help on this issue is highly appreciated.
an alternative solution is also appreciated?
Thanks!
Hi All,
I have a peculiar error while I try to load 2 tables(table name: enroll_emp_back & enroll_dep_back) using SQLLDR, the source file is a .csv file.
CTL FILE CONTENT:
LOAD DATA
TRUNCATE
INTO TABLE enroll_emp_back
WHEN (1:8) = 'EMPLOYEE'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(type NULLIF type= BLANKS,
enrollstmt_ctl_cust_seqnum NULLIF enrollstmt_ctl_cust_seqnum= BLANKS,
pctl_employee_seqnum NULLIF pctl_employee_seqnum= BLANKS,
pctl_lot NULLIF pctl_lot= BLANKS,
pctl_counter NULLIF pctl_counter= BLANKS,
first_name NULLIF first_name= BLANKS,
last_name NULLIF last_name= BLANKS,
mi NULLIF mi= BLANKS,
ssn NULLIF ssn= BLANKS,
cssn NULLIF cssn= BLANKS,
emp_id NULLIF emp_id= BLANKS,
pin NULLIF pin= BLANKS,
addr1 NULLIF addr1= BLANKS,
addr2 NULLIF addr2= BLANKS,
addr3 NULLIF addr3= BLANKS,
city NULLIF city= BLANKS,
state_cd NULLIF state_cd= BLANKS,
zip NULLIF zip= BLANKS,
country NULLIF country= BLANKS,
birth_date NULLIF birth_date= BLANKS,
hire_date NULLIF hire_date= BLANKS,
adj_service_date NULLIF adj_service_date= BLANKS,
elig_date NULLIF elig_date= BLANKS,
smoker_ind NULLIF smoker_ind= BLANKS,
spouse_smoker_ind NULLIF spouse_smoker_ind= BLANKS,
partic_grp_id NULLIF partic_grp_id= BLANKS,
enroll_window_start NULLIF enroll_window_start= BLANKS,
enroll_window_end NULLIF enroll_window_end= BLANKS,
total_ee_cost NULLIF total_ee_cost= BLANKS,
total_er_cost NULLIF total_er_cost= BLANKS,
emp_custom1 NULLIF emp_custom1= BLANKS,
emp_custom2 NULLIF emp_custom2= BLANKS,
emp_custom3 NULLIF emp_custom3= BLANKS,
emp_custom4 NULLIF emp_custom4= BLANKS,
emp_custom5 NULLIF emp_custom5= BLANKS,
custom1 NULLIF custom1= BLANKS,
ctl_ins_dttm NULLIF ctl_ins_dttm= BLANKS,
ctl_upd_dttm NULLIF ctl_upd_dttm= BLANKS,
ctl_trans_seqnum NULLIF ctl_trans_seqnum= BLANKS,
ctl_upd_seq NULLIF ctl_upd_seq= BLANKS,
ctl_deleted_ind NULLIF ctl_deleted_ind= BLANKS,
ben_year NULLIF ben_year = BLANKS,
activity_id NULLIF activity_id= BLANKS,
client_name NULLIF client_name= BLANKS,
doc_type NULLIF doc_type= BLANKS,
environment_type NULLIF environment_type= BLANKS
INTO TABLE enroll_dep_back
WHEN (1:9) = 'DEPENDENT'
FIELDS TERMINATED BY ","
OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(type NULLIF type= BLANKS,
enrollstmt_ctl_cust_seqnum NULLIF enrollstmt_ctl_cust_seqnum= BLANKS,
pctl_employee_seqnum NULLIF pctl_employee_seqnum= BLANKS,
pctl_enroll_dep_num NULLIF pctl_enroll_dep_num= BLANKS,
pctl_dep_num NULLIF pctl_dep_num= BLANKS,
first_name NULLIF first_name= BLANKS,
last_name NULLIF last_name= BLANKS,
ssn NULLIF ssn= BLANKS,
birth_date NULLIF birth_date= BLANKS,
relation NULLIF relation= BLANKS,
sex NULLIF sex= BLANKS,
student_ind NULLIF student_ind= BLANKS,
disabled_ind NULLIF disabled_ind= BLANKS,
ctl_ins_dttm NULLIF ctl_ins_dttm= BLANKS,
ctl_upd_dttm NULLIF ctl_upd_dttm= BLANKS,
ctl_trans_seqnum NULLIF ctl_trans_seqnum= BLANKS,
ctl_upd_seq NULLIF ctl_upd_seq= BLANKS,
ctl_deleted_ind NULLIF ctl_deleted_ind= BLANKS,
den_covered NULLIF den_covered= BLANKS,
deplife_covered NULLIF deplife_covered= BLANKS,
empadd_covered NULLIF empadd_covered= BLANKS,
med_covered NULLIF med_covered= BLANKS,
supadd_covered NULLIF supadd_covered= BLANKS,
suplife_covered NULLIF suplife_covered= BLANKS,
vis_covered NULLIF vis_covered= BLANKS
Error I get:
Table ENROLL_DEP_BACK:
0 Rows successfully loaded.
0 Rows not loaded due to data errors.
1 Row not loaded because all WHEN clauses were failed.
1 Row not loaded because all fields were null.
I dont know why the 'ENROLL_DEP_BACK' table is not getting loaded. If i change the above ctl file in such a way that it first loads ENROLL_DEP_BACK table, then the 'enroll_emp_back' table is not getting loaded.
Please help me on this?
Source File:
EMPLOYEE,2322,181340,1,1,Gervaise,Babic,,704345064,704-34-5064,10223914,12345,123 Felton Street,Building 1,Suite 1,Marlborough,WI,53121,USA,11-May-60,9-Mar-09,7-Jan-04,1-Jan-07,N,N,FTNES,15-Apr-09,22-Apr-09,$0.00 ,$96.78 ,9-Apr-09,,,,,,15-Apr-09,15-Apr-09,1103597,4,N,2009,OE,NESTLE,ENROLL,D
DEPENDENT,2322,181340,1,1,Antony,Broking,765304168,4/26/1962,SP,M,N,N,15-Apr-09,15-Apr-09,1103597,1,N,N,N,N,N,,,N
SQL command used: SQLLDR wedb/wedbo@nestle_10_sd1 CONTROL=AENUSA2.ctl data=ENROLL.csv LOG=AENUSA.log DIRECT=y
Thank You
Edited by: HarinathArasu on Oct 7, 2009 6:26 AM
Edited by: HarinathArasu on Oct 7, 2009 7:17 AM
Edited by: HarinathArasu on Oct 7, 2009 8:24 AM
Edited by: HarinathArasu on Oct 7, 2009 8:24 AMWhen this error occurs it usually means there's some underlying schema changes taking place when you're trying to add a new article
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
I have a data file that looks like:
REC001;TO_NAME;TO_ADDR;TO_PHONE
REC002;ITEM_ID1;DATE_DELIVERED1
REC002;ITEM_ID2;DATE_DELIVERED2
REC002;ITEM_ID3;DATE_DELIVERED3
REC002;ITEM_ID4;DATE_DELIVERED4
i want to load this in the Database using SQL LOADER in this format:
NAME | ADDR | PHONE | ITEM | DATE DELIVERED
TO_NAME TO_ADDR TO_PHONE ITEM_ID1 DATE_DELIVERED1
TO_NAME TO_ADDR TO_PHONE ITEM_ID2 DATE_DELIVERED2
TO_NAME TO_ADDR TO_PHONE ITEM_ID3 DATE_DELIVERED3
TO_NAME TO_ADDR TO_PHONE ITEM_ID4 DATE_DELIVERED4
Basically i want the name, addr, phone from REC001 to be repeated every time i load REC002.
Any help on how to do this.The subject of this forum is AQ.
AQ <> SQL*Loader
Please delete this post and post in Database - General
When you do include full version information and format your post using PRE tags (explained in the FAQ). -
Need help with SQL retrieval for previous month till current date
Hi ,
Need help generating statistics from previous month from date of enquiry till current date of enquiry.
and have to display it according to date.
Date of enquiry : 03/02/2012
Application Type| 01/01/2012 | 02/01/2012 | 03/01/2012 |...... | 31/01/2012 | 01/02/2012 | 02/02/2012 | 03/02/2012 |
sample1 20 30 40
sample 2 40 40 50
sample 3 50 30 30
Hope you guys can help me with this.
RegardsHi,
932472 wrote:
Scenario
1)If i run the query at 12 pm on 03/2/2012. the result i will have to display till the current day.
2)displaying the count of the application made based on the date.
Application type 01012012 | 02012012 | 03012012 | ..... 01022012| 02022012|03022012
sample 1 30 40 50 44 30
sample 2 35 45 55
sample 3 36 45 55Explain how you get those results from the sample data you posted.
It would help a lot if you posted the results in \ tags, as described in the forum FAQ. {message{id=9360002}
SELECT application_type as Application_type
, COUNT (CASE WHEN created_dt = sysdate-3 THEN 1 END) AS 01012012 (should be getting dynamically)
, COUNT (CASE WHEN created_dt = sysdate-4 THEN 1 END) AS 02022012
, COUNT (CASE WHEN created_dt = sysdate-5 THEN 1 END) AS 03022012
, COUNT (CASE WHEN created_dt = sysdate-6 THEN 1 END) AS 04022012
FROM table_1
GROUP BY application_type
ORDER BY application_typeThat's the bais idea.
You can simplify it a little by factoring out the date differences:WITH got_d AS
SELECT qty
, TRUNC ( dt
- ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
, -1
) AS d
FROM table1
WHERE dt >= ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
, -1
AND dt < TRUNC (SYSDATE) + 1
SELECT SUM (CASE WHEN d = 1 THEN qty END) AS day_1
, SUM (CASE WHEN d = 2 THEN qty END) AS day_2
, SUM (CASE WHEN d = 62 THEN qty END) AS day_62
FROM got_d
See the links I mentioned earlier for getting exactly the right number of columns, and dynamic column aliases. -
Need help my iterator is not working
Hi, I am working on a program that deals with three keithley Multimeters and a GW instek power supply. I am currently having trouble getting my power supply to increment up and down. I have the correct formulas to complete this as they have worked before but after having this program totally redone the same code is not working. It would seem there is an error somewhere in the incrementing. The block I am talking about is in the lower right hand corner of the take reading state.
If you see anything please let me know. Thanks
Kenneth
North Dakota State University
Center for Nanoscale Science and Engineering
Attachments:
Thermo power 5-25-11 PM.vi 243 KBAre you saying the the indicator called '1' is not incrementing? It pretty much has to if your loop is running.
If the indicator IS incrementing and you expect it to actually do something, then you have a problem because it doesn't appear to be wired to anything except in the wait state. It's not connected to any part of your Instek code so it's not going increment any voltages. Did you mean to connect it to the Voltage control perhaps?
Using LabVIEW: 7.1.1, 8.5.1 & 2013 -
Need help regarding sql loader
Hi ,
I am executing following command
sqlldr admin_user@ces CONTROL=D:\sample_control.ctl log=D:\sample_log.log bad=D:\Sample_bad.bad
In case of valid data it is inserting the data properly into the table. While invalid records added into the bad file.
Now I want rollback valid data whenever count of bad file greater than equal to 10.
In short whenever file has more than 10 invalid records , I don't want to insert any record from that file.
Please provide me the solution.Thanks in advance.SQL*Loader Command-Line Reference
DISCARDMAX(integer)
Regards
Etbin -
Hi All,
I have a problem in the query below. When I run the query I got a pop-up screen to ente value for
:total_balance,
:emp_code,
:from_date,
:to_date
total_balance supose to be a result of a calculation.
Your assistance is apreciated. Thanks,
Ribhi
select FK_VOUCHERSERIAL_N,
FK_VOUCHERVALUE_DA,
DESCRIPTION,
nvl(AMOUNT,0) amount,
TYPE,
Accnt101.postive_amountformula(EMPLOYEE_TRANSACTI.TYPE, nvl(AMOUNT,0)) postive_amount,
Accnt101.negative_amountformula(EMPLOYEE_TRANSACTI.TYPE, nvl(AMOUNT,0)) negative_amount,
Accnt101.total_balanceformula(:total_balance, EMPLOYEE_TRANSACTI.TYPE,Accnt101.negative_amountformula(EMPLOYEE_TRANSACTI.TYPE, nvl(AMOUNT,0)) ,Accnt101.postive_amountformula(EMPLOYEE_TRANSACTI.TYPE, nvl(AMOUNT,0)) , nvl(AMOUNT,0)) total_balance
from EMPLOYEE_TRANSACTI
where FK_EMPLOYEENUMBER0=:emp_code
and STATUS=1
and FK_VOUCHERVALUE_DA<=:to_date
and FK_VOUCHERVALUE_DA>=:from_date
and ((TYPE >7 and TYPE <16)
or (TYPE >34 and TYPE <43)
or (TYPE =7)
or (TYPE =18)
or (TYPE >26 and TYPE <35)
or (TYPE =17)
OR (TYPE = 60)
OR (TYPE = 70)
OR (TYPE = 72)
OR (TYPE = 73)
OR (TYPE = 74)
or (type = 21)
or (type =24)
or (type = 81)
or (type = 82))
order by FK_VOUCHERVALUE_DA asc, FK_VOUCHERSERIAL_N asc, type descHi Satyaki,
My problem is with SQL and PL/SQL codd. I managed to convert some of my reports and now I'm facing a problem with converted SQL and PL/SQL code. To give you an Idea the following is a sample of a converted report.
Pls have a look. (p.s how can i post formated text)
Thanks,
Ribhi
1 - XML template file
<?xml version="1.0" encoding="UTF-8" ?>
- <dataTemplate name="Accnt101" defaultPackage="Accnt101" version="1.0">
- <properties>
<property name="xml_tag_case" value="upper" />
</properties>
- <parameters>
<parameter name="FROM_DATE" dataType="date" defaultValue="01/01/1998" />
<parameter name="TO_DATE" dataType="date" defaultValue="31/12/1998" />
<parameter name="EMP_CODE" dataType="number" defaultValue="44" />
</parameters>
<lexicals />
- <dataQuery>
- <sqlStatement name="employee_trans">
- <![CDATA[
select FK_VOUCHERSERIAL_N,
FK_VOUCHERVALUE_DA,
DESCRIPTION,
nvl(AMOUNT,0) amount,
TYPE,
Accnt101.postive_amountformula(EMPLOYEE_TRANSACTI.TYPE, nvl(AMOUNT,0)) postive_amount,
Accnt101.negative_amountformula(EMPLOYEE_TRANSACTI.TYPE, nvl(AMOUNT,0)) negative_amount,
Accnt101.total_balanceformula(:total_balance, EMPLOYEE_TRANSACTI.TYPE,Accnt101.negative_amountformula(EMPLOYEE_TRANSACTI.TYPE, nvl(AMOUNT,0)) ,Accnt101.postive_amountformula(EMPLOYEE_TRANSACTI.TYPE, nvl(AMOUNT,0)) , nvl(AMOUNT,0)) total_balance
from EMPLOYEE_TRANSACTI
where FK_EMPLOYEENUMBER0=:emp_code
and STATUS=1
and FK_VOUCHERVALUE_DA<=:to_date
and FK_VOUCHERVALUE_DA>=:from_date
and ((TYPE >7 and TYPE <16)
or (TYPE >34 and TYPE <43)
or (TYPE =7)
or (TYPE =18)
or (TYPE >26 and TYPE <35)
or (TYPE =17)
OR (TYPE = 60)
OR (TYPE = 70)
OR (TYPE = 72)
OR (TYPE = 73)
OR (TYPE = 74)
or (type = 21)
or (type =24)
or (type = 81)
or (type = 82))
order by FK_VOUCHERVALUE_DA asc, FK_VOUCHERSERIAL_N asc, type desc
]]>
</sqlStatement>
- <sqlStatement name="employee">
- <![CDATA[
select NAME,NUMBER0
from EMPLOYEE
where NUMBER0=:emp_code
]]>
</sqlStatement>
</dataQuery>
<dataTrigger name="beforeReportTrigger" source="Accnt101.beforereport" />
- <dataStructure>
- <group name="G_employee_trans" dataType="varchar2" source="employee_trans">
<element name="FK_VOUCHERSERIAL_N" dataType="number" value="FK_VOUCHERSERIAL_N" />
<element name="FK_VOUCHERVALUE_DA" dataType="date" value="FK_VOUCHERVALUE_DA" />
<element name="DESCRIPTION" dataType="varchar2" value="DESCRIPTION" />
<element name="AMOUNT" dataType="number" value="AMOUNT" />
<element name="postive_amount" dataType="number" value="postive_amount" />
<element name="negative_amount" dataType="number" value="negative_amount" />
<element name="total_balance" dataType="number" value="total_balance" />
<element name="TYPE" dataType="number" value="TYPE" />
<element name="CS_1" function="sum" dataType="number" value="G_employee_trans.total_balance" />
</group>
- <group name="G_employee" dataType="varchar2" source="employee">
<element name="NUMBER0" dataType="number" value="NUMBER0" />
<element name="NAME" dataType="varchar2" value="NAME" />
</group>
<element name="balance" dataType="number" value="Accnt101.balance_p" />
<element name="CS_2" function="count" dataType="number" value="G_employee.NUMBER0" />
<element name="CS_3" function="count" dataType="number" value="G_employee_trans.AMOUNT" />
</dataStructure>
</dataTemplate>
2 - PLS/SQL package
CREATE OR REPLACE PACKAGE Accnt101 AS
from_date date;
to_date date;
emp_code number;
balance number := 0 ;
function postive_amountformula(TYPE in number, amount in number) return number ;
function negative_amountformula(TYPE in number, amount in number) return number ;
function BeforeReport return boolean ;
function total_balanceformula(total_balance in number, TYPE in number, negative_amount in number, postive_amount in number, amount in number) return number ;
Function balance_p return number;
END Accnt101;
3- Package Body
CREATE OR REPLACE PACKAGE BODY Accnt101 AS
function postive_amountformula(TYPE in number, amount in number) return number is
begin
if ((TYPE>26 and TYPE<35)
or (TYPE=17))
then
return(amount);
elsif (type = 70)and (amount >=0) then
return (amount) ;
elsif (type = 72)and (amount >=0) then
return (amount) ;
elsif (type = 73)and (amount >=0) then
return (amount) ;
elsif (type = 74)and (amount >=0) then
return (amount) ;
elsif (type = 60)and (amount >=0) then
return (amount) ;
else
return (null) ;
end if;
RETURN NULL; end;
function negative_amountformula(TYPE in number, amount in number) return number is
begin
if ((TYPE>7 and TYPE<16)
or (TYPE >34 and TYPE <43)
or (TYPE=7)
or (TYPE=18)
or (type=21)
or (type=24)
or (type= 81)
or (type=82))
then
return(amount);
elsif (type = 70)and (amount <0) then
return (abs (amount)) ;
elsif (type = 72)and (amount <0) then
return (abs (amount)) ;
elsif (type = 73)and (amount <0) then
return (abs (amount)) ;
elsif (type = 74)and (amount <0) then
return (abs (amount)) ;
elsif (type = 60)and (amount <0) then
return (abs(amount)) ;
else
return (null) ;
end if;
RETURN NULL; end;
function BeforeReport return boolean is
var_pos number(15,3) ;
var_neg number(15,3) ;
beg_bal number(15,3) ;
Begin
begin
select sum (nvl(amount,0)) into beg_bal
from EMPLOYEE_TRANSACTI
where (TYPE=99 or type = 92 or type = 93 or type = 94)
and to_char(from_date,'YYYY')=to_char(date0,'YYYY')
and FK_EMPLOYEENUMBER0=emp_code;
EXCEPTION
WHEN NO_DATA_FOUND THEN
beg_bal := 0;
end;
begin
select sum(nvl(amount,0)) into var_pos
from EMPLOYEE_TRANSACTI
where
(TYPE=17
or type=60
OR TYPE=70
oR TYPE=72
OR TYPE=73
OR TYPE=74
or (TYPE>26 and TYPE<35))
and fk_vouchervalue_da<from_date
and fk_vouchervalue_da>= trunc(from_date,'year')
and FK_EMPLOYEENUMBER0=emp_code;
EXCEPTION
WHEN NO_DATA_FOUND THEN
var_pos := 0;
end;
Begin
select sum(nvl(amount,0)) into var_neg
from EMPLOYEE_TRANSACTI
where ((TYPE>7 and TYPE<16)
or (TYPE >34 and TYPE <43)
or (TYPE=7)
or (TYPE=18)
or (type=21)
or (type=24)
or (type= 81)
or (type=82) )
and fk_vouchervalue_da<from_date
and fk_vouchervalue_da>= trunc(from_date,'year')
and FK_EMPLOYEENUMBER0=emp_code;
balance :=nvl(beg_bal,0) + nvl(var_pos,0) - nvl(var_neg,0);
return(true);
EXCEPTION
WHEN NO_DATA_FOUND THEN
balance :=nvl(beg_bal,0) + nvl(var_pos,0) - nvl(var_neg,0);
RETURN (TRUE);
end;
RETURN NULL; end;
function total_balanceformula(total_balance in number, TYPE in number, negative_amount in number, postive_amount in number, amount in number) return number is
begin
if total_balance is null then
if ((TYPE>7 and TYPE<16)
or (TYPE >34 and TYPE <43)
or (TYPE=7)or (TYPE=18)
or (type=21) or (type=24)
or (type= 81)
or (type=82))
then
return(balance-negative_amount);
elsif ((TYPE>26 and TYPE<35) or (TYPE=17))
then
return(balance+postive_amount);
elsif (type=70 or type=72 or type=73 or type=74
or type=60) and (amount >=0) then
return(balance+postive_amount);
elsif (type=70 or type=72 or type=73 or type=74
or type=60) and (amount <0) then
return(balance-negative_amount);
end if;
else
if ((TYPE>7 and TYPE<16)
or (TYPE >34 and TYPE <43)
or (TYPE=7)or (TYPE=18)
or (type=21) or (type=24)
or (type= 81)
or (type=82))
then
return(total_balance-negative_amount);
elsif ((TYPE>26 and TYPE<35) or (TYPE=17))
then
return(total_balance+postive_amount);
elsif (type=70 or type=72 or type=73 or type=74
or type=60) and (amount >=0) then
return(total_balance+postive_amount);
elsif (type=70 or type=72 or type=73 or type=74
or type=60) and (amount <0) then
return(total_balance-negative_amount);
end if;
end if ;
RETURN NULL; end;
Functions to refer Oracle report placeholders
Function balance_p return number is
Begin
return balance;
END;
END Accnt101 ; -
Need a little help with a Jbutton not working out the way I planned
The following code is to fulfill an assignment I am working on. The problem I am having is with the btnCalc. For some reason when the button is used, the results I get is from another button. I think the variables are set right for the program to function properly but I am really hung up on this. Do anyone have any suggestions?
import java.awt.*; //Contains classes for creating GUI
import java.awt.event.*; //For listener events
import javax.swing.*; // Imports the Main Swing Package
import javax.swing.event.*;
import javax.swing.text.*; // Positions text box
import java.text.NumberFormat; // For number format such as currency
import java.text.*; // Imports the Main Text Package
import java.util.*; // Utility Package
public class MPC extends JFrame implements ActionListener //Creates Class for MPC
//double dblLoanAmount, dblInterestRate, dblMonthlyPayment;
TextField txtTotalMort;
//JButton fixRates = new JButton("Choose Fixed Rates");
JLabel lblTotalMort = new JLabel("How much is the loan?"); // Label for dblLoanAmount amount
JTextField txtYears = new JTextField(10);
JLabel lblPayment = new JLabel("Your monthly payment is "); // Label for Payment
JTextField txtPayment = new JTextField(10);
JLabel lblYears = new JLabel("How many years?");
// add(lblYears);
JTextField txtYearsInput = new JTextField(10);
//a dd(txtYears);
JLabel lblInterestRate = new JLabel("What is the interest rate?");
//add(lblInterestRate);
JTextField txtInterestRate = new JTextField(10);
//add(txtInterestRate);
//JLabel lblPayment = new JLabel("Your monthly payment is:");
//add(lblPayment);
//JTextField txtPayment = new JTextField(10);
//txtPayment.setEditable(false);
//add(txtPayment);
JButton btnCalc = new JButton("Calculate");
//add(btnCalc);
//btnCalc.addActionListener(this);
JButton year7InterestRateBtn = new JButton("7 years at 5.35%"); // Mortgage Term and Interest Rate
JButton year15InterestRateBtn = new JButton("15 years at 5.50%");
JButton year30InterestRateBtn = new JButton("30 years at 5.75%");
JButton reset = new JButton("Clear All");
JTextArea boxSpace = new JTextArea(100,200); // Morgtage table size
JScrollPane scroll = new JScrollPane(boxSpace); // ScrollPane
public MPC() // Method
super("MPC"); // Frame Title
JMenuBar mb = new JMenuBar(); // Menu Bar
setJMenuBar(mb);
setSize(325, 500); // Frame Size
JPanel pane = new JPanel();
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); //Grid box configuration
Container grid = getContentPane();
grid.setLayout(new GridLayout(8,2,8,8)); // Grid Layout
pane.add(grid); // Adds grid
pane.add(scroll); // Adds scrollPane
grid.setBackground(Color.white);
Setting color of text and backgrounds
txtYears.setBackground(Color.white);
txtYears.setForeground(Color.black);
txtYears.setFont(new Font("Arial", Font.PLAIN, 10));
txtPayment.setBackground(Color.white);
txtPayment.setForeground(Color.black);
txtPayment.setFont(new Font("Arial", Font.PLAIN, 10));
boxSpace.setBackground(Color.white);
boxSpace.setForeground(Color.black);
boxSpace.setFont(new Font("Arial", Font.PLAIN, 10));
grid.add(lblYears);
grid.add(txtYearsInput);
grid.add(lblInterestRate);
grid.add (txtInterestRate);
grid.add(lblTotalMort); // Adds the Mortgage Amount Label
grid.add(txtYears); // Adds the Mortgage Amount Text Field
grid.add(lblPayment); // Adds the Payment Label
grid.add(txtPayment); // Adds the Monthly Payment Text Field
txtPayment.setEditable(false); // Disables editing in this Text Field
grid.add(btnCalc);
grid.add(year7InterestRateBtn); // Adds 1st Loan and Rate Button
grid.add(year15InterestRateBtn); // Adds 2nd Loan and Rate Button
grid.add(year30InterestRateBtn); // Adds the Exit Button
grid.add(reset); // Adds the New Calc Button
setContentPane(pane); // Enables the Content Pane
setVisible(true); // Sets JPanel to be Visable
reset.addActionListener(this); // Adds Action Listener to the New Calc Button
txtYearsInput.addActionListener(this);
txtInterestRate.addActionListener(this);
btnCalc.addActionListener(this);
year7InterestRateBtn.addActionListener(this); // Adds Action Listener to the 1st loan Button
year15InterestRateBtn.addActionListener(this); // Adds Action Listener to the 2nd loan Button
year30InterestRateBtn.addActionListener(this); // Adds Action Listener to the 3rd loan Button
txtYears.addActionListener(this); // Adds Action Listener to the Mortgage Amount Text Field
txtPayment.addActionListener(this); // Adds Action Listener to the Monthly payment Text Field
public void actionPerformed(ActionEvent e) // Tests to Verify Which Button is Pressed
Object command = e.getSource(); // Enables command to get data
int intYears = 0; // Declares intYears
double dblLoanAmount, dblInterestRate, interestRate, intRate;
if (command == year7InterestRateBtn) // Activates the 1st Loan Button
intYears = 0; // Sets 1st value of Array
if (command == year15InterestRateBtn) // Activates the 2nd Loan Button
intYears = 1; // Sets 2nd value of Array
if (command == year30InterestRateBtn) // Activates the 3rd Loan Button
intYears = 2; // Sets 3rd value of Array
if (command == btnCalc)
//dblLoanAmount = Double.parseDouble(txtTotalMort.getText() ); // Loan amount
//interestRate = Double.parseDouble(txtInterestRate.getText() ); // /100 )/ 12; // Devides rate
intRate = (Double.parseDouble(txtInterestRate.getText() )/100 )/ 12;
//int intYearsMonths = Integer.parseInt(txtYearsInput.getText() );// * 12; //Multiplies loan length
int months = Integer.parseInt(txtYearsInput.getText() )* 12;
dblLoanAmount = 0; // Declares and Initializes dblLoanAmount
dblInterestRate = 0; // Declares and Initializes dblInterestRate
double [][] dblTrmLoanRate = {{7, 5.35}, {15, 5.50}, {30, 5.75},}; // Array Data for Calculation
try
dblLoanAmount = Double.parseDouble(txtYears.getText()); // Gets user input from txtYears Text Field
catch (NumberFormatException nfe) // Checks for correct user input
JOptionPane.showMessageDialog(null, "You must enter a valid number.", "MPC", JOptionPane.INFORMATION_MESSAGE);
return;
interestRate = dblTrmLoanRate [intYears][1];
//dblInterestRate=interestRate;
intRate = (interestRate / 100) / 12; // Calculates Interst Rate
double intYearsMonths = dblTrmLoanRate [intYears] [0]; // Calculates Loan Term in Months
int months = (int)intYearsMonths * 12; // Devides by months
double interestRateMonthly = (intRate / 12); // Devides Rate
double payment = dblLoanAmount * intRate / (1 - (Math.pow(1/(1 + intRate), months))); // Calculates monthly payment
double dblRmnLoan = dblLoanAmount; //Left over balance
double txtPaymentInterest = 0; // Payment
double txtPaymentPrincipal = 0; // Payment of principal
NumberFormat currency = NumberFormat.getCurrencyInstance(Locale.US); // Curreny format
txtPayment.setText(currency.format(payment));
boxSpace.setText("Month\tPrincipal\tInterest\tBalance Left\n");
for (;months > 0 ; months -- )
txtPaymentInterest = (dblRmnLoan * intRate);
txtPaymentPrincipal = (payment - txtPaymentInterest); // Calculates monthly payment
dblRmnLoan = (dblRmnLoan - txtPaymentPrincipal);
boxSpace.setCaret (new DefaultCaret()); // Scroll position
boxSpace.append(String.valueOf(months) + "\t" + // Table data
currency.format(txtPaymentPrincipal) + "\t" +
currency.format(txtPaymentInterest) + "\t" +
currency.format(dblRmnLoan) + "\n");
if(command == reset)
Clears fields
txtYearsInput.setText(null);
txtInterestRate.setText(null);
txtYears.setText(null);
txtPayment.setText(null);
boxSpace.setText(null);
public static void main(String[] args) //This is the signature of the entry point of all the desktop apps
new MPC();
}This portion to be exact. All the buttons work for me except this one. I need to calculate user input and also use the fixed data that can be found in the dblTrmLoanRate array. When I choos to use user input instead, the program either crashes or for some reason uses the year7InterestRateBtn instead.
if (command == btnCalc)
//dblLoanAmount = Double.parseDouble(txtTotalMort.getText() ); // Loan amount
//interestRate = Double.parseDouble(txtInterestRate.getText() ); // /100 )/ 12; // Devides rate
intRate = (Double.parseDouble(txtInterestRate.getText() )/100 )/ 12;
//int intYearsMonths = Integer.parseInt(txtYearsInput.getText() );// * 12; //Multiplies loan length
int months = Integer.parseInt(txtYearsInput.getText() )* 12;
I was going to leave out the remed portion but thought it might help you with the navigation. I am sorry I did not use code tags, but I am going to go find out what those are and use them in the future. -
Need help with SQL Query (query for certain IDs in a table and then IDs not in result set)
OK. This is hard to explain but that may be my problem in constructing the query.
I have a table that has a list of jobs. The jobs information in this table, among other things, is a short description of the job itself (think "title" in phrase form), date, and ID.
So I can query the table to get all the jobs for a particular grouping of IDs (the only ones I am interested in) that ran successfully for a given time period. But what I want are all the jobs that did not succeed (or therefore are not present in the table) for this group of jobs and for a certain date range. But these are not the only job id's in the table.
To get the successful ones I do the following:
SELECT id,short_desc FROM my_table where
id IN('1230', '1231', '1232', '1239', '1244', '1245',
'1246', '1247', '1248', '1272', '1280', '1281', '1282',
'1283', '1284', '1285', '1286', '1249', '1250', '1251',
'1252', '1253', '1255', '1233', '1234', '1235', '1236',
'1237', '1238', '1256', '1257','1258', '1254', '1290','1310')
AND the_date > = SYSDATE - 23/24
AND to_char(the_date, 'DD-MON-YYYY') = TO_CHAR(CURRENT_DATE, 'DD-MON-YYYY')
I have tried to use another AND clause with NOT IN and the group or NOT EXISTS but that doesn't work as there are other jobs captured in this table with id's of course. I am only concerned with these id's:
IN('1230', '1231', '1232', '1239', '1244', '1245',
'1246', '1247', '1248', '1272', '1280', '1281', '1282',
'1283', '1284', '1285', '1286', '1249', '1250', '1251',
'1252', '1253', '1255', '1233', '1234', '1235', '1236',
'1237', '1238', '1256', '1257','1258', '1254', '1290','1310')
Someone said to use a temp table. I don't think I have permission and I haven't tried as I want to do this in one query if possible.
After thinking about this I am at a loss. I tried to do this in the front end but it just became too messy.You do not need a physical temp table. You need an in-line view:
WITH list as (
SELECT '1230' id FROM DUAL UNION ALL
SELECT '1231' FROM DUAL UNION ALL
SELECT '1232' FROM DUAL UNION ALL
SELECT '1239' FROM DUAL UNION ALL
SELECT '1244' FROM DUAL UNION ALL
SELECT '1245' FROM DUAL UNION ALL
SELECT '1246' FROM DUAL UNION ALL
SELECT '1247' FROM DUAL UNION ALL
SELECT '1248' FROM DUAL UNION ALL
SELECT '1272' FROM DUAL UNION ALL
SELECT '1280' FROM DUAL UNION ALL
SELECT '1281' FROM DUAL UNION ALL
SELECT '1282' FROM DUAL UNION ALL
SELECT '1283' FROM DUAL UNION ALL
SELECT '1284' FROM DUAL UNION ALL
SELECT '1285' FROM DUAL UNION ALL
SELECT '1286' FROM DUAL UNION ALL
SELECT '1249' FROM DUAL UNION ALL
SELECT '1250' FROM DUAL UNION ALL
SELECT '1251' FROM DUAL UNION ALL
SELECT '1252' FROM DUAL UNION ALL
SELECT '1253' FROM DUAL UNION ALL
SELECT '1255' FROM DUAL UNION ALL
SELECT '1233' FROM DUAL UNION ALL
SELECT '1234' FROM DUAL UNION ALL
SELECT '1235' FROM DUAL UNION ALL
SELECT '1236' FROM DUAL UNION ALL
SELECT '1237' FROM DUAL UNION ALL
SELECT '1238' FROM DUAL UNION ALL
SELECT '1256' FROM DUAL UNION ALL
SELECT '1257' FROM DUAL UNION ALL
SELECT '1258' FROM DUAL UNION ALL
SELECT '1254' FROM DUAL UNION ALL
SELECT '1290' FROM DUAL UNION ALL
SELECT '1310' FROM DUAL
SELECT l.id,
nvl(short_desc,'This job failed') short_desc
FROM my_table m
WHERE RIGTH JOIN
list
ON (
m.id = l.id
AND
the_date > = SYSDATE - 23/24
AND
the_date < TRUNC(SYSDATE) + 1
SY. -
Need help with SQL for selecting ID where the sequence does not match..
I have the following dilemma:
Database contains IDs as follows:
Incident#, Case#, & Part Sequence#
example
Record 1
Incident_Number = 123456
Case_Number = 1
Part_sequence = 1
Record 2
Incident_Number = 123456
Case_Number = 1
Part_sequence = 2
Sometimes the user will delete (let's say) Record 2 after creating a new Record 3
So now the sequencing goes as follows:
Record 1
Incident_Number = 123456
Case_Number = 1
Part_sequence = 1
Record 2
Incident_Number = 123456
Case_Number = 1
Part_sequence = 3
Now there will no longer be a Part_Sequence 2
Need a SQL to select all records where the maximum part sequence > than the count of Incident_number||'-'||Case_number
I tried the following:
select a.incident_number||'-'||a.case_number||'-'||a.part_sequence
from chsuser.a_compl_summary a
where a.entry_date >= '01-may-2011'
and max(a.part_sequence) > count(distinct a.incident_number||'-'||a.case_number)I end up getting a ORA-00934: group function is not allowed here (highlighting on the Max(a.part_sequence) portion.
Any suggestions/hints
Thanksselect incident_number || '-' || case_number || '-' || part_sequence
from (
select incident_number,
case_number,
part_sequence,
max(part_sequence) over(partition by incident_number,case_number) max_seq,
count(*) over(partition by incident_number,case_number) cnt
from chsuser.a_compl_summary
where entry_date >= DATE '2011-05-01'
where cnt != max_seq
/SY.
Maybe you are looking for
-
Why are my pictures being saved at 3.1mp to my camera roll?
I just baught iphoto for my new ipad and everything works great on it.....except for when i try to save my edited pictures to my camera roll.....the resolution for most of my pictures are 7.1 and 12 mp...and when they go through iphoto and save them
-
hi, i want to retrieve the no. of records available for 6 months period. if i am writing single query to retrieve data for 6 months, it's getting timed out in jsp. i am using java and jsp for this. so using function call, i want to retrieve the no. o
-
OID Users what DB table are they stored in
Ive just loaded 400+ users from AD into OID, what database table are these users stored in as I need to assign these users to a portal group and I dont want to do it manually. If I manually modify the password in oiddas for the migrated user then the
-
External swf within external swf?
Hello.. I'm currently playing with a music player template that loads the songs as external swf files. Is it now possible to load this music player as an external swf into my main flash website? So far I've managed to get it loading in the right plac
-
Why am I getting a blue screen during windows support software installation?
After intalling windows 7 x64 (using boot camp 5.1), when I come to install windows support software to set up apple drivers for windows to run on my MacBook pro (late 2013), after installing a good number of drivers, I get suddenly a blue screen!...