Correct Query For EJB
I have such classes
Entity bean
@Entity(name = "Actor")
@Table(name = "actor")
public class Actor extends DomainObject{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "actor_id_seq")
@Column(columnDefinition = "id")
private Long id;
@Embedded
@AttributeOverrides({
@AttributeOverride(name="firstName", column=@Column(name = "firstname", nullable = false)),
@AttributeOverride(name="lastName", column=@Column(name = "lastname", nullable = false))
private PersonalInfo personalInfo;
// getters and setters here
}Here is an embedded class
@Embeddable
public class PersonalInfo {
private String firstName;
private String lastName;
//getters and setters
}And here is a stateless bean
@Stateless
@Remote(AccountService.class)
public class AccountServiceBean implements AccountService {
@PersistenceContext
private EntityManager manager;
public Actor findActorByFirstName(String firstName){
Query q = manager.createQuery("SELECT actor FROM Actor actor WHERE actor.firstName = :firstName"); //!!!HERE
q.setParameter("firstName", firstName);
return (Actor) q.getSingleResult();
}Can anybody say, what is the reson why createQuery method doesn't work? Or maybe, somebody can help me with a correct query.
I use Sun Application Server 9. In log i see such error
javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: java.lang.NullPointerException
java.lang.NullPointerException
at com.sun.enterprise.util.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:521)
at net.sourceforge.openejforum.services.engine.ejb3.AccountServiceBean.findActorByFirstName(AccountServiceBean.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
...Thank you
Message was edited by:
awep
You can try this in your query:
Query q = manager.createQuery("SELECT actor FROM Actor actor WHERE actor.personalInfo.firstName = :firstName");
q.setParameter("firstName", firstName); I hope this can help you.
Similar Messages
-
Specific EJB-QL query for m:n relationship
Hi all,
could anyone help me to write EJB-QL query? I'm designing an application and not sure how to express the following query in EJB-QL notation:
For demo study imagine the following schema (from Sun J2ee tutorial):
Player ------- Team
with m:n relationship
Players: John, Mike, Tom. Jim
Teams: RedHeads, WhiteKnees, BigPlayers
I want to write a query that finds all players that are NOT in e.g. RedHeads team (they can be members of other teams).
Thanks,
TomasCan't help you on presenting an all cooked up query, but I suggest solving this kind of problem with a SessionBean containing the logic to filter players in the e.g. RedHeads team.
Using a finder method is very costly, the general advise I hear is using EJBQL only when you really need to and only 'findByName' or 'findAll' style. If you know what I mean. -
Options for EJB - Corba - correct?
Hi,
I'm looking at the options for EJB->CORBA and CORBA->EJB method calls in Weblogic Server 5.1 (although we may be moving to 6 soon)
We are currently using CORBA 2.1 C++ code, and are looking for a migration path into EJBs.
I've tried to pull together small list of our options, with apologies to Eduardo Ceballos who wrote most of this text originally, and anyone else who's work is included.
Does any one have the time to read the below, and make any comments on important options that I've missed, or pitfalls that they can see?
Thankyou in advance;
Notes:
-- RMI over IIOP is only available under JDK 1.3
-- if we use a pre Corba 2.3 implementation (as we currently are), only primitive types may be passed (no OBV available).
-- Another option is to use WebLogic Enterprise, but we are currently using WebLogic Server. ‘WebLogic Enterprise Connectivity gives you the ability to create IIOP connection pools to a BEA WebLogic Enterprise, allowing you to execute WebLogic Enterprise CORBA objects from WebLogic Server servlets and Enterprise JavaBeans.’
Calling from a WLS into a CORBA server:
========================================
There are several variations on two ways:
1. expose the CORBA interface;
To expose the CORBA interface, you collocate the ORB of your choice within the WLS instance and bind CORBA stubs into the JNDI tree as needed. The application looks up CORBA objects and uses the CORBA server interfaces as you would regardless of WLS.
This is an example of designing the RMI interface so that it maps in a usable way to the IDL interface.
2. hide the CORBA interface.
To hide the CORBA interface, create a RMI interface and a RMI server class; run 'weblogic.rmic -iiop -idl ...' on that class; take the resulting idl and add it to the interfaces which the CORBA servers implement. To gain access to the CORBA servers, use COSNaming to bind the CORBA servers into the WLS JNDI tree. As above, the application looks up the CORBA servers in the JNDI tree, but in this case the application uses the RMI-IIOP stubs to communicate with the CORBA servers.
This is an example of adding RMI interfaces to existing CORBA servers to establish some level of connectivity.
If you are using an RMI-IIOP implementation of some sort, then you are effectively hiding the CORBA interface, except you'd ignore any of work that would be done at the IDL level.
Note: We should use rmic and the –noValueTypes flag (as we aren’t using Orbix 2.3).
Calling from a Corba server into WLS
======================================
It is possible to host an Orb in the app server, contained within a WebLogic startup class. This will allow Corba calls to be delegated to app-server components (see option 1, above).
Thanks again.Comments inline....
G Morgan wrote:
Hi,
I'm looking at the options for EJB->CORBA and CORBA->EJB method calls in Weblogic Server 5.1 (although we may be moving to 6 soon)Yes, move to 6.0.
>
>
We are currently using CORBA 2.1 C++ code, and are looking for a migration path into EJBs.
I've tried to pull together small list of our options, with apologies to Eduardo Ceballos who wrote most of this text originally, and anyone else who's work is included.
Does any one have the time to read the below, and make any comments on important options that I've missed, or pitfalls that they can see?
Thankyou in advance;As far as I can tell, pre-2.3 ORBs can not handle type ids that start with "RMI:". So pretty much the only option at the moment with a pre-2.3 ORB is to delegate through a colocated ORB. As with the the previous response, it's a good idea to host the ORB in a WLS client, that way if the ORB goes south, it doesn't take the server with it.
>
>
Notes:
-- RMI over IIOP is only available under JDK 1.3
-- if we use a pre Corba 2.3 implementation (as we currently are), only primitive types may be passed (no OBV available).
-- Another option is to use WebLogic Enterprise, but we are currently using WebLogic Server. ‘WebLogic Enterprise Connectivity gives you the ability to create IIOP connection pools to a BEA WebLogic Enterprise, allowing you to execute WebLogic Enterprise CORBA objects from WebLogic Server servlets and Enterprise JavaBeans.’
Calling from a WLS into a CORBA server:
========================================
There are several variations on two ways:
1. expose the CORBA interface;
To expose the CORBA interface, you collocate the ORB of your choice within the WLS instance and bind CORBA stubs into the JNDI tree as needed. The application looks up CORBA objects and uses the CORBA server interfaces as you would regardless of WLS.
This is an example of designing the RMI interface so that it maps in a usable way to the IDL interface.
2. hide the CORBA interface.
To hide the CORBA interface, create a RMI interface and a RMI server class; run 'weblogic.rmic -iiop -idl ...' on that class; take the resulting idl and add it to the interfaces which the CORBA servers implement. To gain access to the CORBA servers, use COSNaming to bind the CORBA servers into the WLS JNDI tree. As above, the application looks up the CORBA servers in the JNDI tree, but in this case the application uses the RMI-IIOP stubs to communicate with the CORBA servers.
This is an example of adding RMI interfaces to existing CORBA servers to establish some level of connectivity.
If you are using an RMI-IIOP implementation of some sort, then you are effectively hiding the CORBA interface, except you'd ignore any of work that would be done at the IDL level.
Note: We should use rmic and the –noValueTypes flag (as we aren’t using Orbix 2.3).
Calling from a Corba server into WLS
======================================
It is possible to host an Orb in the app server, contained within a WebLogic startup class. This will allow Corba calls to be delegated to app-server components (see option 1, above).
Thanks again. -
Hello Experts,
I'm tryng to develop my first application for EP (v7 SP12) with NWDS (without NWDI).
This application has to read and write data in the EP DB (oracle v10).
I'm using:
<u>a Dictionary Project</u> (define the DB Tables)
<u>a Java Project</u> (define class as DAO, DBManager etc)
<u>a Library Project</u>
<u>an EJB Project</u>
<u>an EAR Project</u>
With these projects I can deploy a <u>webService</u> in my EP server.
BUT I have some problem with a query that I'm tryng to sent to my DB through a DAO Class called by my WebService.
The query is simple and correct but it does not work...
This is the error message returned (the query id in bold)
(column names: GIORNO, NOMEDITTA, NOMEAREA, NOMESETTORE)
<i>HTTP/1.1 500 Internal Server Error
Connection: close
Server: SAP J2EE Engine/7.00
Content-Type: text/xml; charset=UTF-8
Date: Fri, 21 Sep 2007 14:29:57 GMT
Set-Cookie: <value is hidden>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>java.sql.SQLException: com.sap.sql.log.OpenSQLException: The SQL statement <b>"SELECT NOMESETTORE, MIN(? - "GIORNO") AS GIORNI FROM SRS_DATEINFORTUNI WHERE NOMEDITTA = ? AND NOMEAREA= ? GROUP BY NOMESETTORE ORDER BY NOMESETTORE"</b> <u>contains the syntax error[s]: - 1:25 - the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</u></faultstring><detail><ns1:getGiorniSettori_com.akhela.giorniSenzaInfortuni.ejb.exception.GiorniSenzaInfortuniException xmlns:ns1='urn:GiorniSenzaInfortuniWSWsd/GiorniSenzaInfortuniWSVi'></ns1:getGiorniSettori_com.akhela.giorniSenzaInfortuni.ejb.exception.GiorniSenzaInfortuniException></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope></i>
The variable '?' is the today date, the difference <b>"(?-GIORNO)"</b> is an int..
Moreover in my DAO class the query is <b>"SELECT NOMESETTORE, MIN(? - GIORNO) AS GIORNI FROM SRS_DATEINFORTUNI WHERE NOMEDITTA = ? AND NOMEAREA= ? GROUP BY NOMESETTORE ORDER BY NOMESETTORE</b>", instead in the error message is reported <b>MIN(? - "GIORNO")</b>...
We have tryed also with alternative query, for example we used <b>"MIN(SYSDATA - GIORNO)"</b> but <b>SYSDATA</b> was interpreted as column name and not found....
Any help???
Best RegardsHi, I found something about the Host Variable (http://help.sap.com/saphelp_nw70/helpdata/en/ed/dbf8b7823b084f80a6eb7ad43bdbb9/content.htm), there explain that if you want to use an host variable you have to put ':' as prefix..
My problem is that <u>I need to extract the minimum of the subtraction between two dates:</u>
Query <b>MIN(? - GIORNO)</b> --> <i>Error: the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</i>
So I tried to use the ':' as indicated in the manual..
<b>MIN:(? - GIORNO)</b> --> - <i>SQL syntax error: the token ":" was not expected here
- expecting LPAREN, found ':'</i>
<b>MIN(:(? - GIORNO))</b> --> <i>- 1:25 - Open SQL syntax error: :PARAMETER not allowed
- 1:26 - SQL syntax error: the token "(" was not expected here
- 1:26 - expecting ID, found '('</i>
Then I tried to avoid the MIN() function and I tried to do just the subtraction:
<b>? - GIORNO</b> --><i> - 1:21 - the arithmetic expression >>? - "GIORNO"<< contains a host variable (parameter marker)</i>
<b>:(? - GIORNO)</b> --> <i>- 1:21 - Open SQL syntax error: :PARAMETER not allowed
- 1:22 - SQL syntax error: the token "(" was not expected here
- 1:22 - expecting ID, found '('</i>
<b>'2007-09-24' - GIORNO</b> --> <i>- 1:34 - SQL syntax error: first argument of operator "-" must be a number, date/time or interval
- 1:43 - SQL syntax error: arguments of operator "-" do not have correct types
- 1:43 - SQL syntax error: derived columns in SELECT list with AS must be values</i>
<b>GIORNO - GIORNO</b> --> <i>- 1:21 - the group by list and the select list are inconsistent: the column >>"GIORNO"<< is neither grouped nor aggregated
- 1:30 - the group by list and the select list are inconsistent: the column >>"GIORNO"<< is neither grouped nor aggregated</i>
Why these parts of query are not accepted???
I don't understand why... I hope you can help me.
Best Regards
Alessandro -
How can I get the elapse time for execution of a Query for a session
Hi ,
How can I get the elapse time for execution of a Query for a session?
Example - I have a report based on the procedure ,when the user execute that it takes say 3 min. to return rows.
Is there any possible way to capture this session info. for this particular execution of query along with it's execution elapse time?
Thanks in advance.Hi
You can use the dbms_utility.get_time tool (gives binary_integer type value).
1/ Initialize you time and date of beginning :
v_beginTime := dbms_utility.get_time ;
2/ Run you procedure...
3/ Get end-time with :
v_endTime := dbms_utility.get_time ;
4/ Thus, calculate elapsed time by difference :
v_elapsTime := v_endTime - v_beginTime ;
This will give you time elapsed in of 100th of seconds...
Then you can format you result to give correct print time.
Hope it will help you.
AL -
How to add a receipt number in the following Query for PO Report
Hi Guys,
I need a help regarding following query.
Its a PO report for 11.5.10.2
select distinct pv.segment1 supplier_number,
pv.vendor_name supplier_name,
pha.segment1 po_number,
pha.revision_num revision_num,
pha.authorization_status po_status,
to_char(pha.creation_date, 'DD/MM/YYYY') creation_date,
pha.currency_code currency_code,
pla.sum_amount_ordered sum_amount_ordered,
pda.sum_quantity_ordered sum_quantity_ordered,
pda.sum_amount_received sum_amount_received,
pda.sum_quantity_received sum_quantity_received,
(pla.sum_amount_ordered - pda.sum_amount_received) sum_accrued, --AVI
( pda.sum_quantity_ordered - pda.sum_quantity_received) quantity_accrued, --AVi
to_char(rsl.date_receipt, 'DD/MM/YYYY') date_receipt,
-- rsl.receipt_num receipt_number,
ppa.segment1 project_code, ppa.project_status_code, --10.0.0.4
aia.invoice_num invoice_num,
aia.invoice_date invoice_date, --AVI
aia.creation_date invoice_creation_date, --AVI
aia.amount invoice_amount_allocated_to_po, --AVI
pla.purchase_basis,
pla.category_id,
-- pda.item_description,
haou.name organisation, --10.0.0.3
pda.sum_quantity_billed sum_quantity_billed , --10.0.0.3
gcc1.CONCATENATED_SEGMENTS,
gcc2.CONCATENATED_SEGMENTS
from po_headers_all pha,
po_vendors pv,
pa_projects_all ppa,
hr_all_organization_units haou,
(select po_header_id,
sum(quantity * unit_price) sum_amount_ordered,
org_id,
purchase_basis,
category_id
-- pla.item_description,
from po_lines_all
group by po_header_id, org_id
, purchase_basis,
category_id
-- pla.item_description
) pla,
(select pla.po_header_id,
pda.project_id,
sum(pda.quantity_ordered) sum_quantity_ordered,
sum(pda.quantity_delivered * pla.unit_price) sum_amount_received,
sum(pda.quantity_delivered) sum_quantity_received,
sum(pda.quantity_billed) sum_quantity_billed, --10.0.0.3
accrual_account_id
from po_distributions_all pda, po_lines_all pla
where pla.po_line_id = pda.po_line_id
group by pla.po_header_id, pda.project_id,accrual_account_id
) pda,
(select po_header_id, charge_account_id,
-- rsh.receipt_num,
min(rsl.creation_date) date_receipt
from rcv_shipment_lines rsl
where rsh.SHIPMENT_HEADER_ID=rsl.SHIPMENT_HEADER_ID
group by po_header_id,charge_account_id
) rsl,
(select distinct aia.invoice_num, pda.po_header_id , aia.invoice_date --10.0.0.3
, aia.creation_date , sum(aida.amount) amount
from po_distributions_all pda,
ap_invoice_distributions_all aida,
ap_invoices_all aia
where pda.po_distribution_id = aida.po_distribution_id(+)
and aia.invoice_id(+) = aida.invoice_id
Group by
aia.invoice_num, pda.po_header_id , aia.invoice_date --10.0.0.3
, aia.creation_date) aia,
(select haou2.organization_id, haou2.name
from fnd_flex_value_sets ffvs,
fnd_flex_value_norm_hierarchy ffvnh,
fnd_flex_values_vl ffvv,
hr_all_organization_units haou1,
FND_FLEX_VALUE_CHILDREN_V ffvcv,
hr_all_organization_units haou2
where ffvs.FLEX_VALUE_SET_NAME = 'CAP_CODE_BU'
and ffvs.FLEX_VALUE_SET_ID = ffvnh.flex_value_set_id
and ffvnh.parent_flex_value like 'PO%'
and ffvv.FLEX_VALUE_SET_ID = ffvnh.flex_value_set_id
and ffvv.FLEX_VALUE between ffvnh.child_flex_value_low and ffvnh.child_flex_value_high
and substr(haou1.name, 1, Instr(haou1.name, '-')) =
substr(ffvv.DESCRIPTION, 1, Instr(ffvv.DESCRIPTION, '-'))
and haou1.organization_id = fnd_global.org_id
and ffvcv.parent_flex_value = ffvnh.parent_flex_value
and ffvcv.flex_value_set_id = ffvs.flex_value_set_id
and substr(haou2.name, 1, Instr(haou2.name, '-')) =
substr(ffvcv.DESCRIPTION, 1, Instr(ffvcv.DESCRIPTION, '-'))
union --10.0.0.1
select f.organization_id, f.name --10.0.0.1
from hr_all_organization_units f --10.0.0.1
where f.organization_id = fnd_global.ORG_ID --10.0.0.1
) bu
, po_line_locations_all plla --10.0.0.4
, gl_code_combinations_kfv gcc1
,gl_code_combinations_kfv gcc2
where pv.vendor_id = pha.vendor_id
and pla.po_header_id = pha.po_header_id
and pda.po_header_id = pha.po_header_id
and pha.po_header_id = rsl.po_header_id(+)
and pda.project_id = ppa.project_id(+)
and pha.po_header_id = aia.po_header_id(+)
and aia.po_header_id = pha.po_header_id
and pla.org_id = haou.organization_id
and pha.authorization_status in ('APPROVED', 'OPEN')
and plla.po_header_id = pha.po_header_id --10.0.0.4
and plla.closed_code in ('APPROVED', 'OPEN', 'CLOSED FOR INVOICE', 'CLOSED FOR RECEIVING', 'CANCELLED') --10.0.0.4
and bu.organization_id = haou.organization_id
AND gcc1.code_combination_id = pda.accrual_account_id
AND gcc2.code_combination_id =rsl.CHARGE_ACCOUNT_ID
In the following query I have commented receipt_num using the table rcv_transaction_headers.
If I uncomment it the query results huge number of unexpected report.
How can I add receipt number to the following query?
Should I use rcv_transactions. If yes, what would be the join conditions.
Kindly help as its urgent.
Thanks in advance.
Regards
AvijitSandeep is correct. I don't have time to tell you the correct query, but mine is something like this based on Sandeep's information:
SELECT rsh.receipt_num
FROM rcv_transactions rcvt,
po_lines_all pla,
rcv_shipment_headers rsh
WHERE rcvt.shipment_header_id = rsh.shipment_header_id
AND rcvt.PO_LINE_ID = pla.PO_LINE_ID
AND pla.item_id = (select distinct inventory_item_id
from mtl_system_items
where segment1 = '1216107-2') -
Query for finding data during special holidays
Hi, i have a table for special holidays that looks like this:
PROFILE_DAY
VAR_DATE
REGULAR_HOLIDAY
1/1/2013
H_WEEK_THURSDAY
3/28/2013
H_WEEK_FRIDAY
3/29/2013
REGULAR_HOLIDAY
12/24/2013
REGULAR_HOLIDAY
12/25/2013
REGULAR_HOLIDAY
12/31/2013
And another table (LOAD_PROFILE_TEST), which contains LOAD_PROF1 values from (TIME_EQ) 0 to 24 at intervals 0.25 for (PROFILE_DAY) MONDAY to SUNDAY including REGULAR_HOLIDAY, H_WEEK_THURSDAY and H_WEEK_FRIDAY. All in all, this table contains 970 records (97 records between 0 to 24 with interval of 0.25 per PROFILE_DAY, with 10 distinct PROFILE_DAY).
TIME_EQ
PROFILE_DAY
LOAD_PROF1
LOAD_PROF2
0
REGULAR_HOLIDAY
11.47
0.25
REGULAR_HOLIDAY
11.27
0.5
REGULAR_HOLIDAY
11.3
0.75
REGULAR_HOLIDAY
11.08
0
MONDAY
11.27
0.25
MONDAY
11.33
0.5
MONDAY
11.18
Now, I have this query to update value of LOAD_PROF2 of the said table whenever parameters V_DATE_OUT & V_DATE_IN is entered:
UPDATE LOAD_PROFILE_TEST
SET LOAD_PROF2 = LOAD_PROF1 + :LOAD_DIFF
WHERE UPPER(PROFILE_DAY) IN (select UPPER(to_char(:V_DATE_OUT + (level-1), 'fmDAY'))
from dual
connect by level <= :V_DATE_IN - :V_DATE_OUT + 1
where :LOAD_DIFF is a certain pre-determined value.
This query works fine if i am trying to update regular days from MONDAY to SUNDAY. What i would like to do is to determine if the two parameter dates, V_DATE_OUT & V_DATE_IN would fall under any of the holidays on the first table LOAD_PROFILE_TEST, then update only those rows. For example, V_DATE_OUT = 12/02/2013, Monday and V_DATE_IN = 12/06/2013, Friday. The query above would update the values of LOAD_PROF2 for PROFILE_DAY - MONDAY to FRIDAY, corresponding to dates 12/02/2013 and 12/06/2013. If however, V_DATE_OUT = 12/23/2013, Monday and V_DATE_IN = 12/27/2013, Friday, this should update the rows corresponding to PROFILE_DAY - MONDAY for 12/23/2013, THURSDAY for 12/26/2013, FRIDAY for 12/27/2013, and REGULAR_HOLIDAY for the dates 12/24/2013 and 12/25/2013 since these two are included in the first table (table of holidays). This same scenario will work the same way when V_DATE_OUT and/or V_DATE_IN fall in the dates 3/28/2013 and 3/29/2013. All other dates not included in the table for special holidays will be treated according to the day they fall on (Monday thru Sunday). I hope my point is clear. Thank you in advance.Thanks for your reply. Firstly, I am using Forms [32 Bit] Version 10.1.2.0.2 (Production). I will try to explain a little further but I don't know if i can give the exact details of the tables since this would be voluminous. First i have a table REG_HOLIDAYS, whcih contain the following:
PROFILE_DAY
VAR_DATE
REGULAR_HOLIDAY
1/1/2013
H_WEEK_THURSDAY
3/28/2013
H_WEEK_FRIDAY
3/29/2013
REGULAR_HOLIDAY
12/24/2013
REGULAR_HOLIDAY
12/31/2013
REGULAR_HOLIDAY
12/25/2013
Now i have another table LOAD_PROFILE_TEST which i will simplify just to show what i wanted to do:
CREATE
TABLE LOAD_PROFILE_TEST
TIME_EQ
NUMBER (5, 2),
PROFILE_DAY
VARCHAR2 (15 BYTE),
LOAD_PROF1
NUMBER (6, 2),
LOAD_PROF2
NUMBER (6, 2)
Here are the sample values of this table:
TIME_EQ
PROFILE_DAY
LOAD_PROF1
LOAD_PROF2
0
Monday
2
0
Tuesday
2.1
0
Wednesday
2.3
0
Thursday
2.5
0
Friday
2.2
0
Saturday
2.4
0
Sunday
2.3
0
Regular_holiday
1.9
0.25
Monday
2.1
0.25
Tuesday
2.1
0.25
Wednesday
2.4
0.25
Thursday
2.2
0.25
Friday
2.5
0.25
Saturday
2.3
0.25
Sunday
2.3
0.25
Regular_holiday
2.5
However, in the actual table, TIME_EQ will start with 0 until 24 with interval of 0.25 (i.e 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, ...23.5, 23.75, 24). So for a PROFILE_DAY of 'Monday', there will be 97 rows corresponding to TIME_EQ of 0 to 24. The same is true for Tuesday, Wednesday until Sunday including Regular_holiday. All in all, this table would contain 776 rows. LOAD_PROF1 values are random values initally inputted with PROFILE_DAY and TIME_EQ.
The first goal is to UPDATE this table (LOAD_PROFILE_TEST) by updating the column LOAD_PROF2 by adding a certain parameter value, :LOAD_DIFF, say 0.1. Now, i will have two scenarios to show what i would like to happen. First, i have two date parameters :V_DATE_OUT and :V_DATE_IN.
First Case, V_DATE_OUT = 12/15/2013 (Monday); V_DATE_IN = 12/22/2013 (Sunday)
I will have this query to update said table:
UPDATE LOAD_PROFILE_TEST
SET LOAD_PROF2 = LOAD_PROF1 + :LOAD_DIFF
WHERE UPPER(PROFILE_DAY) IN (select UPPER(
to_char(
:V_DATE_OUT + (level-1),
'fmDAY'))
from dual
connect by level <=
:V_DATE_IN - :V_DATE_OUT + 1);
The output of this query would be:
TIME_EQ
PROFILE_DAY
LOAD_PROF1
LOAD_PROF2
0
Monday
2
2.1
0
Tuesday
2.1
2.2
0
Wednesday
2.3
2.4
0
Thursday
2.5
2.6
0
Friday
2.2
2.3
0
Saturday
2.4
2.5
0
Sunday
2.3
2.4
0
Regular_holiday
1.9
0.25
Monday
2.1
2.2
0.25
Tuesday
2.1
2.2
0.25
Wednesday
2.4
2.5
0.25
Thursday
2.2
2.3
0.25
Friday
2.5
2.6
0.25
Saturday
2.3
2.4
0.25
Sunday
2.3
2.4
0.25
Regular_holiday
2.5
Since, 12/15/2013 up to 12/22/2013 is from Monday to Sunday without having a particular day included in the first table, REG_HOLIDAYS, therefore all the rows with Monday to Sunday are updated.
Second Case, V_DATE_OUT = 12/23/2013 (Monday); V_DATE_IN = 12/29/2013 (Sunday)
Take note that 12/24 and 12/25 are included in the first table, REG_HOLIDAYS, therefore i need a query so that this would be my output afterwards:
TIME_EQ
PROFILE_DAY
LOAD_PROF1
LOAD_PROF2
0
Monday
2
2.1
0
Tuesday
2.1
0
Wednesday
2.3
0
Thursday
2.5
2.6
0
Friday
2.2
2.3
0
Saturday
2.4
2.5
0
Sunday
2.3
2.4
0
Regular_holiday
1.9
2.0
0.25
Monday
2.1
2.2
0.25
Tuesday
2.1
0.25
Wednesday
2.4
0.25
Thursday
2.2
2.3
0.25
Friday
2.5
2.6
0.25
Saturday
2.3
2.4
0.25
Sunday
2.3
2.4
0.25
Regular_holiday
2.5
2.6
As can be seen, since 12/23/2013 up to 12/29/2013 is from Monday to Sunday, rows with Monday upto Sunday should be updated, HOWEVER, since 12/24 and 12/25 which falls on a Tuesday and a Wednesday also were declared as holidays (included in the REG_HOLIDAYS table), instead of updating rows with PROFILE_DAY of Tuesday and Wednesday, the query should instead update rows with Regular_holiday as PROFILE_DAY and leave as is the rows with Tuesday and Wednesday. Additional note, days declared in the REG_HOLIDAYS table with PROFILE_DAY of Regular_holidays are treated as DISTINCT as in the case of 12/24 and 12/25.
The query you gave me gives the correct value if the involved days between V_DATE_OUT and V_DATE_IN is from Monday to Sunday only, otherwise it always gives Regular_holiday only regardless of the other dates queried. As in the first case above, it would give Monday to Sunday (correct) but for the second case, it will only give Regular_holiday, the other days (Monday, Thursday, Friday, Saturday and Sunday) was not outputted.
I hope this became clearer since i will still be needing this for another query which i will inquire again after resolving this issue. Thanks a lot for your help. -
Select Query for smart form-invoice
Hi Folks,
I have to fetch the following fields as per the requirement for desiging a invoice smartform.I had copied lb_bill_invoice smartform into z format.
Can anyone here please give me the select query for the same.
fields to fetched are as follows:-
1.vbrp-arktx,
2.vbrp-fkimg,
3.konv-kbetr with respect to vbrk-knumv
4.konv-kwert.
And also what all I have to give in format interface and global definitions of the smartform.
please help me in this regard.
Points will be given.
K.Kiran.Hi,
declare the variables V_arktx(40) and v_Qty like vbrp-fkimp and other varaibles for Kbetr, kwert, knumv on the global definitions.
select single arktx fkimg into (v_arktx, v_qty) from vbrp
where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
select single knumv into v_knumv from vbrk where where vbeln = LBBIL_IT_REFPURORD-BIL_NUMBER.
this select has to fire in the item level and in the loop.
so have to write in the correct place.
select kbetr kwert into (v_kbetr, v_kwert) from konv
where where knumv = v_knumv and kposn = LBBIL_IT_REFPURORD-ITM_NUMBER.
regards,
anji -
Hi All,
I have a line UDF called U_PO in the sales order documents that denotes our purchase order number that particular item is ordered on.
I have another line UDF called U_XMill which I want to populate with the corresponding PO document due date.
What would be my query for that?
Basically, it should be something like:
SELECT T0.DocDueDate FROM OPOR T0 WHERE T0.DocNum=$[$38.44.0] FOR BROWSE
However, I am sure that "38.44" is wrong.
It should denote my current document's UDF *.U_PO.
And I am not sure what would be the correct notation for it.
I was wondering if there was a help document I could refer to to figure out the corresponding field numbers for the cases like this.
Thank you for your help.Hello
use FMS on matrix (tables) as
[ItemUID.ColumnUID.Type] or [TableName.FieldName]
where itemUID is 38
ColumnUID is U_XMill
Type is 0 (general).
There is a now-to guide on service.sap.com/smb/sbo where you can find how to us FMS.
Regards
J -
Question/issue regarding querying for uncommited objects in Toplink...
Hi, was hoping to get some insight into this problem we are encoutering
We have this scenario were we are creating a folder hierarchy (using Toplink)
1. a parent folder is created
2. child elements are created (in the same transaction as step 1),
3. we need to lookup the parent folder and assign it as the parent
of these child elements
4. end the transaction and commit all data
In our system we control access to objects by appending a filter to the selection criteria, so we end up with SQL like this example
(The t2 stuff is the authorization lookup part of the query.) ;
SELECT t0.ID, t0.CLASS_NAME, t0.DESCRIPTION, t0.EDITABLE,
t0.DATE_MODIFIED, t0.DATE_CREATED,
t0.MODIFIED_BY, t0.ACL_ID, t0.NAME, t0.CREATED_BY,
t0.TYPE_ID, t0.WKSP_ID, t1.ID, t1.LINK_SRC_PATH,
t1.ABSOLUTE_PATH, t1.MIME_TYPE, t1.FSIZE,
t1.CONTENT_PATH, t1.PARENT_ID
FROM XDOOBJECT t0, ALL_OBJECT_PRIVILEGES t2,
ARCHIVEOBJECT t1
WHERE ((((t1.ABSOLUTE_PATH = '/favorites/twatson2')
AND ((t1.ID = t2.xdoobject_id)
AND ((t2.user_id = 'twatson2')
AND (bitand(t2.privilege, 2) = 2))))
AND (t1.ID = t0.ID))
AND (t0.CLASS_NAME = 'oracle.xdo.server.repository.model.Archivable'))
When creating new objects we also create the authorization lookup record (which is inserted into a different table.) I can see all the objects are registered in the UOW identity map.
Basically, the issue is that this scenario all occurs in a single transaction and when querying for the newly created parent folder, if the authorization filter is appended to the query, the parent is not found. If I remove the authorization filter then the parent is found correctly. Or if I break this up into separate transactions and commit after each insert, then the parent is found correctly.
I use the conformResultsInUnitOfWork attribute on the queries.
This is related to an earlier thread I have in this discussion forum;
Nested UnitOfWork and reading newly created objects...
Thanks for any help you can provide,
-TimHi Doug, we add the authorization filter directly in the application code as the query is getting set up.
Here are some code examples; 1) the first is the code to create new object in the system, followed by 2) the code to create a new authorization lookup record (which also uses the first code to do the actual Toplink insert), then 3) an example of a read query where the authorization filter is appended to the Expression and after that 4) several helper methods.
I hope this is of some use as it's difficult to show the complete flow in a simple example.
1)
// create new object example
public Object DataAccess.createObject(....
Object result = null;
boolean inTx = true;
UnitOfWork uow = null;
try
SessionContext sc = mScm.getCurrentSessionContext();
uow = TLTransactionManager.getActiveTransaction(sc.getUserId());
if (uow == null)
Session session = TLSessionFactory.getSession();
uow = session.acquireUnitOfWork();
inTx = false;
Object oclone = (Object) uow.registerObject(object);
uow.assignSequenceNumbers();
if (oclone instanceof BaseObject)
BaseObject boclone = (BaseObject)oclone;
Date now = new Date();
boclone.setCreated(now);
boclone.setModified(now);
boclone.setModifiedBy(sc.getUserId());
boclone.setCreatedBy(sc.getUserId());
uow.printRegisteredObjects();
uow.validateObjectSpace();
if (inTx == false) uow.commit();
//just temp, see above
if (true == authorizer.requiresCheck(oclone))
authorizer.grantPrivilege(oclone);
result = oclone;
2)
// Authorizer.grantPrivilege method
public void grantPrivilege(Object object) throws DataAccessException
if (requiresCheck(object) == false)
throw new DataAccessException(
"Object does not implement Securable interface.");
Securable so = (Securable)object;
ModulePrivilege[] privs = so.getDefinedPrivileges();
BigInteger pmask = new BigInteger("0");
for (int i = 0; i < privs.length; i++)
BigInteger pv = PrivilegeManagerFactory.getPrivilegeValue(privs);
pmask = pmask.add(pv);
SessionContext sc = mScm.getCurrentSessionContext();
// the authorization lookup record
ObjectUserPrivilege oup = new ObjectUserPrivilege();
oup.setAclId(so.getAclId());
oup.setPrivileges(pmask);
oup.setUserId(sc.getUserId());
oup.setXdoObjectId(so.getId());
try
// this recurses back to the code snippet from above
mDataAccess.createObject(oup, this);
catch (DataAccessException dae) {
Object[] args = {dae.getClass().toString(), dae.getMessage()};
logger.severe(MessageFormat.format(EXCEPTION_MESSAGE, args));
throw new DataAccessException("Failed to grant object privilege.", dae);
3)
// example Query code
Object object = null;
ExpressionBuilder eb = new ExpressionBuilder();
Expression exp = eb.get(queryKeys[0]).equal(keyValues[0]);
for (int i = 1; i < queryKeys.length; i++)
exp = exp.and(eb.get(queryKeys[i]).equal(keyValues[i]));
// check if need to add authorization filter
if (authorizer.requiresCheck(domainClass) == true)
// this is where the authorization filter is appended to query
exp = exp.and(appendReadFilter());
ReadObjectQuery query = new ReadObjectQuery(domainClass, exp);
SessionContext sc = mScm.getCurrentSessionContext();
if (TLTransactionManager.isInTransaction(sc.getUserId()))
// part of a larger transaction scenario
query.conformResultsInUnitOfWork();
else
// not part of a transaction
query.refreshIdentityMapResult();
query.cascadePrivateParts();
Session session = getSession();
object = session.executeQuery(query);
4)
// builds the authorzation filter
private Expression appendReadFilter()
ExpressionBuilder eb = new ExpressionBuilder();
Expression exp1 = eb.getTable("ALL_OBJECT_PRIVILEGES").getField("xdoobject_id");
Expression exp2 = eb.getTable("ALL_OBJECT_PRIVILEGES").getField("user_id");
Expression exp3 = eb.getTable("ALL_OBJECT_PRIVILEGES").getField("privilege");
Vector args = new Vector();
args.add(READ_PRIVILEGE_VALUE);
Expression exp4 =
exp3.getFunctionWithArguments("bitand",args).equal(READ_PRIVILEGE_VALUE);
SessionContext sc = mScm.getCurrentSessionContext();
return eb.get("ID").equal(exp1).and(exp2.equal(sc.getUserId()).and(exp4));
// helper to get Toplink Session
private Session getSession() throws DataAccessException
SessionContext sc = mScm.getCurrentSessionContext();
Session session = TLTransactionManager.getActiveTransaction(sc.getUserId());
if (session == null)
session = TLSessionFactory.getSession();
return session;
// method of TLTransactionManager, provides easy access to TLSession
// which handles Toplink Sessions and is a singleton
public static UnitOfWork getActiveTransaction(String userId)
throws DataAccessException
TLSession tls = TLSession.getInstance();
return tls.getTransaction(userId);
// the TLSession method, returns the active transaction (UOW)
// or null if none
public UnitOfWork getTransaction(String uid) {
UnitOfWork uow = null;
UowWrapper uw = (UowWrapper)mTransactions.get(uid);
if (uw != null) {
uow = uw.getUow();
return uow;
Thanks!
-Tim -
Hi,
I am using OLE DB Source to fetch the records with Data Access Mode as SQL COMMAND which is using the below query with a parameter,
SELECT CON.Title,CON.FirstName,EMP.MaritalStatus,EMP.Gender,EMP.Title AS Designation, EMP.HireDate, EMP.BirthDate,CON.EmailAddress, CON.Phone
from HumanResources.Employee EMP INNER JOIN Person.Contact CON ON EMP.ContactID=CON.ContactID WHERE EMP.Title in (?)
In this query for the parameter I am passing the value from a variable and which is configured (XML Configuration). While passing value
Buyer it works correctly. But while passing values Accountant,Buyer
it is not working as expected.
How to handle while passing such multiple values Or is it possible to pass such values or not in SSIS 2012 ?
Kindly help me to find a solution.
NOTE: I placed the whole query in a variable as a expression as below it is working fine.
"select CON.Title,CON.FirstName,EMP.MaritalStatus,EMP.Gender,EMP.Title AS Designation,EMP.HireDate,EMP.BirthDate,CON.EmailAddress,CON.Phone from HumanResources.Employee EMP
INNER JOIN Person.Contact CON ON EMP.ContactID=CON.ContactID WHERE EMP.Title in ('" + REPLACE(@[User::temp],",","','") +"')"
Any other solution is there ? without placing the query in a variable. May be a variable can have some limitations for no. of characters stored not sure just a thought.
SridharPutting the whole thing into a variable is certainly a valid solution. The other involves putting the comma delimited list into a table valued variable.
http://gallery.technet.microsoft.com/scriptcenter/T-SQL-Script-to-Split-a-308206f3
For an odd ball approach:
http://www.sqlmovers.com/shredding_multiline_column_using_xml/ .
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com -
Hi,
I am having trouble running a query to get the "installed on Date". I am not very good at this. I've been using the script below, but I can't get the correct language for the installed on date. I'm hoping someone can help me complete it and
tell me what I need to enter below the ???. Any help would be greatly appreciated! Thanks.
select SMS_R_System.NetbiosName,
SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName from
SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on
SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceId =
SMS_R_System.ResourceId where
SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName like "%????%"When you answer Sherry's question, you'll probably realize that you could perhaps use SSRS (reporting) instead of WQL query (if you just want a list instead of a collection). As Sherry mentions, it depends on what you plan on doing with the data.
As for your question about the "installed on date", what exactly are you asking? Do you want to know the name of the Installed Date field?
Replace ??? with an actual string form a software name...
SQL
SELECT
SYS.Name0
,ARP.DisplayName0
,ARP.InstallDate0
FROM
v_R_System As SYS
inner join v_GS_ADD_REMOVE_PROGRAMS As ARP on ARP.ResourceId = SYS.ResourceId
WHERE
ARP.DisplayName0 like '%???%'
WQL
SELECT
SYS.NetbiosName
,ARP.DisplayName
,ARP.InstallDate
FROM
SMS_R_System As SYS
inner join SMS_G_System_ADD_REMOVE_PROGRAMS As ARP on ARP.ResourceId = SYS.ResourceId
WHERE
ARP.DisplayName like "%???%"
This got me the results,, but does not show the installed on date. I Am I missing something to enter? -
Query for item warehouses stock in a row
hi all,
How to retreive item warehouse stock in a row using query ?
SELECT T0.ItemCode, T1.ItemName, T2.ItmsGrpNam,
(Select WhsCode from OITW Where
WhsCode=T0.WhsCode and ItemCode=T0.ItemCode) as 'Wh',
(Select OnHand From OITW Where
Whscode = T0.WhsCode and Itemcode=T0.ItemCode) as 'Whstck'
FROM OITW T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod
WHERE T0.ItemCode NOT IN 'a-item'AND
T2.ItmsGrpNam LIKE '%%test%%'
and T0.Onhand > 0
ORDER BY T0.ItemCode
Anyone correct query so that it will retrieve item warehouse stock in a single row.
Thanks
JeyakanthanI have tested your query, the result is just like you wish. The code can be simplified to:
SELECT T0.ItemCode, T1.ItemName, T2.ItmsGrpNam, T0.WhsCode as 'Wh',T0.OnHand as 'Whstck'
FROM DBO.OITW T0
INNER JOIN DBO.OITM T1 ON T0.ItemCode = T1.ItemCode
INNER JOIN DBO.OITB T2 ON T1.ItmsGrpCod = T2.ItmsGrpCod
WHERE T0.ItemCode NOT IN ('a-item') AND T2.ItmsGrpNam LIKE '%[%test%]%'
and T0.Onhand > 0
ORDER BY T0.ItemCode, T0.WhsCode
If you want each item has only one row and warehouse on hand column-wised, you have to use as much as SELECT for each column in according to your number of warehouses. It would be look like this one:
SELECT T0.ItemCode, T0.ItemName, T1.ItmsGrpNam,
(SELECT OnHand FROM OITW WHERE ItemCode = T0.ItemCode AND WhsCode Like 'Whs1') AS 'Whs1 On Hand' ,
(SELECT OnHand FROM OITW WHERE ItemCode = T0.ItemCode AND WhsCode Like 'Whs2') AS 'Whs2 On Hand' ,
(SELECT OnHand FROM OITW WHERE ItemCode = T0.ItemCode AND WhsCode Like 'Whs3') AS 'Whs3 On Hand'
FROM DBO.OITM T0
INNER JOIN DBO.OITB T1 ON T1.ItmsGrpCod = T0.ItmsGrpCod
WHERE T0.ItemCode NOT IN ('a-item') AND T1.ItmsGrpNam LIKE '%[%test%]%'
and T0.Onhand > 0
ORDER BY T0.ItemCode
Thanks,
Gordon -
Retrieve underlying SQL query for deski report via java SDK in BOXIR2
Hi all,
I am trying to retrieve underlying SQL queries of a deski report in BOXIR2. However I find the error as
oDataProvider = oDocumentInstance.getDataProviders().getItem(i1);
System.out.print(oDataProvider.getName());
oSQLDataProvider = (SQLDataProvider) oDataProvider;
oSQLContainer_root = oSQLDataProvider.getSQLContainer();
But "This feature is not supported for desktop Intelligence " exception has occured.
I am running the same query for Webi, and I did not find any issue . After several time spending in google, it appears to me that this code is supported by webi only. But "This feature is not supported for desktop Intelligence " exception has occured.
Please help me to find out the solution in java SDK. If its not supported by Java SDK, then could you please provide me any workaround , e.g. any macro . Any help !!
Regards,
Nita
Edited by: Nita Prasad on Aug 11, 2009 11:20 AM
Edited by: Nita Prasad on Aug 11, 2009 11:25 AMHi Fritz,
I am not getting the way.. how to open the deski report programmatically. I am writing the code in this way:
Dim oInfoObjects1 As CrystalInfoStoreLib.InfoObjects
Set oInfoObjects1 = oInfoStore.Query("SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME='" & oInfoObject.Title & "' AND SI_ID='" & oInfoObject.Id & "' order by SI_NAME")
Dim oInfoObject1 As CrystalInfoStoreLib.InfoObject
Dim UserCount1 As Integer
UserCount1 = oInfoObjects1.ResultCount
MsgBox "SELECT * FROM CI_INFOOBJECTS WHERE SI_NAME=' " & oInfoObject.Title & " ' AND SI_ID=' " & oInfoObject.Id & " ' order by SI_NAME"
MsgBox " Total number of Deski reports are : [" & UserCount1 & "]", vbOKOnly
Dim j As Integer
For j = 1 To UserCount1
Set oInfoObject1 = oInfoObjects1.Item(i)
sFile_ReportList = StrConv(oInfoObject1.Title, vbLowerCase) & ".rep"
sFile_Output = "D:\TraceWrite1\ " & StrConv(oInfoObject1.Id & "_" & oInfoObject1.Title, vbLowerCase) & ".txt"
sFile_ReportListTemp = StrConv(oInfoObject1.Files.Item(j), vbLowerCase)
MsgBox "[" & sFile_ReportList & "]", vbOKOnly
If Dir(sFile_ReportList) = "" Then
MsgBox "The text file [" & sFile_ReportList & "] for the DeskI documents does not exist!" & vbCrLf & "Aborting process."
Exit Sub
End If
I am getting the error on line ... If Dir(sFile_ReportList) = "" Then... The code is not able to locate the deski report path.
Is this the correct way to get a deski report information? Please let me know, If I am going in the right direction.
Edited by: Nita Prasad on Aug 18, 2009 3:47 PM -
How to Enable the LOV to query for partial user entries in af:query in an ADF search form
Hi guys,
I have faced one issue in creating a search form in ADF, in that I have used af:query and table region. and I have attached an lov vo to the base vo for the list of values and given UI hint as Input values with List of values. Now the issue is that I have given auto submit property as true so when I give some value suppose "Jan-14" and tab out it gives me all the correct results. but if I give like "Jan%" and then tab out then it does not give me any value. Could you kindly help me with some solution. I am using Jdev 11.1.1.6.0.
Thanks,
TanmoyTo enable the LOV to query for partial user entries, we can trap the 'LaunchPopupListener' event and add custom code there. Within the af:query component, just wondering how can we set property the 'LaunchPopupListener' for the search criteria ?
Maybe you are looking for
-
Did you mean: I need the toolbar mine disappeared I want to try to reinstall it hope i don't lose my passwords and bookmarks == This happened == Every time Firefox opened == User Agent == Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2;
-
A coworker that works in Oracle told me today that he heard that a future release of SQL Developer was going to be integrated with Apex. Is that correct? If so, does anyone know how the two products will be integrated? Thanks, Tony
-
Continuously get a value in order to autofill a text box.
I am creating a type of KPI scoreboard that will tell the user what type of level they are currently operating in depending how they respond to four questions. I have set it up so that: Column 1 = Strongly Disagree = 0 Column 2 = Disagree = 1 Column
-
Hi All, Is there a place where we can go and see who created a certain variable and last changed as we can see the query properties? Thanks GMS
-
Problems Embedding swf In Site Built and "Sliced" From Photoshop CS5
Made a slide-show in Flash, and want to embed in new site that is being constructed. When using "Insert/Media/swf", or copying the code that came with the swf file, it "Splits up" the website in DW. It's like it gets cracked like a mirror. However, i