last day (17 days later) » 
17:00 - 22:0022:00 - 23:00

5:18 PM
0
Q: Oracle SQL query taking too long like 60 minutes to execute

Jiten KI have one query that taking too long, that is 60 minutes. I am programmer but i am not quite sure if all the table are indexes out. here is the query, any table that ends with _V is view: SELECT prod_eff.facility , prod_eff.product , (SELECT MIN (cbv1.bucket_header) FROM ...

 
Show us the execution plan.
 
i am not sure what do u mean? I went through each query inside view and check whether it is indexed or not? but I am confused what is difference between dba_indexes and user_indexes
 
Indexes don't increase performance of your application magically, Oracle doesn't use it if the way without the index is faster. At first you have to gather the statistics‌​‌​, secondly generate an explain plan, finally, show is the explain plan
@Mihai I guess it is not enough, I think the author hasn't gathered any statistics at all. And when you execute the explain plan for... you have to use DBMS_XPLAN to get the plan.
 
I am sorry I am newbie in database thing. I only know basic thing like sql join and writing basic queries. Any help would be appreciate.
Updated with execution plan, please see my original post.
 
@JitenK Have you gathered statistics? I see nothing that damages your performance
 
5:18 PM
@zaratustra I am not sure how to do - gathered statistics ? can you please guide me or point me on how to do it? I am happy to provide information in order to tweak that sql query to not take much time.
 
@zaratustra which one you like me to run? exec dbms_stats.gather_schema_stats('SCOTT',DBMS_STATS.AUTO_SAMPLE_SIZE); exec dbms_stats.gather_schema_stats(ownname=>'SCOTT', estimate_percent=>DBMS_STATS.AUTO_SAMPLE_SIZE); exec dbms_stats.gather_schema_stats(ownname => 'SCOTT', estimate_percent => 25); exec dbms_stats.gather_table_stats('SCOTT', 'EMPLOYEES'); exec dbms_stats.gather_index_stats('SCOTT', 'EMPLOYEES_PK'); exec dbms_stats.delete_schema_stats('SCOTT'); after running one, i see this result but nothing happen --> anonymous block completed
 
execute this dbms_stats.gather_table_stats('SCHEMA_OR_USER_WHO_IS_OWNER_OF_THE_TABLES', 'TABLE_NAME_IN_CAPITAL_CASE'); for each of your tables. I suppose, the owner/user/schema is AMD_OARS use it.
 
@zaratustra when i ran this --> exec dbms_stats.gather_table_stats('AMD_OARS', 'TEMP_SELECTED_PRODUCT'); i got this result --> anonymous block completed
hi
 
hi
exec dbms_stats.gather_table_stats('AMD_OARS', 'TEMP_SELECTED_PRODUCT');
run it for other tables
 
5:22 PM
i got this --> anonymous block completed
i dunno why i keep getting this and not result
 
it is ok
keep running
 
i found out that column --> EFF_START_DATETIME and EFF_END_DATETIME is not index, do u think if i can index it, it will ran faster?
 
it depends on your data
 
when i ran this
select * from DBA_IND_COLUMNS ba where ba.TABLE_OWNER = 'AMD_OARS' and ba.TABLE_NAME = 'BOM_PRODUCT_FACILITY' order by ba.TABLE_OWNER, ba.TABLE_NAME, ba.COLUMN_NAME;
i saw only the following are indexed
FACILITY
PRODUCT
VERSION_ID
 
forget about indexes now
 
5:23 PM
but not
EFF_START_DATETIME DATE
EFF_END_DATETIME DATE
ok
but what these command do? --> exec dbms_stats.gather_table_stats('AMD_OARS', 'TEMP_SELECTED_PRODUCT');
it only showing me ---> anonymous block completed <-- as output
 
it's ok
it gathers the statistics
 
ok
how can i show u statistics now?
 
it shows the optimizer about the data you have
for example it's bad to use index if your table has only one row, full table scan will be completed faster
 
ok
 
or if you have 10M rows probably it is a good idea to use index
 
5:26 PM
what is the next step u want me to do now?
 
did you gather the statistics for all your tables you use in the query?
 
nothing shows on output except --> anonymous block completed after i ran this --> exec dbms_stats.gather_table_stats('AMD_OARS', 'TEMP_SELECTED_PRODUCT');
:(
 
one more time: anonymous block completed is good
TEMP_SELECTED_PRODUCT
is it a temp table?
 
ok i did
let me check
 
is CURRENT_BUCKETS_V a view?
 
5:29 PM
its regular table under table --> TEMP_SELECTED_TABLE
yes
 
"table under table", what do you mean ?
 
it is view
 
is CURRENT_BUCKETS_V a view based on the table TEMP_SELECTED_PRODUCT?
 
on sql developer on left side when i expand 'Tables (filtered') i see --> TEMP_SELECTED_PRODUCT
 
5:30 PM
no
here is the view
 
what icon do you see?
 
CREATE OR REPLACE FORCE VIEW "AMD_OARS"."CURRENT_BUCKETS_V" ("VERSION_ID", "BUCKET_ID", "BUCKET_NAME", "FISCAL_YEAR", "FISCAL_BUCKET", "BUCKET_HEADER", "MIN_DATETIME", "MAX_DATETIME") AS
SELECT cb.version_id, cb.bucket_id, cb.bucket_name, cb.fiscal_year,
cb.fiscal_bucket,
calendar_pkg.bucket_header (cb.bucket_name,
cb.fiscal_year,
cb.fiscal_bucket
) bucket_header,
cb.min_datetime, cb.max_datetime
FROM temp_current_buckets cb
;
 
is temp_current_buckets a temp table?
 
here is the screenshot, this is how the icon look like
 
yes, this is temp tables
the version table is not a temp table
ok
 
5:32 PM
ok
 
how do you fill this temp tables?
how many records are in them?
 
which ?
them which?
 
these temp tables
 
select count(*) from TEMP_SELECTED_PRODUCT
0
 
for example, how do you fill the temp_current_buckets table
 
5:35 PM
let me check the code
 
how many records does the temp_current_buckets table have?
forget it for now
 
ok
 
exclude
(SELECT MIN (cbv1.bucket_header)
FROM AMD_OARS.CURRENT_BUCKETS_V cbv1
WHERE cbv1.version_id = 1
AND cbv1.min_datetime >= prod_eff.EFF_START_DATETIME
) min_eff
, (SELECT MAX (cbv1.bucket_header)
FROM AMD_OARS.CURRENT_BUCKETS_V cbv1
WHERE cbv1.version_id = 1
AND cbv1.min_datetime < prod_eff.EFF_END_DATETIME
) max_eff
from your query
then run explain plan for ...
 
ok hang on
 
and show the result
 
5:37 PM
select count(*) from temp_current_buckets
0
hang on please
try to fix that error
Error starting at line : 1 in command -
EXPLAIN PLAN FOR
SELECT prod_eff.facility,
prod_eff.product,
1 valid
FROM
(SELECT pf.product,
pf.facility,
pf.eff_start_datetime,
pf.eff_end_datetime
FROM AMD_OARS.BOM_PRODUCT_FACILITY pf,
AMD_OARS.MASTER_FACILITY f
WHERE pf.version_id = 114847
AND pf.facility = f.facility
AND f.facility != 'NONE'
AND f.validated = 1
) prod_eff,
AMD_OARS.TEMP_SELECTED_PRODUCT tsp
WHERE tsp.product = prod_eff.product
AND (prod_eff.EFF_START_DATETIME BETWEEN to_timestamp('07/27/2014
 
execute it without the "explain plan for" section
I can't see the error
 
still same error
ORA-01785: ORDER BY item must be the number of a SELECT-list expression
01785. 00000 - "ORDER BY item must be the number of a SELECT-list expression"
*Cause:
*Action:
Error at Line: 22 Column: 145
Plan hash value: 2398229158

------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 78 | 3 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 1 | 78 | 3 (0)| 00:00:01 |
here it is
 
now I see
 
ok
i have to remove order by to make it work
here is the query
EXPLAIN PLAN FOR
SELECT prod_eff.facility,
prod_eff.product,
1 valid
FROM
(SELECT pf.product,
pf.facility,
pf.eff_start_datetime,
pf.eff_end_datetime
FROM AMD_OARS.BOM_PRODUCT_FACILITY pf,
AMD_OARS.MASTER_FACILITY f
WHERE pf.version_id = 114847
AND pf.facility = f.facility
AND f.facility != 'NONE'
AND f.validated = 1
) prod_eff,
AMD_OARS.TEMP_SELECTED_PRODUCT tsp
WHERE tsp.product = prod_eff.product
AND (prod_eff.EFF_START_DATETIME BETWEEN to_timestamp('07/27/2014
00:00:01.000', 'mm/dd/yyyy hh24:mi:ss.ff3') AND to_timestamp('12/20/2015 00:00:00.000', 'mm/dd/yyyy
 
i forgot to remove the comma in the order clause
at the end
 
5:45 PM
ok
 
write order by 1, 2
that's it
3 and 4 remove
 
ok hang on
 
and then execute the query
 
Plan hash value: 2398229158

------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 78 | 3 (0)| 00:00:01 |
| 1 | NESTED LOOPS | | 1 | 78 | 3 (0)| 00:00:01 |
 
if it works run the explain plan for select ...
 
5:47 PM
yes it did
 
ok
how many seconds did it take?
to execute
without the explain plan section
 
problem is there are no data, application run, put data run query then deletes it
:(
so i cannot analyse it that way
but my co-worker telling me to index date columns
date columns are not indexed
and that table BOM_PRODUCT_FACILITY have 500k rows
 
ok, if you can't run it outside of the application change your query, this part
SELECT prod_eff.facility
, prod_eff.product
, (SELECT MIN (cbv1.bucket_header)
FROM AMD_OARS.CURRENT_BUCKETS_V cbv1
WHERE cbv1.version_id = 1
AND cbv1.min_datetime >= prod_eff.EFF_START_DATETIME
) min_eff
, (SELECT MAX (cbv1.bucket_header)
FROM AMD_OARS.CURRENT_BUCKETS_V cbv1
WHERE cbv1.version_id = 1
AND cbv1.min_datetime < prod_eff.EFF_END_DATETIME
) max_eff
, 1 valid
FROM (
to this
SELECT prod_eff.facility
, prod_eff.product
, 0 min_eff
, 0 max_eff
, 1 valid
FROM (
temporary
I want to find out where the problem is, if rewritten query works fast then you have the problem with your temp tables
 
ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
*Cause:
*Action:
Error at Line: 20 Column: 4
 
if it still works slowly then you will add the index
find out where you added excessive the left parenthesis
 
5:53 PM
all rows fetched: 0 in 0.034 seconds
SELECT prod_eff.facility
, prod_eff.product
, 0 min_eff
, 0 max_eff
, 1 valid
FROM (SELECT pf.product,
pf.facility,
pf.eff_start_datetime,
pf.eff_end_datetime
FROM AMD_OARS.BOM_PRODUCT_FACILITY pf,
AMD_OARS.MASTER_FACILITY f
WHERE pf.version_id = 114847
AND pf.facility = f.facility
AND f.facility != 'NONE'
AND f.validated = 1
) prod_eff,
AMD_OARS.TEMP_SELECTED_PRODUCT tsp
WHERE tsp.product = prod_eff.product
AND (prod_eff.EFF_START_DATETIME BETWEEN to_timestamp('07/27/2014
00:00:01.000', 'mm/dd/yyyy hh24:mi:ss.ff3') AND to_timestamp('12/20/2015 00:00:00.000', 'mm/dd/yyyy
i ran this
there is no data
 
yes
I want you to run it from your application
because somehow you fill you temp tables
 
ok for that i need to comment out old code, put that new code deploy war file in dev and run it
give me time please
 
I guess you have to reconsider your app's architecture, it is not very well when you run queries directly from your code, if I were you I would make it a view and make my code execute the query from the view
 
well but some of the params are passing thru variable so thats why i cannot make views :(
 
of course, you can write a pipelined function and pass the params there
 
6:01 PM
let me check
views run faster then query?
 
I will be unavailable for about one hour
 
views run faster then regular query via jdbc ?
ok
 
yes
because views are parsed already
 
i see
what if views run slow just like regular jdbc then?
 
Do you use java in your development?
Why don't you use a hot swap?
it's a built-in feature, so you don't have to redeploy your app constantly
 
6:13 PM
its long story
i can do hot swap
INFO [15 Aug 2014 13:12:16,353 jdbc.sqltiming]: SELECT prod_eff.facility, prod_eff.product, 0 min_eff, 0 max_eff, 1 valid FROM (SELECT pf.product,
pf.facility, pf.eff_start_datetime, pf.eff_end_datetime FROM AMD_OARS.BOM_PRODUCT_FACILITY
pf, AMD_OARS.MASTER_FACILITY f WHERE pf.version_id = 115013 AND pf.facility = f.facility AND
f.facility != 'NONE' AND f.validated = 1) prod_eff, AMD_OARS.TEMP_SELECTED_PRODUCT tsp WHERE
tsp.product = prod_eff.product AND (prod_eff.EFF_START_DATETIME between to_timestamp('07/27/2014
it took 56 msec
that mean i do not need to index these columns?
and do views instead?
?
 
7:01 PM
you are completely right
let's look at the columns we exclude
show me this procedure calendar_pkg.bucket_header
make sure you don't have other procedures with the same name
I am interested in only the procedure you use to create the CURRENT_BUCKETS_V view
I guess you can rewrite your query like this
SELECT prod_eff.facility
, prod_eff.product
, (SELECT MIN (cbv1.bucket_header)
FROM temp_current_buckets cbv1
WHERE cbv1.version_id = 1
AND cbv1.min_datetime >= prod_eff.EFF_START_DATETIME
) min_eff
, (SELECT MAX (cbv1.bucket_header)
FROM temp_current_buckets cbv1
WHERE cbv1.version_id = 1
AND cbv1.min_datetime < prod_eff.EFF_END_DATETIME
) max_eff
, 1 valid
FROM
(SELECT pf.product
, pf.facility
, pf.eff_start_datetime
, pf.eff_end_datetime
FROM AMD_OARS.BOM_PRODUCT_FACILITY pf
, AMD_OARS.MASTER_FACILITY f
It won't work, you don't have bucket_header yet
Try this:
SELECT prod_eff.facility
, prod_eff.product
, (SELECT MIN (calendar_pkg.bucket_header (cbv1.bucket_name,cbv1.fiscal_year,cbv1.fiscal_bucket))
FROM temp_current_buckets cbv1
WHERE cbv1.version_id = 1
AND cbv1.min_datetime >= prod_eff.EFF_START_DATETIME
) min_eff
, (SELECT MAX (calendar_pkg.bucket_header (cbv1.bucket_name,cbv1.fiscal_year,cbv1.fiscal_bucket))
FROM temp_current_buckets cbv1
WHERE cbv1.version_id = 1
AND cbv1.min_datetime < prod_eff.EFF_END_DATETIME
) max_eff
, 1 valid
FROM
 
7:22 PM
meaning
change the query?
ORA-00904: "PROD_EFF"."PRODUCT": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 2 Column: 3
what the new query?
let me test with indexing on
hang on please
if indexing one does not work then i will use your query
 
Indexes can't improve your performance magically
 
how will your query improve performance?
can you please explain?
 
I don't know it for sure
Show me the calendar_pkg.bucket_header function
 
ok hang on
CREATE OR REPLACE FORCE VIEW "AMD_OARS"."CURRENT_BUCKETS_V" ("VERSION_ID", "BUCKET_ID", "BUCKET_NAME", "FISCAL_YEAR", "FISCAL_BUCKET", "BUCKET_HEADER", "MIN_DATETIME", "MAX_DATETIME") AS
SELECT cb.version_id, cb.bucket_id, cb.bucket_name, cb.fiscal_year,
cb.fiscal_bucket,
calendar_pkg.bucket_header (cb.bucket_name,
cb.fiscal_year,
cb.fiscal_bucket
) bucket_header,
cb.min_datetime, cb.max_datetime
FROM temp_current_buckets cb
;
 
this is the CURRENT_BUCKETS_V view
I need the function
that returns you a header
 
7:37 PM
hang on please
im looking sql of TEMP_CURRENT_BUCKETS
it say generating DDL ... (Running)
 
не нужно мне это
i don't need it
 
?
 
sorry
 
how to get function though?
 
I used my native language with no intention
Do you use SQL Developer?
 
7:39 PM
yes
 
At the panel
 
oracle sql developer
 
where you look at the tables
there is the section packages
find it
 
hang on please
 
then find the calendar_pkg package
and Double click on it
 
7:41 PM
cannot see section package
let me do share screen
 
hold on
 
ok
 
click on it
can you see the tables?
 
yes
u want me to do insert on that too?
 
there are views, then indexes and then packages
This I meant when I told you to look for the package section
can you see it?
 
7:44 PM
create or replace PACKAGE calendar_pkg
IS
FUNCTION magna
RETURN NUMBER;

PRAGMA RESTRICT_REFERENCES (magna, WNDS, WNPS, RNDS, RNPS);

FUNCTION zero
RETURN NUMBER;

PRAGMA RESTRICT_REFERENCES (zero, WNDS, WNPS, RNDS, RNPS);

FUNCTION seconds_in_day
RETURN PLS_INTEGER;

PRAGMA RESTRICT_REFERENCES (seconds_in_day, WNDS, WNPS, RNDS, RNPS);

PROCEDURE populate_current_buckets (
in_vid IN VERSION.version_id%TYPE,
in_pm_name IN period_manager.pm_name%TYPE,
in_horizon_start_datetime IN VERSION.version_timestamp%TYPE
this one?
 
FUNCTION bucket_header (
in_bucket_name IN VARCHAR2,
in_fiscal_year IN NUMBER,
in_fiscal_bucket IN NUMBER
)
RETURN VARCHAR2;
this I was looking for
 
ok
 
but I need to see the code if this procedure
let me figure out how to open it
 
ok
 
can you click right-mouse on it? is there any context menu?
 
7:46 PM
no
 
"on it" I meant on the proceudre
put your cursor on the bucket_header word and click right mouse
 
create or replace PACKAGE BODY calendar_pkg
IS
c_seconds_in_minute CONSTANT PLS_INTEGER := 60;
c_minutes_in_hour CONSTANT PLS_INTEGER := 60;
c_hours_in_day CONSTANT PLS_INTEGER := 24;
c_days_in_week CONSTANT PLS_INTEGER := 7;
c_fiscal_day_str CONSTANT VARCHAR2 (3) := 'DAY';
c_fiscal_week_str CONSTANT VARCHAR2 (11) := 'FISCAL_WEEK';
c_fiscal_month_str CONSTANT VARCHAR2 (12) := 'FISCAL_MONTH';
c_fiscal_quarter_str CONSTANT VARCHAR2 (14) := 'FISCAL_QUARTER';
this one?
 
yes, let me see
Ok, I will rewrite your query
hold on for a while
10 min I guess
 
ok
if you want to see anything i can share my screen
 
I don't need it so far
 
7:53 PM
ok
this is the code
public IQuerySet extract(Connection conn, IVersionHandler scenarioVersions,
PlanningCalendar planningCalendar) throws Exception, IOException {
int bucketVersion = getCalendar( planningCalendar );

PreparedStatement ps = null;

int dataVersion = scenarioVersions.getVersion( conn, LoadType.BOM_CONNECTION );


Timestamp horizonStart = DBDataUtil.getFirstBucketExclusiveBound(conn,bucketVersion);
Timestamp horizonEnd = DBDataUtil.getStartofLastHorizonBucket(conn,bucketVersion);

String sql =
" SELECT prod_eff.facility, prod_eff.product, " +
 
ok, thanks
 
that generate the query
 
8:17 PM
Try this:
with t as (
SELECT cb.bucket_name, cb.fiscal_year,cb.fiscal_bucket, cb.version_id, cb.min_datetime
, case
when cb.bucket_name = 'DAY' --fiscal_day_str
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'D'|| LPAD (TO_CHAR (cb.fiscal_bucket), 3, '0')
when cb.bucket_name = 'FISCAL_WEEK'
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'W' || LPAD (TO_CHAR (cb.fiscal_bucket), 2, '0')
when cb.bucket_name = 'FISCAL_MONTH'
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'M' || LPAD (TO_CHAR (cb.fiscal_bucket), 2, '0')
but at first try to run it from SQL Developer
to find out if there are some syntax errors
 
this query look longer then before
where do i need to put
in my code?
starting statement is --> with t as (
 
did you check?
Are there some errors?
 
yes
 
show me
 
wait no error
i ran it
 
8:24 PM
ok
add it to your code
 
only add this part before my code start?
with t as (
SELECT cb.bucket_name, cb.fiscal_year,cb.fiscal_bucket, cb.version_id, cb.min_datetime
, case
when cb.bucket_name = 'DAY' --fiscal_day_str
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'D'|| LPAD (TO_CHAR (cb.fiscal_bucket), 3, '0')
when cb.bucket_name = 'FISCAL_WEEK'
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'W' || LPAD (TO_CHAR (cb.fiscal_bucket), 2, '0')
when cb.bucket_name = 'FISCAL_MONTH'
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'M' || LPAD (TO_CHAR (cb.fiscal_bucket), 2, '0')
when cb.bucket_name = 'FISCAL_QUARTER'
 
start with this --> with t as (
 
yes i did
 
no, you have to change
SELECT MIN (calendar_pkg.bucket_header (cbv1.bucket_name,cbv1.fiscal_year,cbv1.fiscal_bucket))
FROM temp_current_buckets cbv1
to
SELECT MIN (bucket_header)
FROM t cbv1
the same for the max
 
oh i see
let me make changes to my code
 
8:26 PM
add the with part and change table name in max and min
ok
 
if it work, i will give you my points too :)
yes i have to modify the code
 
8:48 PM
running the code now, hang on please
 
got error
java.sql.SQLException: Invalid column index
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.OraclePreparedStatement.setTimestampInternal(OraclePreparedStatement.java:7606)
at oracle.jdbc.driver.OraclePreparedStatement.setTimestamp(OraclePreparedStatement.java:7580)
at net.sf.log4jdbc.PreparedStatementSpy.setTimestamp(PreparedStatementSpy.java:987)
its suppose to be cb instead of cbv right?
 
hold on
show me the code
 
@Override
public IQuerySet extract(Connection conn, IVersionHandler scenarioVersions,
PlanningCalendar planningCalendar) throws Exception, IOException {
int bucketVersion = getCalendar( planningCalendar );

PreparedStatement ps = null;

int dataVersion = scenarioVersions.getVersion( conn, LoadType.BOM_CONNECTION );


Timestamp horizonStart = DBDataUtil.getFirstBucketExclusiveBound(conn,bucketVersion);
Timestamp horizonEnd = DBDataUtil.getStartofLastHorizonBucket(conn,bucketVersion);

String sql =
 
java code
 
8:58 PM
yes
 
Can you debug this code?
Can you use a debugger tool?
 
i don't think so
where this point to --> FROM t cbv1
cbv1 ?
 
it was your alias
I left it
I mean, I keep it
 
look at the code
i removed that alias
 
show me the line you removed it
 
9:01 PM
oh i got it
t point to your beginning code
i got it
 
If you can execute this query from SQL Developer there is not problems with the query I guess
We need to investigate java code
 
yes i can execute this query from sql developer fine
 
replace the end of your method
to this
ps.setTimestamp(4, horizonEnd);
IQuerySet iQuerySet = DBUtil.retrieveResults( conn, ps );
System.out.println("111111111111111111\t" + iQuerySet);
return iQuerySet
}
and run again
if you see the output (it will be easy to find by the "1111111" string) then the query executes well
missed the column at the end of the return line
return iQuerySet;
 
yeah
hang on
let me deploy again
 
you definitely have to try Idea or eclipse, It will increase your speed in 100x times
 
9:10 PM
ok
hang on
i am using eclipse, reason i cannot debug is because it is using very old version of grails
which does not exist
 
running the code again
2014-08-15 16:23:28,265 [INFO] com.amd.oars.db.DBUtil .prepareStatement, ** SQL=with t as ( SELECT cb.bucket_name, cb.fiscal_year,cb.fiscal_bucket, cb.version_id, cb.min_dat
etime , case when cb.bucket_name = 'DAY' then 'Y' || SUBSTR (cb.fiscal_year, 3) || 'D'|| LPAD (TO_CHAR (cb.fiscal_bucket), 3, '0') when cb.bucket_name = 'FISCAL_WEEK' then 'Y' || SUBSTR (cb.fiscal_year, 3) || 'W' || LPAD (TO_CHAR (cb.fiscal_bucket), 2, '0') when cb.bucket_name = 'FISCAL_MONTH' then 'Y' || SUBSTR (cb.fiscal_year, 3) || 'M' || LPAD (TO_CHAR (cb.fiscal_bucket), 2, '0') when cb.bucket_name = 'FISCAL_QUARTER
 
did you have 111111 in your console?
 
9:26 PM
java.sql.SQLException: ORA-00942: table or view does not exist

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
i am looking for it
 
Show me DBUtil.prepareStatement
 
public static PreparedStatement prepareStatement(Connection connection, String sql) throws SQLException
{
PreparedStatement ps = connection.prepareStatement(sql);
logger.info(".prepareStatement, ** SQL=" + removeExtraSqlStringWhitespace(sql) + " **");
return ps;
}

public static void rollbackConnection(Connection connection)
{
if (connection != null)
{
try
{
connection.rollback();
}
catch ( SQLException e )
{
/* no-op */
}
}
}
 
ok, let's assume that prepared statement can't parse CTE
I rewrite the sql code
the link is available for 10 min
try to run it from SQL Developer at first
if it works, edit your java code
 
ok
what CTE ?
 
People call the with t as (...) section CTE
 
9:35 PM
i cannot access this site
pastebin
work blocked that site
 
common table expression
ok
SELECT prod_eff.facility
, prod_eff.product
, (SELECT MIN (bucket_header)
FROM (
SELECT cb.bucket_name, cb.fiscal_year,cb.fiscal_bucket, cb.version_id, cb.min_datetime
, case
when cb.bucket_name = 'DAY' --fiscal_day_str
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'D'|| LPAD (TO_CHAR (cb.fiscal_bucket), 3, '0')
when cb.bucket_name = 'FISCAL_WEEK'
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'W' || LPAD (TO_CHAR (cb.fiscal_bucket), 2, '0')
when cb.bucket_name = 'FISCAL_MONTH'
then
'Y' || SUBSTR (cb.fiscal_year, 3) || 'M' || LPAD (TO_CHAR (cb.fiscal_bucket), 2, '0')
 
just finished modified that code
let me compile on server and try again
 
did you check it from SQL Developer?
 
yes i did
no error
 
ok
fix your java code
 
9:46 PM
i did
compiling now
 
nice
 
9:57 PM
java.sql.SQLException: Invalid column index
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.OraclePreparedStatement.setTimestampInternal(OraclePreparedStatement.java:7606)
at oracle.jdbc.driver.OraclePreparedStatement.setTimestamp(OraclePreparedStatement.java:7580)
at net.sf.log4jdbc.PreparedStatementSpy.setTimestamp(PreparedStatementSpy.java:987)
 
is there the 1111111 string?
 
17:00 - 22:0022:00 - 23:00

  last day (17 days later) »