Help with SQL queries following migration
Hi there,
I have just migrated from MS SQL Server database to Oracle 10g database using the Oracle SQL Developer.
My application is using JDBC to access the database, and there are heaps of SQL statements that need to be verified and tested. I've found a number of SQL compatibility issues from my testing of the Oracle database and I hope you can help me the following.
1. Case sensitivity
Is it possible to not enforce case sensitivity (by default) when performing a select query?
If this is not possible, all the SQL statements will need to be changed to evaluate column based on uppercase.
2. Trailing white space
Is it possible to not evaluate trailing white space (by default) when performing a select query?
For example, suppose a table column studentNo has trailing spaces (after database migration), e.g. 'A182D '
when performing query - select * from student where studentNo = 'A182D'
no results can be found
3. Issue with Where condition containing with '' = ''
There are quite a number of SQL statements with Where condition containing '' = ''.
For example, the following SQL query doesn't return any results even though there are matching suburb that starts with 'ST'. These types of queries are mostly used in dynamic generated queries.
select * from Address where (suburb like 'ST%') and ('' = '' or country = '')
Any help or advice will be greatly appreciated.
Regards,
Jason Gordon
As justin mentioned setting those NLS parameters will make oracle not to use your regular index. for that you must create a function based index. See example below.
SQL> create index t_idx on t (name)
2 /
Index created.
SQL> exec dbms_stats.gather_table_stats(user,'T',cascade=>true)
PL/SQL procedure successfully completed.
SQL> explain plan for
2 select * from t where name = 'karthick'
3 /
Explained.
SQL> select * from table(dbms_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 2946670127
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 9 | 1 (0)| 00:00:01 |
|* 1 | INDEX RANGE SCAN| T_IDX | 1 | 9 | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - access("NAME"='karthick')
13 rows selected.
SQL> delete from plan_table
2 /
2 rows deleted.
SQL> alter session set NLS_COMP=ANSI;
Session altered.
SQL> alter session set NLS_SORT=BINARY_CI;
Session altered.
SQL> explain plan for
2 select * from t where name = 'karthick'
3 /
Explained.
SQL> select * from table(dbms_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 1601196873
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 9 | 5 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| T | 1 | 9 | 5 (0)| 00:00:01 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
1 - filter(NLSSORT("NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('6B61727
46869636B00') )
14 rows selected.
SQL> create index t_idx_1 on t(NLSSORT(name,'NLS_SORT=BINARY_CI'))
2 /
Index created.
SQL> exec dbms_stats.gather_table_stats(user,'T',cascade=>true)
PL/SQL procedure successfully completed.
SQL> /
create index t_idx_1 on t(NLSSORT(name,'NLS_SORT=BINARY_CI'))
ERROR at line 1:
ORA-00955: name is already used by an existing object
SQL> delete from plan_table
2 /
2 rows deleted.
SQL> explain plan for
2 select * from t where name = 'karthick'
3 /
Explained.
SQL> select * from table(dbms_xplan.display)
2 /
PLAN_TABLE_OUTPUT
Plan hash value: 2580036035
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 3 | 27 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T | 3 | 27 | 2 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | T_IDX_1 | 3 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access(NLSSORT("NAME",'nls_sort=''BINARY_CI''')=HEXTORAW('6B6172746869636B00') )Thanks,
Karthick.
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. -
Question: Need help with overcoming the following message: "Nothing was imported.
Need help with overcoming the following message: “Nothing was imported. The file(s) or folder(s) selection to import did not contain any supported file types, or the files are already in this catalogue”.
The photos being scanned are old film shots. They have NOT been previously scanned. I am using Photoshop Elements 9 software.
QUESTION: how do I override this STOP and or circumvent the photo comparison option????
Thanks for the help. Bob K --- [email protected]Are you scanning as jpeg, tiff or some other format?
Are you using continuous numbering for files names as by definition scanned files have no exif data.
-
Hi all,
I need a help with these queries, because is happening a strange problem when I try to execute it.
This first query is executed faster than the other one, around 30 minutes faster.
The queries are the same, but there is a single difference, I switch the hard code value '5.93218%' in a like condition by a variable P_COD_RAIZ || '%', because it can't be hard code.
SELECT max(oh.ohipp) as mesano_ultfatura
INTO V_MESANO_FATURA
FROM sysadm.orderhdr_all@dl_bsc oh,
customer_all@dl_bsc ca
WHERE ca.custcode like '5.93218%'
and ca.customer_id = oh.customer_id
and oh.ohipp = (select max(yy.ohipp)
from orderhdr_all@dl_bsc yy
where yy.customer_id = oh.customer_id
and oh.ohinvtype = 5);
SELECT max(oh.ohipp) as mesano_ultfatura
FROM sysadm.orderhdr_all@dl_bsc oh,
customer_all@dl_bsc ca
WHERE ca.custcode like P_COD_RAIZ || '%'
and ca.customer_id = oh.customer_id
and oh.ohipp = (select max(yy.ohipp)
from orderhdr_all@dl_bsc yy
where yy.customer_id = oh.customer_id
and oh.ohinvtype = 5);
What I want to know is, why the execution time of the second query is greater than the first, if the only difference between it is a variable instead of hard code?
Thanks,
Murilo.I assume column custcode is also varchar2. Then it looks like a problem with bind values and not evenly distributed data.
When you first run the query with the parameter = '5%' you may get many values and another execution plan as with '5.93218%' on a second run. However the execution plan is saved between the first and second run and not adopted to the new values.
There are ways out of this "bind" problem. But all have to do with providing us a good execution plan first.
However you can start by yourself with forcing the use of the index on the column custcode. -
Generate ER Diagram with Sql Queries ?
Hi Expertie,
I am new to Oracle Sql Developer Data Modeler.
I am having doubt in Oracle Sql Developer Data Modeler. Can we create ER Diagram with sql queries ?
Ex: select Ename, EAge, Eemail, ESalary, DDept, Dname, Estatus from Emp E join Dept D on E.EmpId = D.Empid
Where EAge in (20, 25, 30, 35)
Please provide me the answer and suggestion. It will be greatful for me.
Thanks & Regards
BhaskarYes, you can engineer your physical model to a logical one, then you'll have an ERD as well. It's a right-click on the model I believe.
To be more specific, if you relational model is loaded, you can use the button in the toolbar that looks like a double-blue-arrow, or you can mouse-right-click on your relational model in the tree. This will engineer your model to a logical one. You'll then have your ERD.
Edited by: Jeff Smith SQLDev PM on Apr 29, 2013 9:53 AM -
Links with sql queries to practice
Hi all,
Can someone give me the links with sql queries for practice to preparing for OCP
Thanks
Shekar.Hi,
Can u repost?? as its very difficult to understand ur problem.
Vasu Natari. -
Looking for a SQL report guru to help me with SQL queries
As an independent consultant, I sometimes need to build custom SSRS reports. I need someone I can reach out to when SQL queries become complex. There is such a query now.
Thanks.
Richgar
612-207-8347Thanks, Visakh,
I'm trying to determine which resources did not fill out a timesheet. The result of this query is missing just a few names and I can't find the reason. I'm thinking of a web meeting looking at real data is necessary and will be glad to pay
for the help.
SELECT
ResourceName, ResourceIsGeneric, ResourceType, RBS, ResourceIsActive
FROM
MSP_EpmResource_UserView
WHERE
(ResourceName NOT IN
(SELECT DISTINCT MSP_EpmResource_UserView_1.ResourceName
FROM
MSP_EpmResource_UserView AS MSP_EpmResource_UserView_1 INNER JOIN
MSP_TimesheetLine_UserView ON MSP_EpmResource_UserView_1.ResourceUID = MSP_TimesheetLine_UserView.ResourceUID INNER JOIN
MSP_Timesheet ON MSP_TimesheetLine_UserView.TimesheetUID = MSP_Timesheet.TimesheetUID
WHERE (MSP_EpmResource_UserView_1.ResourceType = 2) AND (MSP_EpmResource_UserView_1.ResourceIsActive = 1) AND (MSP_EpmResource_UserView_1.RBS IS NOT NULL) AND
(CONVERT(varchar, MSP_TimesheetLine_UserView.PeriodStartDate, 101) IN (@Period_Start_Date)) AND (MSP_EpmResource_UserView_1.RBS IN (@RBS)))) AND (ResourceIsGeneric = 0) AND
(ResourceType = 2) AND (RBS IN (@RBS)) AND (ResourceIsActive = 1) -
Issue with SQL converter: Query Migration Tool for Microsoft SQL Server to SAP HANA
Hello,
I found the following blog : http://scn.sap.com/community/business-one/blog/2013/04/10/how-to-convert-sql-from-ms-sql-server-to-sap-hana
I am trying out this migration tool for converting my MS SQL queries to HANA.
I am running into issue while converting certain queries.
The issue is specific to "set" commands which set local variables inside "create procedure" commands.
e.g.
a standalone set command:
SET @var = (SELECT TOP 1 name FROM mytable ORDER BY name)
is converted well:
SELECT (SELECT TOP 1 "name" FROM "mytable" ORDER BY "name") INTO var FROM DUMMY;
But when the same is part of create procedure:
CREATE PROCEDURE [dbx].[XXXXX_YYYY_ZZZZ]
AS
SET @var = (SELECT TOP 1 name FROM mytable ORDER BY name)
it fails in converting the same:
--Statements in the input file contain errors; conversion was canceled
I would like to understand who can help me here.
Thanks...Hi Mayur,
that tool cannot convert stored procedures. it is still being developed. For these you have to do it manually. -
Need help in SQL Queries using GUI controls or variables
Hello, all
I have a big problem (I have already had with Visual Basic a few mounths ago) with Java while writing my SQL Queries.
I would like to know how I must do to use variable data or GUI control data in my SQL Query to select only some records.
Here, my first Query that works without any problem (no WHERE clause !!!) :
Statement requeteBedes = connectBedes.createStatement();
ResultSet resultatSeries = requeteBedes.executeQuery("SELECT * FROM Series");
initComboBoxSeries(resultatSeries);the method "initComboBoxSeries" fills a JComboBox with all the names of the series in my database.
Here comes my problem.I would like to use the value of the selected "series" in the JComboBox to search in another table of the same Database. I made another statement but it returns a Null ResultSet :
ResultSet resultatSearchAlbumsFromSeries = requeteBedes.executeQuery("SELECT * FROM bandes_dess WHERE ser_nom = '" + strComboBoxSeriesSelected + "' "); The variable strComboBoxSeriesSelected contains the value of the selected line in the combobox with all the series, filled after the first query that is here above and that works very well.
Could some one help me and tell me how I must use variables or GUI controls values in my SQL Queries or tell me if there is a place where I could find an explanation of that kind of problems (like more "advanced SQL Queries", as the ones currently used in all the Learning Java 2 books)
Thank you all for your help.
Christian.executeQuery() will never return null. At least that's what the spec says. You are probably catching an exception (probably a syntax error caused by a single quote in strComboBoxSeriesSelected) and ignoring it. Or do you mean the ResultSet contains no rows?
Anyway, to use parameterized queries, take a look at PreparedStatements. Your code should look like this using PreparedStatement:Statement requeteBedes = connectBedes.prepareStatement("SELECT * FROM bandes_dess WHERE ser_nom = ?");
requeteBedes.setString(1, strComboBoxSeriesSelected);
ResultSet resultatSeries = requeteBedes.executeQuery();Alin. -
Please help with SQL amount calulation
-- Results
with t as (
select 'P11877' Mstr_Program, 1 Year_of_study, 'BUSI1490' program_module, 20 no_of_stud, 1 rank, 30 program_credits, 30 cumm_credits from dual union all
select 'P11877', 1, 'COMP1365', 20, 2, 30, 60 from dual union all
select 'P11877', 1, 'BUSI1375', 20, 3, 30, 90 from dual union all
select 'P11877', 1, 'COMP1363', 20, 4, 30, 120 from dual union all
select 'P11877', 2, 'MARK1174', 8, 1, 30, 30 from dual union all
select 'P11877', 2, 'FINA1068', 8, 2, 15, 45 from dual union all
select 'P11877', 2, 'INDU1062', 8, 3, 30, 75 from dual union all
select 'P11877', 2, 'BUSI1329', 8, 4, 15, 90 from dual union all
select 'P11877', 2, 'MARK1138', 8, 5, 30, 120 from dual)
select * from t;-- Each MSTR_PROGRAM can have 1 or many program_module
-- MSTR_PROGRAM's can run for 1 or 2 years (case above is two years) so some modules run in year 1 and some in year 2
-- NO_OF_STUD is the number of students on the module
-- RANK basically ranks the modules by the number of students on them grouped by program and year
-- e.g.row_number() OVER (PARTITION BY Mstr_Program, Year_of_study) ORDER BY COUNT(STUDENT_ID) DESC) rank
-- PROGRAM_CREDITS: each module has a fixed number of credits
-- CUMM_CREDITS: Increments the credit count of modules
-- SUM(program_credits * 10) OVER (PARTITION BY Mstr_Program, Year_of_study
-- ORDER BY count(STUDENT_ID) desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
-- I want to trim of any modules once the CUM_CREDITS hits 120. As seen above. I achieve this by wrapping the main query is another SELECT then LIMIT
-- that WHERE cum_credit <=120.
-- But what I need is:
-- In some cases the the cumm_credit maybe on lets say 90credits then the next module is worth 40 credits. This next module will not show as it
-- will be greater than 120 credits, so i need to pro-rata it:
-- So if credit_count > 120, then the last module is counted pro-rata as follows: 1- ((credit count - 120) / credits from last module
-- Can anyone help with how I can incorporate this into my current code: The SELECT portion of the Original SQL is below: I simplified column names
-- e.t.c in the above so they wont be the same
SELECT * FROM (
SELECT
,SR_PROGRAM Mstr_Program
,DECODE (SORLCUR_YEAR, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR) year_of_study
,SCT_SUBJ_CODE||SCT_CRSE_NUMB program_module
,COUNT(student_ID) no_of_stud
,row_number() OVER (PARTITION BY sr_program,
DECODE (sr_year, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR) ORDER BY COUNT(student_id) DESC, scbcrse_title asc) rank
,(SCT_CREDIT_HRS * 10) program_credits
,SUM(SCT_CREDIT_HRS * 10) OVER (PARTITION BY sr_program, DECODE (sorlcur_year, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR)
ORDER BY count(student_id) desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
WHERE cumm_credit <=120
ORDER BY Mstr_Program, YEAR_OF_STUDY, RANK asc;Maybe
SELECT Mstr_Program,year_of_study,program_module,no_of_stud,rank,program_credits old_program_credits,cumm_credits old_cumm_credits,
case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end new_program_credits,
case when cumm_credits > 120
then 120
else cumm_credits
end new_cumm_credits
FROM (SELECT SR_PROGRAM Mstr_Program,
DECODE(SORLCUR_YEAR,1,1,2,2,3,3,4,3,SR_YEAR) year_of_study,
SCT_SUBJ_CODE||SCT_CRSE_NUMB program_module,
COUNT(student_ID) no_of_stud,
row_number() OVER (PARTITION BY sr_program,DECODE(sr_year,1,1,2,2,3,3,4,3,SR_YEAR)
ORDER BY COUNT(student_id) DESC,scbcrse_title) rank,
10 * SCT_CREDIT_HRS program_credits,
10 * SUM(SCT_CREDIT_HRS) OVER (PARTITION BY sr_program,DECODE(sorlcur_year,1,1,2,2,3,3,4,3,SR_YEAR)
ORDER BY count(student_id) desc
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
WHERE 0 <= case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end
ORDER BY Mstr_Program,YEAR_OF_STUDY,RANKRegards
Etbin
Edited by: Etbin on 16.12.2011 8:50
with
t as /* simulating the result achieved */
(select 'P11877' Mstr_Program,1 Year_of_study, 'BUSI1490' program_module,20 no_of_stud,1 rank,30 program_credits,30 cumm_credits from dual union all
select 'P11877', 1, 'COMP1365', 20, 2, 40, 70 from dual union all
select 'P11877', 1, 'BUSI1375', 20, 3, 30, 100 from dual union all
select 'P11877', 1, 'COMP1363', 20, 4, 40, 140 from dual union all
select 'P11877', 2, 'MARK1174', 8, 1, 30, 30 from dual union all
select 'P11877', 2, 'FINA1068', 8, 2, 50, 80 from dual union all
select 'P11877', 2, 'INDU1062', 8, 3, 30, 110 from dual union all
select 'P11877', 2, 'BUSI1329', 8, 4, 50, 160 from dual union all
select 'P11877', 2, 'MARK1138', 8, 5, 30, 190 from dual
select Mstr_Program,Year_of_study,program_module,no_of_stud,rank,program_credits old_credits,cumm_credits old_cumm,
case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end new_program_credits,
case when cumm_credits > 120
then 120
else cumm_credits
end new_cumm_credits
from t
where 0 <= case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end -
Where clause "where 1=1" help with SQL tuning
Hello Tuning experts,
Is it helpful to use "where 1=1" and then put all the joins and conditions in the "AND" statements of the SQL when writing SQL queries. I would like to know if it helps with query performance to write SQL queirs that way.
Thanks in advance.
Edited by: oracle_developer on Oct 8, 2012 10:41 AMYou can see here that "where 1 = 1" is gone from the predicate info in the explain plan.
The optimizer simply discarded it.
SQL> explain plan for
2 select *
3 from emp
4 where 1 = 1
5 and job = 'SALESMAN';
Explained.
PLAN_TABLE_OUTPUT
Plan hash value: 3956160932
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 3 | 114 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| EMP | 3 | 114 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("JOB"='SALESMAN')
13 rows selected. -
Where to find help with SQL Developer installation?
Hi,
I just want to try out SQL Developer and compare its capabilities to TOAD's. Unfortunately, I am not PC software savvy and now am stuck with a SQL Developer (sqldeveloper-1.2.2998) installation problem. When I clicked on the .exe file, I got a blank SQL Developer screen - there is nothing in the screen except a heading that reads 'Oracle SQL Developer'...
Does anyone know of a blog or a site that I can get some help with problems like mine?
Any help is much appreciated!Hi,
SQL Developer forum link:
"http://forums.oracle.com/forums/forum.jspa?forumID=260"
There are 2 versions of SQL Developer, with/without JRE.
Try out the full install version with JRE.
HTH
Zack -
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 PrusinskiHi 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
) -
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 ; -
Help with SQL Server 2005 http Endpoint
I am trying to use mx:webservice to directly connect to a SQL
Server 2005 HTTP Endpoint. Is this possible. Is there going to be a
problem with crossdomain issues? If the Endpoint is actively
listening on port 80 then IIS cannot. So I cannot place
crossdomain.xml in webserver, how will I overcome this crossdomain
problem? Am I making this more complicated than it is? If anyone
has an example it would be appreciated. All I want is a flex2 app
talking directly to sql server. Seems possible.Kent, I see that many others have reported that error (doing
a google search), but I see no ready answers. I saw something that
reminded me of a connection string value that I've seen answer some
problems. May be worth a shot for you: try adding this string to
the connection string (in "advanced options") for your datasource:
AuthenticationMethod=Type2
If it doesn't solve it, remove it. But keep it handy in case
it ever may help with some other problem.
Here's one other possible answer for you:
http://www.webmasterkb.com/Uwe/Forum.aspx/coldfusion-server/3206/SQL-Server-2000-Windows-A uth
Sorry I can't be more clear for you.
Maybe you are looking for
-
Continuous play of items in playlist
When I play a song or video from a playlist, Apple TV plays the song or video and then goes back to the menu. What do I have to do for all the songs or videos to play one after the other continuously, like they do on my iPod?
-
Adding music to iPod Shuffle PROBLEM!!!
ok... when i try to put a music on my iPod Shuffle with iTunes after like 5~10 music the iPod just disconect from my pc and keep doing this all the time anyone know how to fix that?
-
C4700 installed ;Get rid of black box on screen??
Installed printer, it works fine. Can't get rid of black box panel on left side of computer screen;says clip book on top. So can't see left half of websites or email. Also dragging box over to print doesn't go out of panel.
-
This content is not authorized, message in my rentals,and purchased Series and Movies
I keep geting this message, This content is not authorized, on my series and movies
-
Hi All after i installed an firewire-usb-hub my macmini doesn't startup. i deinstalled the hub but nothing going on. after press the power-button the startsound play and then the grey bootdisplay but no loadersymbol. please can someone help me? thank