UNION operator in ejb 3.0
Hi All,
I have to use UNION operator in my ejb ql. My underlying database is MySQL.
My ejb ql is
SELECT s from eee s where s.name like 'XXX'
UNION
SELECT t from eee t where t.default_id = 'XXX'
union is on the same entitybean.
In my eee entity bean I have tried
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
Ejb ql doesnot return the expected results.
Could someone please help me out with UNION operator in ejb 3.0
Thanks
you should have little problems, but just how little is container specific. I successfully run JEE 1.4 stuff on JBoss 5.1 for example without having to make any configuration changes. Heck, I mix that technology with EJB 3 tech, even having shared container managed transactions.
BTW: you mean JEE5, not J2SE 1.5. Big difference in what they represent.
Similar Messages
-
While doing union operation, i am getting the following eror.
While doing union operation, i am getting the following eror.
Solution for the following error
"Numbers of columns and their data types must be consistent across all criteria and Result Columns"Hi...phani..thanks for the response..
Report 1: TopN values... working fine
Report2: >TopN values working fine.
when i union the 2 the result is: all records, and i got it.
ReQ: i have to add the remaining Records of >N at the end of the report, represents Others: xxxx
My ReQ:
Col1 Col2 Col3 # of Srs %Of Srs
ABC Complaint Operation 200 40%
CDF ACD Part Availability 100 20%
Others 300 40%
suppose for first column in result tab,
Formula tab: case when saw_4>10 then 'Others' else saw_0 end.
when i put the above condition in Result columns i am getting the error.
Error: Numbers of columns and their data types must be consistent across all criteria and Result Columns -
Writing query using UNION Operator
Question -
(1)
Write an SQL Statement to list the following items: Customer ID, Customer Name, number of invoices, sum of total for invoices. Ensure that all customers are returned in the result set.
Answer for the above is written as below by one person. That seams to be correct. Is there another way of writing this same query.;
select c.CUSTOMER_ID,c.NAME,i.cnt,i.s
from gee_customer c,(select customer_id,count(*) as cnt, sum(TOTAL) as s
from gee_invoice
group by customer_id) i
where c.CUSTOMER_ID = i.customer_id (+)
(2)
My other question is How to write the above answer (or what you sugest) using UNION operator ?
Any ideas please
Message was edited by:
user483578In fact the outer join means you use the union of two result sets - usual join result
and the rows from the outer table for which there is not any row in the inner table.
SQL> select d.deptno, e.ename from emp e, dept d
2 where d.deptno = e.deptno(+)
3 order by 1,2
4 /
DEPTNO ENAME
10 CLARK
10 KING
10 MILLER
20 ADAMS
20 FORD
20 JONES
20 SCOTT
20 SMITH
30 ALLEN
30 BLAKE
30 JAMES
30 MARTIN
30 TURNER
30 WARD
40
15 rows selected.
SQL> select d.deptno,e.ename from emp e, dept d
2 where d.deptno = e.deptno
3 union
4 select deptno, null
5 from dept d where not exists (select null from emp e where e.deptno = d.deptno)
6 order by 1,2
7 /
DEPTNO ENAME
10 CLARK
10 KING
10 MILLER
20 ADAMS
20 FORD
20 JONES
20 SCOTT
20 SMITH
30 ALLEN
30 BLAKE
30 JAMES
30 MARTIN
30 TURNER
30 WARD
40
15 rows selected.In your example something like (NOT tested !)
with i as (select customer_id,count(*) as cnt, sum(TOTAL) as s
from gee_invoice group by customer_id)
select c.CUSTOMER_ID,c.NAME,i.cnt,i.s
from gee_customer c, i
where c.CUSTOMER_ID = i.customer_id
union
select c.CUSTOMER_ID,c.NAME,null,null
from gee_customer c
where not exists (select null from i where c.CUSTOMER_ID = i.customer_id)
Rgds. -
Using union operator in discoverer
Hi All,
I have a sql statement which is to be implemented in discoverer:
(select ........where user_entered_date='YYYY/MM/DD' )
UNION
(select ........where user_entered_date='YYYY/MM/DD'
AND (select ........where user_entered_date='YYYY/MM/DD' ))
Problem:
a) There are nested select statements which require parameters to be entered by the user.
b) How would I implement the union operator in the above scenario?
I would really appreciate it if someone could give a work around.
Regards,
NavHi,
Unfortunately, we can not have a SQL query with Union in Discoverer directly.
You should create a view based on the complete query and then create folder using the view.
You can provide a parameter at the report level.
For eg :
View query : select as_of_date from table_name
Report : Add a paremeter for as_of_date
Hope this Helps!
Yogini -
Creating table or View using UNION Operator ???????
Hi all
please need some help ,i have created aquery using UNION operator
(i.e
select A,to_number(null),C from table1
Union
select A,B,To_number(null) from table2)
it gives the output correctly and i need to make this output as View ot table
eacg time i use
Create or replace view v_1 ...........
it gives me this error :: unknown command "UNION" - rest of line ignored.
can any one pls tell me what to do
ThanksHi,
I found there is no error in your sql
create view x_v
as
select a from x
union
select to_number(null) from y;
this works fine.
in your sql check your right or left peranthesis
regards
Ripudaman -
All,
I have a requirement in SQL that I have to number each row. Hence I thought of using ROWNUM. But the sql query I'm using uses UNION operator. Hence I used like this
select a,b,rownum as 'field1' from table1
union
select c,d,1 as 'field1' from table2
Will the above query solve my purpose?
thanks
senjeneesh wrote:
This will probably kill the purpose of UNION - which is to take only the DISTINCT rows..
If DISTINCT is not intended, it is better to choose UNION ALLYes, you are correct about use of UNION. Probably, OP would have wanted to use Union ALL perhaps, but might have forgotten about suppressing of duplicates and sorting and ended up using Union.
But, in accordance with the original query used by OP, my suggestion of row number would not affect the output, I guess, would it?
Perhaps, if OP would have provided us with some base sample data and the Output desired from it, it would have been of greater help. -
Xpath union operator (|)
I am having trouble using the xpath union operator (|).
The selectNodes method of the oracle.xml.parser.v2.XMLNode is throwing an exception when I use any xPath expression with a pipe such as the one below. Does the Oracle Parser support this type of xPath operator?
Thanks,
Michael
//test/me[@id=3|@id=5]
<test>
<me id="5">you</me>
<me id="3">be</me>
</test>I discovered that this XPath returns the expected result:
//test/me[@id=3]|//test/me[@id=5] -
Hi everyone
I need to merge the data from two omogenous tables (be aware: two tables not two data services; the tables are populated by the user). I specifically need to do this client-side.
When I try to connect the out port of a table to the union operator, the input ports of the operator are grayed out.
I assume the union operator can be used only to merge data from data services: has anyone faced this issue before?
Thanks
Points will be awarded
VTHi Vincenzo,
this is where you reach some limitations in the Visual Composer.
The union operator is made to work on data services, not on tables.
The only ways to solve this are either to use another tool (WebDynpro) or to make use of a data service that would perform the necessary operation for you (creating a specific RFC or Web Service).
Rgds,
Karim -
Performing database operations using EJB 3.0
I need to create a session bean that will perform operations on backend database. I am new to EJB 3.0 and need a gentle guidance to the solution
This is what I believe is suppose to be done
1. Create stateless bean interface marking operations.
2. Create bean implementation for above
3. Init stage will require me to connect to the Oracle database. Now am confused how will it get the connection details? Is there a way to extract the url username and password using resource bendle which can be accessed from within bean implementation?
4. Bean method will perform update, read oprations
5. Predestroy will close the connection
6. A client will simply call this ejb with some input parameter(s)
Please let me know if am doing anything wrong hereIf you use EJB technology for which it is designed, the container (server) will manage the transaction (and also the connections to the database) for you, so no creation or cleanup of connections on your part. I advise you to read into JPA which is designed to be used in conjunction with EJB tech. The books Enterprise Javabeans 3.0 and Pro EJB 3: the Java Persistence API may help you a lot.
-
File IO operation in EJB (Session Bean)
Hi all,
Requirement : Read contents of a text file and upload the same to Oracle database (table).
I have created a Java class (application kind of) which opens, reads a file and transfers its data to a Oracle table.
Can I instantiate the same class within a Session Bean to perform the same operation or as per the EJB Restrictions this is not supposed to be done?
EJB Specifications 2.1 pdf guide
(refer 25.1.2 Programming restrictions
An enterprise bean must not use the java.io package to attempt to access files and directories in the file system. The file system APIs are not well-suited for business components to access data. Business components should use a resource manager API, such as JDBC, to store data.
Awaiting ur responses at the earliest.
Thanking in advance,
SeeteshHi Kenneth,
Thks for ur post.
I have coded the same using Weblogic App Server 7.0 ie a jsp invoking a java class (FileIO.class)(using jsp:useBean) and writing which does the IO operation and this works just fine.
Will this work by replacing the jsp with a Session Bean.
ie Session Bean's business method executing the method in the FileIO.class
Rgds,
Seetesh -
How to add an EJB to the Business Operation's EJB list?
I have made a session stateless EJB that have just one single business
method and I want to call that method from my workflow template definition.
So, I need it to be added to the /JNDI Name for Session EJB/ combo box in
the Define Business Operation window. I tried by simply deploying the ejb by
using the WLS console app but I didn't get it in the combo box list, what I
got was an exception in the WLS6:***** ASSERTION FAILED *****[ Unable to
load remote interface: java.lang.ClassNotFoundException:
atlante.Prueba ]Make sure your EJB is configured in the same Application as
the WLPI codeI have been trying to find an elegant way to add my ejb to the
WLPI Application in the console but i haven't found any, so what I had to do
was add the definition of my ejb to the <Application... name="WLPI
Application"> element in config.xml. It works fine, but I don't feel
comfortable doing that and I also think that there must be a descent way to
do that.so, the question is, how?
I will appreciate any help on this
regards
IsraelI have made a session stateless EJB that have just one single business
method and I want to call that method from my workflow template definition.
So, I need it to be added to the /JNDI Name for Session EJB/ combo box in
the Define Business Operation window. I tried by simply deploying the ejb by
using the WLS console app but I didn't get it in the combo box list, what I
got was an exception in the WLS6:***** ASSERTION FAILED *****[ Unable to
load remote interface: java.lang.ClassNotFoundException:
atlante.Prueba ]Make sure your EJB is configured in the same Application as
the WLPI codeI have been trying to find an elegant way to add my ejb to the
WLPI Application in the console but i haven't found any, so what I had to do
was add the definition of my ejb to the <Application... name="WLPI
Application"> element in config.xml. It works fine, but I don't feel
comfortable doing that and I also think that there must be a descent way to
do that.so, the question is, how?
I will appreciate any help on this
regards
Israel -
I'm trying to write a query that use the in operator:
@NamedQuery(name="findAnswersByLoginIdAndQuestionList", query="select object(o) from Answers o Where o.loginId = :loginId AND o.questionId IN :questionId")but I'm getting an error:
Exception Description: Syntax Recognition Problem parsing the EJBQL [select object(o) from Answers o Where o.loginId = :loginId AND o.questionId IN :questionId]. The parser returned the following [unexpected token: IN].
What am I doing wrong here?I'm looking through some documentation at http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/EJBQL5.html#72299
It looks to me like the IN does not support variables, the list must contain string literals. Quote:
An IN expression determines whether or not a string belongs to a set of string literals. Here is the syntax of the IN expression:
in_expression ::=
single_valued_path_expression
[NOT] IN (string_literal [, string_literal]* )
I'm sure there's some trickery that can get it to do what you want, though.
Also, no matter what you try, I would definitely suggest that you put the ( ) around your IN list. I assume in your example, questionId was a comma separated list, and the questionId string contained the parentheses. I don't think that will work.
Also, I suggest looking at the IN that is part of the FROM clause, to see if it does what you wan.
Message was edited by:
Michael_Ebbert -
Does OC4J support "LIKE" operation in ejb-ql?
I have a sql in ejb-jar.xml:
<query>
<query-method>
<method-name>findByZoneidTypeLnameInfo1</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>int</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[ SELECT OBJECT(a) FROM rrdata AS a WHERE a.zoneid = ?1 AND a.type = ?2 AND a.lname = ?3 AND a.info1 LIKE 'udns%.ultradns.net.' ]]>
</ejb-ql>
</query>
When compiling, I got an error:
com/sun/ejb/ejbql/StringLiteral
EJB QL statement : 'SELECT OBJECT(a) FROM rrdata AS a WHERE a.zoneid = ?1 AND a.
type = ?2 AND a.lname = ?3 AND a.info1 LIKE 'udns%.ultradns.net.''
EJB QL method : public abstract java.util.Collection com.ultradns.j2ee.compon
ents.ultradns.rrdata.ejb.RrdataHome.findByZoneidTypeLnameInfo1(java.lang.String,
int,java.lang.String) throws javax.ejb.FinderException
at com.sun.ejb.ejbql.parser.EjbQLParser.parse(EjbQLParser.java:226)
at com.sun.ejb.ejbql.EjbQLDriver.parse(EjbQLDriver.java:86)
at com.sun.ejb.sqlgen.SQLGenerator.generateSQLForEjbQLQueries(SQLGenerat
or.java:628)
at com.sun.ejb.sqlgen.SQLGenerator.generateSQL(SQLGenerator.java:270)
at com.evermind.server.ejb.deployment.EJBPackage.init(EJBPackage.java:19
47)
at com.evermind.server.ServerComponent.init(ServerComponent.java:224)
at com.evermind.server.ejb.EJBPackageDeployment.getPackage(EJBPackageDep
loyment.java:645)
at com.evermind.server.ejb.EJBContainer.postInit(EJBContainer.java:513)
at com.evermind.server.Application.postInit(Application.java:429)
at com.evermind.server.Application.setConfig(Application.java:136)
at com.evermind.server.ApplicationServer.addApplication(ApplicationServe
r.java:1479)
at com.evermind.server.ApplicationServer.initializeApplications(Applicat
ionServer.java:1436)
at com.evermind.server.ApplicationServer.setConfig(ApplicationServer.jav
a:1099)
at com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLa
uncher.java:93)
at java.lang.Thread.run(Thread.java:484)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:49)
Error in application dnsmanager: Error loading package at file:/C:/java/oc4j/j2e
e/home/applications/dnsmanager/ejb/, Failure to initialize EJBQL descriptors: co
m/sun/ejb/ejbql/StringLiteral
EJB QL statement : 'SELECT OBJECT(a) FROM rrdata AS a WHERE a.zoneid = ?1 AND a.
type = ?2 AND a.lname = ?3 AND a.info1 LIKE 'udns%.ultradns.net.''
EJB QL method : public abstract java.util.Collection com.ultradns.j2ee.compon
ents.ultradns.rrdata.ejb.RrdataHome.findByZoneidTypeLnameInfo1(java.lang.String,
int,java.lang.String) throws javax.ejb.FinderExceptionI would suggest to try
"from Brukerkonto as o"
instead of
"from Brukerkonto o" -
Cant Add OCRD.CardName,CRD7.ECCNo to this query.Please Help.
declare @FDate as datetime
declare @TDate as datetime
declare @Location as VARCHAR (30)
/* SELECT FROM [dbo].[OLCT] S0 WHERE */ SET @Location = /* S0.Location*/ '[%0]'
/* SELECT FROM [dbo].[OINM] S1 WHERE */ SET @FDate = /* S1.TaxDate*/ '[%1]'
/* SELECT FROM [dbo].[OINM] S2 WHERE */ SET @TDate = /* S2.TaxDate*/ '[%2]'
SELECT
'Sales'Document,OBTN.DistNumber
,NNM1.SeriesName,OINV.DocNum,OCRD.CardName,CRD7.ECCNo,OINV.DocDate,OITM.SWW [HSN Number],INV1.ItemCode,INV1.Dscription,(ITL1.Quantity*-1) [Quantity]
,OEDR.Name,OBTN.U_EDuty*(ITL1.Quantity*-1) EDuty,OBTN.U_EDuty EDutyUnit,OBTN.U_EDCess*(ITL1.Quantity*-1) EDCess,OBTN.U_EDHSCess*(ITL1.Quantity*-1) EDHSCess
,OBTN.U_EDImpDuty SADUnit,OBTN.U_EDImpDuty*(ITL1.Quantity*-1) SADTotal
,OBTN.U_MfgName,OBTN.U_MfgInvNo,OBTN.U_MfgInvDt,OBTN.U_MfgQty,OBTN.U_MfgValue
,OBTN.U_MfgDuty,OBTN.U_MfgCess,OBTN.U_MfgHSCess,OBTN.U_MfgImport
,OBTN.U_SupName,OBTN.U_SupInvNo,OBTN.U_SupInvDt,OBTN.U_SupQty,OBTN.U_SupValue
,OBTN.U_SupDuty,OBTN.U_SupCess,OBTN.U_SupHSCess,OBTN.U_SupImport
FROM
INV1
INNER JOIN
OINV ON INV1.DocEntry=OINV.DocEntry
INNER JOIN
OCRD ON OINV.CardCode = OCRD.CardCode
INNER JOIN
CRD7 ON OCRD.CardCode = CRD7.CardCode
INNER JOIN
OITM ON INV1.ItemCode=OITM.ItemCode
INNER JOIN
OITL ON INV1.BaseType=OITL.ApplyType AND INV1.BaseEntry=OITL.ApplyEntry AND INV1.BaseLine=OITL.ApplyLine
INNER JOIN
ITL1 ON OITL.LogEntry=ITL1.LogEntry
INNER JOIN
OBTN ON ITL1.MdAbsEntry=OBTN.AbsEntry and ITL1.SysNumber=OBTN.SysNumber AND ITL1.ItemCode=OBTN.Itemcode
INNER JOIN
[@OEDR] OEDR ON OBTN.U_EDRate=OEDR.Code
LEFT JOIN
NNM1 ON OINV.Series=NNM1.Series
WHERE INV1.LocCode IN (SELECT Code FROM OLCT WHERE Location=@Location)
AND OINV.DocDate BETWEEN @FDate AND @TDate
UNION ALL
SELECT
'Sales Return'Document,OBTN.DistNumber
,NNM1.SeriesName,ORIN.DocNum,ORIN.DocDate,OITM.SWW [HSN Number],RIN1.ItemCode,RIN1.Dscription,(ITL1.Quantity*-1) [Quantity]
,OEDR.Name,OBTN.U_EDuty*(ITL1.Quantity*-1) EDuty,OBTN.U_EDuty EDutyUnit,OBTN.U_EDCess*(ITL1.Quantity*-1) EDCess,OBTN.U_EDHSCess*(ITL1.Quantity*-1) EDHSCess
,OBTN.U_EDImpDuty SADUnit,OBTN.U_EDImpDuty*(ITL1.Quantity*-1) SADTotal
,OBTN.U_MfgName,OBTN.U_MfgInvNo,OBTN.U_MfgInvDt,OBTN.U_MfgQty,OBTN.U_MfgValue
,OBTN.U_MfgDuty,OBTN.U_MfgCess,OBTN.U_MfgHSCess,OBTN.U_MfgImport
,OBTN.U_SupName,OBTN.U_SupInvNo,OBTN.U_SupInvDt,OBTN.U_SupQty,OBTN.U_SupValue
,OBTN.U_SupDuty,OBTN.U_SupCess,OBTN.U_SupHSCess,OBTN.U_SupImport
FROM
RIN1
INNER JOIN
ORIN ON RIN1.DocEntry=ORIN.DocEntry
INNER JOIN
OITM ON RIN1.ItemCode=OITM.ItemCode
INNER JOIN
OITL ON RIN1.BaseType=OITL.ApplyType AND RIN1.BaseEntry=OITL.ApplyEntry AND RIN1.BaseLine=OITL.ApplyLine
INNER JOIN
ITL1 ON OITL.LogEntry=ITL1.LogEntry
INNER JOIN
OBTN ON ITL1.MdAbsEntry=OBTN.AbsEntry and ITL1.SysNumber=OBTN.SysNumber AND ITL1.ItemCode=OBTN.Itemcode
INNER JOIN
[@OEDR] OEDR ON OBTN.U_EDRate=OEDR.Code
LEFT JOIN
NNM1 ON ORIN.Series=NNM1.Series
WHERE RIN1.LocCode IN (SELECT Code FROM OLCT WHERE Location=@Location)
AND ORIN.DocDate BETWEEN @FDate AND @TDateNagarajan,
I've altered the query into this.Think that it is working.Thanks man
declare @FDate as datetime
declare @TDate as datetime
declare @Location as VARCHAR (30)
/* SELECT FROM [dbo].[OLCT] S0 WHERE */ SET @Location = /* S0.Location*/ '[%0]'
/* SELECT FROM [dbo].[OINM] S1 WHERE */ SET @FDate = /* S1.TaxDate*/ '[%1]'
/* SELECT FROM [dbo].[OINM] S2 WHERE */ SET @TDate = /* S2.TaxDate*/ '[%2]'
SELECT
'Sales'Document,OBTN.DistNumber
,NNM1.SeriesName,OINV.DocNum,OCRD.CardName,CRD7.ECCNo,OINV.DocDate,OITM.SWW [HSN Number],INV1.ItemCode,INV1.Dscription,(ITL1.Quantity*-1) [Quantity]
,OEDR.Name,OBTN.U_EDuty*(ITL1.Quantity*-1) EDuty,OBTN.U_EDuty EDutyUnit,OBTN.U_EDCess*(ITL1.Quantity*-1) EDCess,OBTN.U_EDHSCess*(ITL1.Quantity*-1) EDHSCess
,OBTN.U_EDImpDuty SADUnit,OBTN.U_EDImpDuty*(ITL1.Quantity*-1) SADTotal
,OBTN.U_MfgName,OBTN.U_MfgInvNo,OBTN.U_MfgInvDt,OBTN.U_MfgQty,OBTN.U_MfgValue
,OBTN.U_MfgDuty,OBTN.U_MfgCess,OBTN.U_MfgHSCess,OBTN.U_MfgImport
,OBTN.U_SupName,OBTN.U_SupInvNo,OBTN.U_SupInvDt,OBTN.U_SupQty,OBTN.U_SupValue
,OBTN.U_SupDuty,OBTN.U_SupCess,OBTN.U_SupHSCess,OBTN.U_SupImport
FROM
INV1
INNER JOIN
OINV ON INV1.DocEntry=OINV.DocEntry
INNER JOIN
OITM ON INV1.ItemCode=OITM.ItemCode
INNER JOIN
OCRD ON OINV.CardCode = OCRD.CardCode
INNER JOIN
CRD7 ON OCRD.CardCode = CRD7.CardCode
INNER JOIN
OITL ON INV1.BaseType=OITL.ApplyType AND INV1.BaseEntry=OITL.ApplyEntry AND INV1.BaseLine=OITL.ApplyLine
INNER JOIN
ITL1 ON OITL.LogEntry=ITL1.LogEntry
INNER JOIN
OBTN ON ITL1.MdAbsEntry=OBTN.AbsEntry and ITL1.SysNumber=OBTN.SysNumber AND ITL1.ItemCode=OBTN.Itemcode
INNER JOIN
[@OEDR] OEDR ON OBTN.U_EDRate=OEDR.Code
LEFT JOIN
NNM1 ON OINV.Series=NNM1.Series
WHERE INV1.LocCode IN (SELECT Code FROM OLCT WHERE Location=@Location)
AND OINV.DocDate BETWEEN @FDate AND @TDate
UNION ALL
SELECT
'Sales Return'Document,OBTN.DistNumber
,NNM1.SeriesName,ORIN.DocNum,OCRD.CardName,CRD7.ECCNo,ORIN.DocDate,OITM.SWW [HSN Number],RIN1.ItemCode,RIN1.Dscription,(ITL1.Quantity*-1) [Quantity]
,OEDR.Name,OBTN.U_EDuty*(ITL1.Quantity*-1) EDuty,OBTN.U_EDuty EDutyUnit,OBTN.U_EDCess*(ITL1.Quantity*-1) EDCess,OBTN.U_EDHSCess*(ITL1.Quantity*-1) EDHSCess
,OBTN.U_EDImpDuty SADUnit,OBTN.U_EDImpDuty*(ITL1.Quantity*-1) SADTotal
,OBTN.U_MfgName,OBTN.U_MfgInvNo,OBTN.U_MfgInvDt,OBTN.U_MfgQty,OBTN.U_MfgValue
,OBTN.U_MfgDuty,OBTN.U_MfgCess,OBTN.U_MfgHSCess,OBTN.U_MfgImport
,OBTN.U_SupName,OBTN.U_SupInvNo,OBTN.U_SupInvDt,OBTN.U_SupQty,OBTN.U_SupValue
,OBTN.U_SupDuty,OBTN.U_SupCess,OBTN.U_SupHSCess,OBTN.U_SupImport
FROM
RIN1
INNER JOIN
ORIN ON RIN1.DocEntry=ORIN.DocEntry
INNER JOIN
OCRD ON ORIN.CardCode = OCRD.CardCode
INNER JOIN
CRD7 ON OCRD.CardCode = CRD7.CardCode
INNER JOIN
OITM ON RIN1.ItemCode=OITM.ItemCode
INNER JOIN
OITL ON RIN1.BaseType=OITL.ApplyType AND RIN1.BaseEntry=OITL.ApplyEntry AND RIN1.BaseLine=OITL.ApplyLine
INNER JOIN
ITL1 ON OITL.LogEntry=ITL1.LogEntry
INNER JOIN
OBTN ON ITL1.MdAbsEntry=OBTN.AbsEntry and ITL1.SysNumber=OBTN.SysNumber AND ITL1.ItemCode=OBTN.Itemcode
INNER JOIN
[@OEDR] OEDR ON OBTN.U_EDRate=OEDR.Code
LEFT JOIN
NNM1 ON ORIN.Series=NNM1.Series
WHERE RIN1.LocCode IN (SELECT Code FROM OLCT WHERE Location=@Location)
AND ORIN.DocDate BETWEEN @FDate AND @TDate -
UNION operator with BULK COLLECT for a collection type
Hi all,
I created a table type as below:
create or replace type coltest is table of number;
Below are 3 PL/SQL blocks that populate data into variables of the above mentioned table type:
BLOCK 1:
DECLARE
col1 coltest := coltest(1, 2, 3, 4, 5, 11);
col2 coltest := coltest(6, 7, 8, 9, 10);
col3 coltest := coltest();
BEGIN
SELECT * BULK COLLECT
INTO col1
FROM (SELECT *
FROM TABLE(CAST(col1 AS coltest))
UNION ALL
SELECT * FROM TABLE(CAST(col2 AS coltest)));
dbms_output.put_line('col1');
dbms_output.put_line('col1.count: ' || col1.COUNT);
FOR i IN 1 .. col1.COUNT
LOOP
dbms_output.put_line(col1(i));
END LOOP;
END;
OUPUT:
col1
col1.count: 5
6
7
8
9
10
BLOCK 2:
DECLARE
col1 coltest := coltest(1, 2, 3, 4, 5, 11);
col2 coltest := coltest(6, 7, 8, 9, 10);
col3 coltest := coltest();
BEGIN
SELECT * BULK COLLECT
INTO col2
FROM (SELECT *
FROM TABLE(CAST(col1 AS coltest))
UNION ALL
SELECT * FROM TABLE(CAST(col2 AS coltest)));
dbms_output.put_line('col2');
dbms_output.put_line('col2.count: ' || col2.COUNT);
FOR i IN 1 .. col2.COUNT
LOOP
dbms_output.put_line(col2(i));
END LOOP;
END;
OUTPUT:
col2
col2.count: 6
1
2
3
4
5
11
BLOCK 3:
DECLARE
col1 coltest := coltest(1, 2, 3, 4, 5, 11);
col2 coltest := coltest(6, 7, 8, 9, 10);
col3 coltest := coltest();
BEGIN
SELECT * BULK COLLECT
INTO col3
FROM (SELECT *
FROM TABLE(CAST(col1 AS coltest))
UNION ALL
SELECT * FROM TABLE(CAST(col2 AS coltest)));
dbms_output.put_line('col3');
dbms_output.put_line('col3.count: ' || col3.COUNT);
FOR i IN 1 .. col3.COUNT
LOOP
dbms_output.put_line(col3(i));
END LOOP;
END;
OUTPUT:
col3
col3.count: 11
1
2
3
4
5
11
6
7
8
9
10
Can anyone please explain the output of BLOCK 1 and 2? Why doesn't bulk collect into col1 and col2 return 11 as count?Consider the following code from your block.
select *
bulk collect into col1
from (
select *
from table(cast(col1 as coltest))
union
all
select *
from table(cast(col2 as coltest))
); Now my assumption would be like this.
PL/SQL engine would recognize the SQL part and will be sending it to SQL Engine for processing. Before doing that it will try to initialize the SQL collection variable COL1. Now when SQL Engine process the SELECT, COL1 would be empty already. And thats the reason you don't get the as 5 and not 11.
Maybe you are looking for
-
Dreamweaver CS6 "Not Responding" with TypeKit on Windows 8
My Dreamweaver CS6 (Cloud Install) on Windows 8 freezes up when i type code in "code view" to "Not Responding". It seems that it is the two lines from TypeKit that cause the problem (<script type="text/javascript" src="//use.typekit.net/xxx.js"></scr
-
How to create a container element?
Hi, Could somebody please tell me how to create a container element and how to create a multi container element? How is this element used in the fork step? I am using a fork with 3 branches but the agent assignment is a problem.The workitem does not
-
Dear All: My problem is as below: I need to draw a large repeating frame ( sized 8 inches x 38 inches) and print it out using A4 paper (sized approximately 8.5 inches x 11 inches) via PDF format in Acrobat Reader. The problem is the report print out
-
I am experiencing "unable to download" apps. My cbs app says my date and time are wrong to run? eBay icons quit downloading?
-
AEBS associates client hostnames with DHCP-supplied IP addresses?
Hi, I have 3 Mac's, a Windows and a Linux machine on my home network. I'm looking at getting an Airport Extreme Base Station. I understand it does DNS forwarding and caching out-of-the-box. I'd love to know if the Airport Extreme when acting as a DHC