Home » SQL & PL/SQL » SQL & PL/SQL » Fetch & Reverse Entry
Fetch & Reverse Entry [message #244216] Tue, 12 June 2007 01:02 Go to next message
Nirene
Messages: 22
Registered: February 2004
Junior Member
Hello All,
I'm developing a financial accouting transaction,in which I want to select a set of records based on a condition and I reverse the transaction in a single query.

Orginal Entry
Party a/c Dr 100
Bank a/c Cr 100

I want to fetch this and reverse this accounting entry as

Bank a/c Dr 100
Party a/c Cr 100

Thanks in advance

Nirene

Re: Fetch & Reverse Entry [message #244217 is a reply to message #244216] Tue, 12 June 2007 01:17 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Without proper formatting it's hard to help.

Are 'Party a/c Dr 100' and 'Bank a/c Cr 100' single strings? Do they represent multiple columns? I can't tell. Use [CODE] and [/CODE] to make it look like this:

COL1    COL2    COL3   COL4
Party   a/c     Dr      100
Bank    a/c     Cr      100


...or like this:

COL1          COL2    
Party a/c     Dr 100
Bank a/c      Cr 100


..or like this:
COL1
Party a/c Dr 100
Bank a/c Cr 100


The same goes for your expected output. Read the tips and tricks topic, along with the topic about formatting. Please.

MHE
Re: Fetch & Reverse Entry [message #244223 is a reply to message #244216] Tue, 12 June 2007 01:32 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What do you want to reverse?
Is this the line or is this bank->Dr instead of Cr and Party->Cr instead of Cr?

Please always post your Oracle version (4 decimals).
Please read and apply How to format your posts.

Regards
Michel
Re: Fetch & Reverse Entry [message #244270 is a reply to message #244217] Tue, 12 June 2007 03:58 Go to previous messageGo to next message
Nirene
Messages: 22
Registered: February 2004
Junior Member
Hello,

Sorry about the formatting part,the data looks like this
COL1         COL2    COL3
Party a/c     Dr      100
Bank  a/c     Cr      100


I want that to be in this way

Bank  a/c     Dr      100
Party a/c     Cr      100


Thanks & Regards

Nirene

[Updated on: Tue, 12 June 2007 03:59] by Moderator

Report message to a moderator

Re: Fetch & Reverse Entry [message #244274 is a reply to message #244270] Tue, 12 June 2007 04:03 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Still the question:
Quote:
What do you want to reverse?
Is this the line or is this bank->Dr instead of Cr and Party->Cr instead of Cr?


Regards
Michel
Re: Fetch & Reverse Entry [message #244280 is a reply to message #244274] Tue, 12 June 2007 04:11 Go to previous messageGo to next message
Nirene
Messages: 22
Registered: February 2004
Junior Member
Hello,

Col1          Col2    Col3
Bank  a/c     Dr      100      Row1
Party a/c     Cr      100      Row2

Insert another 2 records

Col1          Col2    Col3
Party a/c     Dr      100      Row3
Bank  a/c     Cr      100      Row4


Nirene




[Updated on: Tue, 12 June 2007 04:31] by Moderator

Report message to a moderator

Re: Fetch & Reverse Entry [message #244296 is a reply to message #244280] Tue, 12 June 2007 05:08 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Still don't understand the problem.
Can you explain in words how you get the second from the first?

Regards
Michel
Re: Fetch & Reverse Entry [message #244300 is a reply to message #244280] Tue, 12 June 2007 05:18 Go to previous messageGo to next message
sanka_yanka
Messages: 184
Registered: October 2005
Location: Kolkata
Senior Member

Nirene
If i am not wrong then you mean to say,
you have only two records
Col1          Col2    Col3
Bank  a/c     Dr      100      Row1
Party a/c     Cr      100      Row2


and you want to add more two records in a single query only replacing Dr -> Cr and Cr -> Dr.
Is that you problem?

Regards
Sanka
Re: Fetch & Reverse Entry [message #244304 is a reply to message #244300] Tue, 12 June 2007 05:21 Go to previous messageGo to next message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Do you think you'll get an answer? I already asked 3 times.

Regards
Michel
icon14.gif  Re: Fetch & Reverse Entry [message #244307 is a reply to message #244300] Tue, 12 June 2007 05:23 Go to previous messageGo to next message
sanka_yanka
Messages: 184
Registered: October 2005
Location: Kolkata
Senior Member

Not sure,
But you can try this query
select col1,col2,col3 from table
union
select col1,decode(col2,'Dr','Cr','Cr','Dr') as col2,col3 from table


I think this will help you.

Regards,
Sanka
Re: Fetch & Reverse Entry [message #244379 is a reply to message #244216] Tue, 12 June 2007 09:12 Go to previous messageGo to next message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
insert into my_table(col1,col2,col3)
select col1,decode(col2,'Dr','Cr','Cr','Dr'),col3
from my_table
where ....;
Re: Fetch & Reverse Entry [message #244381 is a reply to message #244379] Tue, 12 June 2007 09:13 Go to previous message
Michel Cadot
Messages: 64120
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
But he still did not say this is the modification he wants.
In fact, he did not say what he wants.

Regards
Michel
Previous Topic: Bind variable "00" not declared.
Next Topic: adding 1 hour to a time field in PL/SQL
Goto Forum:
  


Current Time: Tue Dec 06 10:34:04 CST 2016

Total time taken to generate the page: 0.10765 seconds