Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Intersperse daily totals with opening and closing balance

445476Apr 1 2010 — edited Apr 19 2010
Hi All

Suppose we have a data set (simplified from my query but will suffice)
(
  select 1 as daynum, 'CR' as trantype, 200 as amount from dual union all
  select 1 as daynum, 'DR' as trantype, -300 as amount from dual union all
  select 2 as daynum, 'CR' as trantype, 800 as amount from dual union all
  select 2 as daynum, 'DR' as trantype, -200 as amount from dual union all
  select 3 as daynum, 'CR' as trantype, 900 as amount from dual union all
  select 3 as daynum, 'DR' as trantype, -500 as amount from dual 
)
How would you go about getting a result set that looks like:

1, Opening Balance, 0
1, CR, 200
1, DR, -300
1, Closing Balance, -100
2, Opening Balance, -100
2, CR, 800
2, DR, -200
2, Closing Balance, 500
3, Opening Balance, 500
3, CR, 900
3, DR, -500
3, Closing Balance, 900
4, Opening Balance, 900
4, Closing Balance, 900

I'm thinking:
generate an arbitrary number of rows for the number of days I want to report over (in this case, 4)
cross join these with 2 row set of constants "opening" and "closing" balanace
-> I have now an opening and closing balance row for every day
union it with my data so that "opening/CLosing balance" is a type too (and nulls in the amount column)
case when the type is like '%Balance' then sum(amount) over(order by day, orderkind rows unbounded preceding) else amount

(orderkind is a constant 0 for opening, 1 for all the datarows, 2 for closing)

Is it right?
Is there a better way?

Edited by: charred on Apr 1, 2010 7:03 AM

Comments

We need more info.

What OS are you on?

What JDK are you using?
What version of Oracle are you connected to?

user6545024

Hi, Jeff.

I've got the same problem. As soon as I connect to the DB, supose I write "SELECT * FROM DUAL;" and press F5. No problem. Now I write "SELECT 1/0 FROM DUAL" and execute. The problem whit screen appears.

My OS: Windows 7 Professional 32 bits Service Pack 1

JDK: jdk1.8.0_25

Oracle version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

thatJeffSmith-Oracle

I just get a

Error starting at line : 1 in command -

SELECT 1/0 FROM DUAL

Error report -

SQL Error: ORA-01476: divisor is equal to zero

01476. 00000 -  "divisor is equal to zero"

*Cause:   

*Action:

user6545024

The question is I can't see the error text because the screen is not repainting. And in the log window I see the error about RaptorTaskManager.

Gary Graham-Oracle

Some possibilities...

  1. If a freeze is not some sort of deadlock, then it could be a memory limitation.  The fact you are using a 32-bit OS makes me suspicious.  Have you modified the Java -Xms or -Xmx memory limit in your product.conf file?  (In C:\Users\<yourID>\AppData\Roaming\sqldeveloper\4.1.0).  If the setting (even the default) is higher than available RAM, then that could be the problem. Or if it is lower than what SQL Developer needs (depending on what you have been doing and for how long), then you may be experiencing thrashing due to JVM garbage collection.
  2. Are you really using 4.1.0?   In 4.0.x there was a problem with using the Ctrl+C, Ctrl-V copy/paste shortcut keys: SQL Developer Unresponsive
user6545024

Thanks, Gary.

In product.conf every line is commented but one saying "SetJavaHome C:\Program Files\Java\jdk1.8.0_25". And the version is  4.1.0.19. In fact I've being using SQL Developer a long time, and I had this problem with all the versions after 3.2.20.09 (in the same computer, I suppose I need a newer one ).

Gary Graham-Oracle

I suppose I need a newer one

Very probably.  In early 2014 nearly 50% of Win 7 installs were 64-bit, and clock in tech-time spins pretty fast.  If you are stuck on 32-bit, however, the next suggestion is to update your video driver or at least search the web for issues with your video card / driver combination.  I even read of one user blaming a Lenovo mouse driver for the infamous copy/paste hang.  Anyway, good luck!

reckless

Hello,

this seems to be the same issue described on this thread I opened several months ago:

I opened a SR to fix/investigate the issue. this is the bug: 20548707. It's on this state: "44 - Not Feasible to fix, to Filer" Not sure what it means...


I wrote this only to state that I reproduced the issue on different computers (some of them quite new & fast), so I maybe the speed of the computer is not relevant at all. I hope this issue could be fixed son as is quite irritant (also, this issue could be dangerous as you can't know what gone wrong or right in the script output).

Thanks in advance


Gary Graham-Oracle

I believe that bug was put into a "Not Feasible to fix" status because QA could not reproduce the behavior using your test case.  Neither could I.


I assume the problem either has something to do with...

1. your environment (software / hardware).

2. corruption in your user profile settings: C:\Users\<yourUserid>\AppData\Roaming\SQL Developer\system<sqldevbuild>


So if you are still using 4.0.3.16.84, you could try upgrading to the latest 4.1.1.19.59 and just skip the settings migration step to see if the problem still exists.

reckless

Ok, I'll try it (btw the issue persist on 4.1.1.19.59).

Thinking about it, this are the only two "special" things installed:

- plugins: show me the password, keepalive

- a large set of connections imported via xml.

What is strange, is that on sqldeveloper version on linux the issue does not occur (with the same version, plugins and connections).

I'll post feedback about a fresh sqldeveloper install.

Thanks in advance.

reckless

Hi again,

Sorry for keep this thread alive but... same issue on 4.1.2.20 (with settings skipped on the 1st start)

Am I the only one? I can't understand what could cause this. Anyway I think the cause is clear:

SEVERE35230oracle.dbtools.raptor.backgroundTask.RaptorTaskManager$1null en java.util.StringTokenizer.nextToken(StringTokenizer.java:349)

Any chance to send this error to a java developer to see if this could be a bug on the sqldeveloper code? Any hint? I opened a SR a while ago a nothing was detected.

Take note that I tested it in various hw environments  (all on Windows 7 64bit).

Thanks in advance!

user6545024

I don't know why, but the problem I was having long time ago with this issue has dissapeared with the next line in sqldeveloper.conf:

AddVMOption -Duser.language=en

It forces SQL Developer to use English GUI, instead of the one I was using (Spanish)

reckless

Setting the english option did the trick!!! thanks a lot user6545024!!!

maybe could be useful send this workaround to developers team ....

user6545024

Gary, what do you think about sending this to developers? I suppose they can reproduce this behaviour using a non English GUI

Gary Graham-Oracle

Any chance to send this error (SEVERE ... RaptorTaskManager$1) to a java developer to see if this could be a bug on the sqldeveloper code?

As far as I know, the SEVERE log messages generated from RaptorTaskManager come either from cancelling an active task or scheduler thread, closing the window of an active task, or represent some otherwise uncaught exception in a background thread the task manager is running. So these messages do not help much to track down something that is typically a suspected issue with video driver software / hardware acceleration settings, or Java's handling of the user's locale.

Over the years, since English is the de facto locale, the AddVMOption -Duser.language=en workaround has been a standard recommendation when the user's locale is unsupported or some Java / locale bug comes up.  For example, in ...\sqldeveloper\ide\bin\ide.boot, we see other officially supported languages in the line...

oracle.translated.locales = de,es,fr,it,ja,ko,pt_BR,zh_CN,zh_TW

One never knows what problem a failure in a translated locale will cause SQL Developer.  For example, this old discussion re: a missing Connections navigator...

The Connection Navigator is missing

Gary Graham-Oracle

I suppose they can reproduce this behaviour using a non English GUI

Possibly. But I suppose the issue could also be the specific locale configuration on a specific machine and might be difficult to reproduce.  I have no idea what percentage of non-English locale users have this kind of problem, but if you have have solid test case it would be best to log a service request with Oracle Support.

1 - 16
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 17 2010
Added on Apr 1 2010
25 comments
4,127 views