Home » Developer & Programmer » Forms » Union Operation in Forms (Oracle IDS 10g,Windows XP)
Union Operation in Forms [message #376385] |
Wed, 17 December 2008 03:23 |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Hi All !
I want to combine two tables using union operation.. I tried with the coding
select employeeid,leavetype,fromdate,todate,numberofdays,status from empaply
union
select employeeid,leavetype,fromdate,todate,numberofdays,status
from
aplybkup
This works well in the sql database window but not in the oracle forms .. In forms i got an error to add INTO clause.. so i tried with the coding ..
Table names:empaply and hod_al and aplybkup -- rest are the field names in the corresponding table ..
select employeeid,leavetype,fromdate,todate,numberofdays,status
into :hod_al.employeeid,:hod_al.leavetype,:hod_al.fromdate,:hod_al.todate,:hod_al.numberofdays,:hod_al.status
from empaply
union
select employeeid,leavetype,fromdate,todate,numberofdays,status
into :hod_al.employeeid,:hod_al.leavetype,:hod_al.fromdate,:hod_al.todate,:hod_al.numberofdays,:hod_al.status
from aplybkup ;
But i got an error saying
"Encountered the symbol INTO when
expecting (,/,%,*,. etc)."
Please help me with a solution ..
Thanks and Regards,
varosh [EDITED by DJM: fixed crappy formatting]
[Updated on: Wed, 07 January 2009 00:33] by Moderator Report message to a moderator
|
|
|
|
|
Re: Union Operation in Forms [message #376396 is a reply to message #376385] |
Wed, 17 December 2008 03:50 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
This has got nothing to do with forms and everything to do with your select.
SELECT INTO never works with multiple into's
You need to use an inline view.
Something like this:
SELECT <column list> INTO <variable list>
FROM (SELECT <column list>
FROM table1
UNION
SELECT <column list>
FROM table2);
|
|
|
|
Re: Union Operation in Forms [message #376413 is a reply to message #376396] |
Wed, 17 December 2008 04:30 |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Hi Cookiemonster and LittleFoot !
Thanks for your reply !
I tried with your coding(cookiemonster) it worked fine without error but when i run the form i got the current record alone and not all the rows that is obtained by UNION..
i got 32 records in sql database window by UNION operation but i got here only one row that is the current row alone on running the form..
So what can be done to get all the records on the form ..
Actually i have saved the entries of a form in two different tables.. With one table having the current record and the other table having the previous records..
So i want combine these two table and retrieve those records in a new form ..
Thanks and Regards,
varosh
|
|
|
|
|
|
Re: Union Operation in Forms [message #376640 is a reply to message #376445] |
Thu, 18 December 2008 02:49 |
varosh81
Messages: 178 Registered: February 2008 Location: CHENNAI
|
Senior Member |
|
|
Here is the coding which i used to create a VIEW ..
CREATE VIEW vv
AS
SELECT a.employeeid, a.employeename, a.leavetype, a.fromdate, a.todate,
a.numberofdays, a.reason, b.employeeid, b.employeename, b.leavetype,
b.fromdate, b.todate, b.numberofdays, b.reason
FROM empaply a, aplybkup b
WHERE a.employeeid = b.employeeid
b.employeeid,b.employeename,b.leavetype,b.fromdate,b.todate,b.numberofdays,b.reason
*ERROR at line 3:
ORA-00957: duplicate column name
Thanks and Regards,
varosh
[EDITED by LF: formatted the CREATE VIEW script]
[Updated on: Thu, 18 December 2008 04:32] by Moderator Report message to a moderator
|
|
|
Re: Union Operation in Forms [message #376679 is a reply to message #376640] |
Thu, 18 December 2008 04:35 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
It is obvious: you can't create a view with duplicate column names! Although tables 'empaply' and 'aplybkup' contain columns with the same names, you'll have to modify some of them.
For example:
CREATE VIEW vv AS
SELECT a.employeeid empid_a,
b.employeeid empid_b,
FROM
empaply a, aplybkup b
WHERE ...
Also, next time format the code. Using the [code] tags in order to preserve formatting is useless if the code itself is unformatted.
|
|
|
Goto Forum:
Current Time: Mon Feb 03 17:53:19 CST 2025
|