Urgent Group by Having Clause Fails in Oracle and Works in Sybase
Hello EveryBody I need to select curve data of curve whose date is maximum in that curve so say if i ahve
so if records are
curveid curvename curvedate
1001 test1 12/12/1003
1001 test1 12/13/1003
1002 test2 12/12/2002
1002 test2 12/12/2004
I have query which run well in sybase but oracle screw up...My logic say having clause is use to filter the records of group so it should have worked in oracle.....
Here is query
select curveid,curvename from curve group by curveid having curvedate =max(curve_date)
This give "not a Group by " error in oracle....It work well in sybase...
ORA-00979: not a GROUP BY expression
I have query which use subquery to select these records but i don't want that to use that query
Please help
please understand what I need the result
for each curve i need that data of that curve who date is max in that curve group
so say for 1001 there are two date 1/1/2001 and 1/1/2002
I need the data of curve 1001 with date 1/1/2002
Oracle should have some alternative solution for this....
If i have to use subquery I do have subquery
select a.curveid, b.curvename from curve a group by curveid having curvedate = (select max(curvedate) from curve where a.curveid=b.curveid group by curveid );
I don't want to use that ,,,
I want to solve my probelm using having and group/....
Main purpose of having is to filter the records from group result so IT SHOULD DO THAT WHY ORACLE GIVE ORA ERROR FOR
group by curve_id having curve_date=max(curve_date)
Creators of oracle please reply
Similar Messages
-
Group By -- Having Clause related doubt.
Hello,
Can we Write/Use rather a 'Having Condition' Before a Group by Clause ..?
If Yes then How does it Work.. I mean a 'Having' is a WHERE clause (filter) on Aggregate results ...
SO how does Having works before grouping the Results..??Hi,
Aijaz Mallick wrote:
Hello,
Can we Write/Use rather a 'Having Condition' Before a Group by Clause ..?What happens when you try it?
If Yes then How does it Work.. I mean a 'Having' is a WHERE clause (filter) on Aggregate results ... Right; the HAVING clause is like another WHERE clause.
The WHERE clause is applied before the GROUP BY is done, and the aggregate functions are computed.
The HAVING clause is applied after the GROUP BY is done, and the aggregate functions are computed, so you can use aggregate functions in the HAVING clause.
SO how does Having works before grouping the Results..??The order in which clauses appear in your code isn't necessarily the order in which they are performed. For example,
SELECT job
, COUNT (*) AS cnt
FROM scott.emp
GROUP BY job;Does it confuse you that this query can reference COUNT (*) in the SLECT clause, which is before the GROUP BY clause?
The SELECT clause which always comes before the GROUP BY clause in code. That does not mean that the SELECT clause is completed before the GROUP BY clause is begun.
If the documentation says that clauses must be in a certain order, then use that order, even if your current version of Oracle allows them to be in a different order. There's no guarantee that the next version of Oracle will allow something that was always said to be wrong. -
Urgent:IMP-00017: following statement failed with ORACLE error 3113
OS:HP_UX 11i
Oracle 9.2.0.3.0
when import tablespace metadata,
comand is "imp \'sys/sysadmin AS sysdba\' TRANSPORT_TABLESPACE=y DATAFILES='/oradata/data2/
B.dbf' TABLESPACES=A FILE=A.dmp IGNORE=Y LOG=./log/import.log"
the error occurs as followed:
Export file created by EXPORT:V09.02.00 via conventional path
About to import transportable tablespace(s) metadata...
import done in US7ASCII character set and AL16UTF16 NCHAR character set
import server uses WE8ISO8859P1 character set (possible charset conversion)
. importing SYS's objects into SYS
IMP-00017: following statement failed with ORACLE error 3113:
"BEGIN sys.dbms_plugts.beginImport ('9.2.0.3.0',31,'2000',NULL,'NULL',3626"
"7,35051,1); END;"
IMP-00003: ORACLE error 3113 encountered
ORA-03113: end-of-file on communication channel
IMP-00000: Import terminated unsuccessfully
export is in same enviorment, the successful informantion below:
exp \'sys/sysadmin AS sysdba\' TRANSPORT_TABLESPACE=y TABLESPACES=A FILE=A.dmp
LOG=./log/export.log
log file:
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
server uses WE8ISO8859P1 character set (possible charset conversion)
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
For tablespace A ...
. exporting cluster definitions
. exporting table definitions
. . exporting table A
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.I do it,but the same error message.
export message:
Connected to: Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.3.0 - Production
Export done in WE8ISO8859P1 character set and AL16UTF16 NCHAR character set
Note: table data (rows) will not be exported
About to export transportable tablespace metadata...
For tablespace A ...
. exporting cluster definitions
. exporting table definitions
. . exporting table A
. exporting referential integrity constraints
. exporting triggers
. end transportable tablespace metadata export
Export terminated successfully without warnings.
Import Message:
Export file created by EXPORT:V09.02.00 via conventional path
About to import transportable tablespace(s) metadata...
import done in WE8ISO8859P1 character set and AL16UTF16 NCHAR character set
. importing SYS's objects into SYS
IMP-00017: following statement failed with ORACLE error 3113:
"BEGIN sys.dbms_plugts.beginImport ('9.2.0.3.0',31,'2000',NULL,'NULL',3627"
"7,36451,1); END;"
IMP-00003: ORACLE error 3113 encountered
ORA-03113: end-of-file on communication channel
IMP-00000: Import terminated unsuccessfully -
Group by having clause problem
Hi,
I have a query like this:
select a.id,a.first_nm,a.last_nm,a.subgroup_id
from temp a
where (a.subgroup_id like 'D%' or a.subgroup_id like 'G%')
group by a.id,a.first_nm,a.last_nm,a.subgroup_id having
count(*) >1
union
select b.id,b.first_nm,b.last_nm,b.subgroup_id
from temp b
where b. subgroup_id like 'F%'
group by b.id,b.first_nm,b.last_nm,b.subgroup_id having count(*) > 2;
I want the result like this:
10001 Wendy Lin DAP
10001 Wendy Lin GMP
10002 Jim Davis FAD
10002 Jim Davis FIP
10002 Jim Davis FIAP
My query above didn't give the right result, Can someone help me?
Thank you very much!
WendyYou may like to try this way...
select id,name,sub_id
from a
where id in (select id
from a
group by id
having count(id)>1)
order by id,name, sub_id asc;
results are..
ID NAME CODE
1 wendy DIA
1 wendy LCA
1 wendy PLA
2 jim CPR
2 jim DIA
2 jim PLA
Hope this helps. -
User names with apostrophes failing in Oracle and SQL
Attempting to pass a name with an apostrophe through and getting ORA-1756. How can I get this to work for my usernames with apostrphes
SELECT 'O''Brian'
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Failing on ATM and working in ISDN
I am facing problem in accessing Lotus notes application when connected through 1 mb ATM link. But the same application is working through an low speed ISDN link. All other IP applications working fine. Scarambling is enabled,No errors on ATM port. Central site is E3 link .I tried PPPoATM with MTU similar to that of isdn. Qos applied for Lotus notes port, changed the routrer to 2811, But no luck. Could any body help..
I tried both MTU 1500 and normal mtu 4470.
With both all IP applications are working perfcetly except the Lotus notes, But it is wotking with ISDN. I tried giving high priority for LOtus notes port with QOS no luck.
CONFIGURATION
interface ATM0/0/0
no ip address
scrambling-payload
mtu 1500
atm pvc 2 1 1 aal5ciscoppp 1024 1024 Virtual-Template2
atm ilmi-keepalive
interface Virtual-Template2
ip address 170.71.240.243 255.255.255.248
router eigrp 4001
passive-interface default
no passive-interface Virtual-Template2 -
Get inf. about user, rol and group, which shows and works on my webdynpro ?
Hi everybody,
Can someone help me? I need the information about rol and group of the user, who's show and work on my webdynpro?Hi,
You can use the below code to get the information you need. You need to add the jar file com.sap.security.api.jar to your Web Dynpro project's build path.
IRoleFactory roleFactory= UMFactory.getRoleFactory();
IGroupFactory groupFactory = UMFactory.getGroupFactory();
try
IWDClientUser wdUser = WDClientUser.getCurrentUser();
IUser user = wdUser.getSAPUser();
Iterator assignedRoles = user.getRoles(true); // true means all the roles are searched recursively
Iterator assignedGroups = user.getParentGroups(true); // true means all the groups are searched recursively
while(assignedRoles.hasNext())
String roleID = (String)assignedRoles.next();
IRole role = roleFactory.getRole(roleID);
String roleName = role.getUniqueName();
// Fill your model node with the role
while(assignedGroups.hasNext())
String groupID = (String)assignedGroups.next();
IGroup group = groupFactory.getGroup(groupID);
String groupName = group.getUniqueName();
// fill your model node with group.
catch(Exception ex)
messageManager.reportException(ex.getLocalizedMessage(),false); -
Use of group by and having clause
hi frnds
can anybody explain me the use of group by an having clause in select state mentHi Rohit,
1. GROUP BY f1 ... fn
2. GROUP BY (itab)
1. GROUP BY f1 ... fn
Effect
Groups database table data in a SELECT command on one line in the result set. A group is a set of lines which all have the same values in each column determined by the field descriptors f1 ... fn.
... GROUP BY f1 ... fn always requires a list in the SELECT clause. If you use field descriptors without an aggregate funciton in the SELECT clause, you must list them in the GROUP BY f1 ... fn clause.
Example
Output the number of passengers, the total weight and the average weight of luggage for all Lufthansa flights on 28.02.1995:
TABLES SBOOK.
DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
DATA: CONNID LIKE SBOOK-CONNID.
SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
INTO (CONNID, COUNT, SUM, AVG)
FROM SBOOK
WHERE
CARRID = 'LH' AND
FLDATE = '19950228'
GROUP BY CONNID.
WRITE: / CONNID, COUNT, SUM, AVG.
ENDSELECT.
Note
... GROUP BY f1 ... fn is not supported for pooled and cluster tables.
2. GROUP BY (itab)
Effect
Works like GROUP BY f1 ... fn if the internal table itab contains the list f1 ... fn as ABAP source code. The internal table itab can only have one field. This field must be of the type C and should not be more than 72 characters long. itab must be enclosed in parentheses and there should be no blanks between the parentheses and the table name.
Note
The same restrictions apply to this variant as to GROUP BY f1 ... fn.
Example
Output all Lufthansa departure points with the number of destinations:
TABLES: SPFLI.
DATA: BEGIN OF WA.
INCLUDE STRUCTURE SPFLI.
DATA: COUNT TYPE I.
DATA: END OF WA.
DATA: WA_TAB(72) TYPE C,
GTAB LIKE TABLE OF WA_TAB,
FTAB LIKE TABLE OF WA_TAB,
COUNT TYPE I.
CLEAR: GTAB, FTAB.
WA_TAB = 'COTYFROM COUNT( * ) AS COUNT'. APPEND FTAB.
APPEND WA_TAB TO FTAB.
WA_TAB = 'CITYFROM'.
APPEND WA_TAB TO GTAB.
SELECT DISTINCT (FTAB)
INTO CORRESPONDING FIELDS OF WA
FROM SPFLI
WHERE
CARRID = 'LH'
GROUP BY (GTAB).
WRITE: / WA-CITYFROM, WA-COUNT.
ENDSELECT.
Regards,
Susmitha -
How to have Having clause in Group by
Hi All,
While using aggregated function (max,min etc) on columns, the SQL generated automatically has the non aggregated columns in the group by clause. How to specify the Having condition ?
select a , max(b)
from t
group by a
having <condition>
TIA...Hi,
In your interface drag and drop the source column into canvas for which you want to generate the HAVING clause.
It will create filters for those columns .Now use aggregation functions like SUM, MAX,MIN, AVG etc in that filter query .
The code generated will now contain the HAVING clause in it .
Thanks,
Sutirtha -
Group by clause and having clause in select
hi frnds
plz give me some information of group by and having clause used in select statement with example
thanksThe Open SQL statement for reading data from database tables is:
SELECT <result>
INTO <target>
FROM <source>
[WHERE <condition>]
[GROUP BY <fields>]
[HAVING <cond>]
[ORDER BY <fields>].
The SELECT statement is divided into a series of simple clauses, each of which has a different part to play in selecting, placing, and arranging the data from the database.
You can only use the HAVING clause in conjunction with the GROUP BY clause.
To select line groups, use:
SELECT <lines> <s1> [AS <a1>] <s2> [AS <a2>] ...
<agg> <sm> [AS <am>] <agg> <sn> [AS <an>] ...
GROUP BY <s1> <s2> ....
HAVING <cond>.
The conditions <cond> that you can use in the HAVING clause are the same as those in the SELECT clause, with the restrictions that you can only use columns from the SELECT clause, and not all of the columns from the database tables in the FROM clause. If you use an invalid column, a runtime error results.
On the other hand, you can enter aggregate expressions for all columns read from the database table that do not appear in the GROUP BY clause. This means that you can use aggregate expressions, even if they do not appear in the SELECT clause. You cannot use aggregate expressions in the conditions in the WHERE clause.
As in the WHERE clause, you can specify the conditions in the HAVING clause as the contents of an internal table with line type C and length 72.
Example
DATA WA TYPE SFLIGHT.
SELECT CONNID
INTO WA-CONNID
FROM SFLIGHT
WHERE CARRID = 'LH'
GROUP BY CONNID
HAVING SUM( SEATSOCC ) > 300.
WRITE: / WA-CARRID, WA-CONNID.
ENDSELECT.
This example selects groups of lines from database table SFLIGHT with the value LH for CARRID and identical values of CONNID. The groups are then restricted further by the condition that the sum of the contents of the column SEATSOCC for a group must be greater than 300.
The <b>GROUP BY</b> clause summarizes several lines from the database table into a single line of the selection.
The GROUP BY clause allows you to summarize lines that have the same content in particular columns. Aggregate functions are applied to the other columns. You can specify the columns in the GROUP BY clause either statically or dynamically.
Specifying Columns Statically
To specify the columns in the GROUP BY clause statically, use:
SELECT <lines> <s1> [AS <a 1>] <s 2> [AS <a 2>] ...
<agg> <sm> [AS <a m>] <agg> <s n> [AS <a n>] ...
GROUP BY <s1> <s 2> ....
To use the GROUP BY clause, you must specify all of the relevant columns in the SELECT clause. In the GROUP BY clause, you list the field names of the columns whose contents must be the same. You can only use the field names as they appear in the database table. Alias names from the SELECT clause are not allowed.
All columns of the SELECT clause that are not listed in the GROUP BY clause must be included in aggregate functions. This defines how the contents of these columns is calculated when the lines are summarized.
Specifying Columns Dynamically
To specify the columns in the GROUP BY clause dynamically, use:
... GROUP BY (<itab>) ...
where <itab> is an internal table with line type C and maximum length 72 characters containing the column names <s 1 > <s 2 > .....
Example
DATA: CARRID TYPE SFLIGHT-CARRID,
MINIMUM TYPE P DECIMALS 2,
MAXIMUM TYPE P DECIMALS 2.
SELECT CARRID MIN( PRICE ) MAX( PRICE )
INTO (CARRID, MINIMUM, MAXIMUM)
FROM SFLIGHT
GROUP BY CARRID.
WRITE: / CARRID, MINIMUM, MAXIMUM.
ENDSELECT.
regards
vinod -
Why Scalar Subquery expression cannot be used in HAVING clauses?
Hi All,
I'm new to SQL. I'm confused with Scalar Subquery.
Is there anyone who can answer me why Scalar Subquery expression cannot be used in HAVING clauses.
Can you show me a example?
Thanks very much,
Xianyi.Ye
Edited by: 908428 on 2012-1-16 下午7:24Hi,
908428 wrote:
Hi Frank,
Thank you for your quick reply. I also agree with your point.
But when I read the book, "OCA Oracle Database SQL Certified Expert Exam Guide",( link to illegal copies of book removed by moderator )
on Page 359, it said that
Scalar subquery expressions cannot be used in the following locations:
1. In CHECK constraints
2. In GROUP BY clauses
3. In HAVING clauses
4. In a function-based index (which is coming up in Chapter 11)
5. As a DEFAULT value for a column
6. In the RETURNING clause of any DML statement
7. In the WHEN conditions of CASE
8. In the START WITH and CONNECT BY clauses, which we discuss in
Chapter 16.7 and 8 are wrong. Scalar sub-queries can be used in WHEN conditions and START WITH and CONNECT BY clauses. (At least in Oracle 10.2. Is the book based on some earlier version?)
Edited by: BluShadow on 17-Jan-2012 09:08 -
Procedure failed while using bulk collect into clause and works with cursor
hi all,
I am using "BULK collect into" clause in my procedure and it is failing after 21 minutes and gives the error "end of file communication channel".
after this error comes when i tried to connect database it is giving following error.
ORA -01034 - Oracle not available.
ORA- 27101 - shared memory realm does not exist.
svr4- error :2 : No such file or directory.
when i use cursor instead of BULK COLLECT INTO clause it is running successful.
Following code is working with cursor.
procedure work_kiosk_full(an_jobid in number ,ac_sqlcode out varchar2 ,ac_sqlerrm out varchar2) is
ld_curr_time Date;
cursor cur_work_kiosk is
select distinct jt.jt_id AS jt_id,
NVL ((ROUND ((jt_date_completed - jt_date_requested) * 24, 2)
0
) AS actual_hrs_to_complete,
NVL ((ROUND ((jt_date_responded - jt_date_requested) * 24, 2)
0
) AS actual_hrs_to_respond,
peo1.peo_name AS agent_name,
peo1.peo_user_name AS asagent_soe_id,
le.lglent_desc AS ap_system,
' ' AS assign_work_request_comment,
DECODE (jt.jt_bill_id,
138802, 'CLIENT BILLABLE',
138803, 'CONTRACTED',
138804, 'INTERNAL BILLABLE',
NULL, ' '
) AS billable,
bl.bldg_name_cc AS building, bl.bldg_id_ls AS building_id,
DECODE (bl.bldg_active_cc,
'Y', 'ACTIVE',
'INACTIVE'
) AS building_status,
DECODE (jt.jt_wrk_cause_id,
141521, 'STANDARD WEAR AND TEAR',
141522, 'NEGLIGENCE',
141523, 'ACCIDENTAL',
141524, 'MECHANICAL MALFUNCTION',
141525, 'OVERSIGHT',
141526, 'VANDAL',
141527, 'STANDARD',
141528, 'PROJECT WORK',
6058229, 'TEST',
NULL, ' '
) AS cause_type,
' ' AS comments, peo3.peo_name AS completed_by,
jt.jt_requestor_email AS contact_email,
jt.jt_requestor_name_first
|| ' '
|| jt.jt_requestor_name_last AS contact_name,
jt.jt_requestor_phone AS contact_phone,
cc.cstctrcd_apcode AS corp_code,
cc.cstctrcd_code AS cost_center,
jt.jt_date_closed AS date_closed,
jt.jt_date_completed AS date_completed,
jt.jt_date_requested AS date_requested,
jt.jt_date_responded AS date_responded,
jt.jt_date_response_ecd AS date_response_ecd,
jt.jt_date_scheduled AS date_scheduled,
DECODE (jt.jt_def_id,
139949, 'WTG VENDOR RESPONSE',
139950, 'WAITING ON PARTS',
139951, 'LABOR AVAILABILITY',
139952, 'DEFERRED- HI PRI WORK',
139953, 'WTG APPROVAL',
139954, 'FUNDING REQUIRED',
139955, 'ACCESS DENIED',
139956, 'WTG MATERIAL',
NULL, ' '
) AS deferral_reason,
jt.jt_description AS description,
jt.jt_date_resched_ecd AS ecd,
fmg.facility_manager AS facility_manager,
fl.floors_text AS FLOOR, gl.genled_desc AS general_ledger,
' ' AS kiosk_date_requested, ' ' AS kiosk_dispatch_confirmed,
' ' AS kiosk_dispatched,
eqp.equip_customer_code AS linked_equipment_alias,
eqp.equip_id AS linked_equipment_id,
eqp.equip_text AS linked_equipment_name,
DECODE (jt_originator_type_id,
1000, 'PROJECT MOVE REQUEST',
138834, 'CUSTOMER INITIATED CORRECTION',
138835, 'CUSTOMER INITIATED REQUEST',
138836, 'CORRECTIVE MAINTENANCE',
138837, 'CONFERENCE ROOM BOOKING',
138838, 'PROJECT INITIATED REQUEST',
138839, 'PLANNED PREVENTIVE MAINTENANCE',
138840, 'SELF INITATED REQUEST',
NULL, ' '
) AS originator_type,
' ' AS payment_terms, priority_text AS priority_code,
swoty.sworktype_text AS problem_type,
prop.property_name_cc AS property,
jt.jt_cost_quote_total AS quote_total,
par.levels_name AS region,
DECODE (jt.jt_repdef_id,
141534, 'ADJUSTED SETTING',
141535, 'TRAINING FOR END',
141536, 'NEW REQUEST',
141537, 'NO REPAIR REQUIR',
141538, 'REPLACED PARTS',
141539, 'REPLACE EQUIPMEN',
1000699, 'NEW REQUEST',
NULL, ' '
) AS repair_definitions,
jt.jt_repairdesc AS repair_description,
jt.jt_requestor AS requestor, ' ' AS requestor_cost_center,
jt.jt_requestor_email AS requestor_email,
jt.jt_requestor_name_first AS requestor_name,
jt.jt_requestor_phone AS requestor_phone,
' ' AS response_time, rm.room_name_cc AS room,
p1.peo_provider_code1 AS service_provider,
p1.peo_address_1 AS service_provider_address,
peocity.city_text service_provider_city,
p1.peo_provider_code1 AS service_provider_code,
peocity.city_country_name AS service_provider_country,
peocur.currency_text AS service_provider_currency,
p1.peo_name AS service_provider_description,
p1.peo_dispatch_method AS serv_prov_dispatc_hmethod,
p1.peo_rate_double AS serv_prov_double_time_rate,
p1.peo_email AS service_provider_email,
p1.peo_emergency_phone AS serv_prov_emergency_phone,
p1.peo_fax AS service_provider_fax_number,
p1.peo_home_phone AS service_provider_home_phone,
p1.peo_rate_hourly AS service_provider_hourly_rate,
p1.peo_title AS service_provider_job_title,
p1.peo_method_id AS service_provider_method,
p1.peo_cell_phone AS service_provider_mobile_phone,
p1.peo_pager AS service_provider_pager,
p1.peo_rate_differential AS service_provider_rates,
p1.peo_rate_differential AS ser_prov_shift_differential,
peocity.city_state_prov_text AS serv_prov_state_province,
DECODE (p1.peo_active,
'Y', 'ACTIVE',
'INACTIVE'
) AS service_provider_status,
p1.peo_url AS serv_prov_web_site_address,
p1.peo_phone AS service_provider_work_phone,
p1.peo_postal_code AS serv_prov_zip_postal_code, ' ' AS shift,
' ' AS skill,
DECODE (jt.jt_bigstatus_id,
138813, 'NEW',
138814, 'PENDING',
138815, 'OPEN',
138816, 'COMPLETED',
138817, 'CLOSED',
138818, 'CANCELLED',
NULL, ' '
) AS status,
lev.levels_name AS subregion, ' ' AS trade,
p1.peo_ls_interface_code1 AS vendor_id,
p1.peo_fax AS vendor_purchasing_fax,
p1.peo_vendor_site_code AS vendor_sitecode,
jt.jt_id AS vendor_ticket, p1.peo_name AS vendor_companyname,
jt.jt_requestor_vip AS vip, wo.wo_id AS work_order_no,
jt.jt_id AS work_request,
jt.jt_class_id AS work_request_class,
woty.worktype_text AS work_type, ' ' AS wr_cost,
jt.jt_description AS wr_description,
' ' AS wr_dispatch_method,
DECODE (jt.jt_bigstatus_id,
138813, 'NEW',
138814, 'PENDING',
138815, 'OPEN',
138816, 'COMPLETED',
138817, 'CLOSED',
138818, 'CANCELLED',
NULL, ' '
) AS wr_status,
ctry.country_name AS country
FROM citi.jobticket jt,
citi.property prop,
citi.bldg bl,
citi.bldg_levels bldglvl,
citi.LEVELS lev,
citi.LEVELS par,
(SELECT crstools.stragg (peo_name) facility_manager,
bldgcon_bldg_id
FROM citi.bldg_contacts, citi.people
WHERE bldgcon_peo_id = peo_id
AND bldgcon_contype_id IN (40181, 10142)
GROUP BY bldgcon_bldg_id) fmg,
citi.floors fl,
citi.room rm,
citi.general_ledger gl,
citi.legal_entity le,
citi.cost_center_codes cc,
citi.equipment eqp,
citi.worktype woty,
citi.subworktype swoty,
citi.work_order wo,
citi.jt_workers jtwo,
citi.priority,
citi.country ctry,
citi.people p1,
citi.people peo3,
citi.people peo1,
citi.city peocity,
citi.currency peocur
WHERE jt.jt_bldg_id = bl.bldg_id
AND bl.bldg_id = bldglvl.bldg_levels_bldg_id
AND bldglvl.bldg_levels_levels_id = lev.levels_id
AND lev.levels_parent = par.levels_id(+)
AND prop.property_id = bl.bldg_property_id
AND bl.bldg_active_ls <> 'N'
AND jt.jt_floors_id = fl.floors_id(+)
AND jt.jt_room_id = rm.room_id(+)
AND jt.jt_bldg_id = fmg.bldgcon_bldg_id(+)
AND jt.jt_genled_id = gl.genled_id(+)
AND gl.genled_lglent_id = le.lglent_id(+)
AND jt.jt_cstctrcd_id = cc.cstctrcd_id(+)
AND jt.jt_equip_id = eqp.equip_id(+)
AND jt.jt_id = jtwo.jtw_jt_id(+)
AND jt.jt_worktype_id = woty.worktype_id(+)
AND jt.jt_sworktype_id = swoty.sworktype_id(+)
AND jt.jt_wo_id = wo.wo_id
AND jt.jt_priority_id = priority_id(+)
--AND jt.jt_date_requested >= ADD_MONTHS (SYSDATE, -12)
AND jt.jt_last_update >= ADD_MONTHS (ld_curr_time, -12)
AND bl.bldg_country_id = ctry.country_id
AND jtwo.jtw_peo_id = p1.peo_id(+)
AND p1.peo_city_id = peocity.city_id(+)
AND jt.jt_completed_by_peo_id = peo3.peo_id(+)
AND p1.peo_rate_currency_id = peocur.currency_id(+)
AND jt.jt_agent_peo_id = peo1.peo_id(+);
BEGIN
execute immediate 'truncate table crstools.drt_bom_work_kiosk';
select sysdate into ld_curr_time from dual;
FOR cur_rec in cur_work_kiosk LOOP
IF MOD(cur_work_kiosk%rowcount,10000 ) = 0 then
COMMIT;
END IF;
INSERT INTO crstools.drt_bom_work_kiosk
( JT_ID
,ACTUAL_HRS_TO_COMPLETE
,ACTUAL_HRS_TO_RESPOND
,AGENT_NAME
,ASAGENT_SOE_ID
,AP_SYSTEM
,ASSIGN_WORK_REQUEST_COMMENT
,BILLABLE
,BUILDING
,BUILDING_ID
,BUILDING_STATUS
,CAUSE_TYPE
,COMMENTS
,COMPLETED_BY
,CONTACT_EMAIL
,CONTACT_NAME
,CONTACT_PHONE
,CORP_CODE
,COST_CENTER
,DATE_CLOSED
,DATE_COMPLETED
,DATE_REQUESTED
,DATE_RESPONDED
,DATE_RESPONSE_ECD
,DATE_SCHEDULED
,DEFERRAL_REASON
,DESCRIPTION
,ECD
,FACILITY_MANAGER
,FLOOR
,GENERAL_LEDGER
,KIOSK_DATE_REQUESTED
,KIOSK_DISPATCH_CONFIRMED
,KIOSK_DISPATCHED
,LINKED_EQUIPMENT_ALIAS
,LINKED_EQUIPMENT_ID
,LINKED_EQUIPMENT_NAME
,ORIGINATOR_TYPE
,PAYMENT_TERMS
,PRIORITY_CODE
,PROBLEM_TYPE
,PROPERTY
,QUOTE_TOTAL
,REGION
,REPAIR_DEFINITIONS
,REPAIR_DESCRIPTION
,REQUESTOR
,REQUESTOR_COST_CENTER
,REQUESTOR_EMAIL
,REQUESTOR_NAME
,REQUESTOR_PHONE
,RESPONSE_TIME
,ROOM
,SERVICE_PROVIDER
,SERVICE_PROVIDER_ADDRESS
,SERVICE_PROVIDER_CITY
,SERVICE_PROVIDER_CODE
,SERVICE_PROVIDER_COUNTRY
,SERVICE_PROVIDER_CURRENCY
,SERVICE_PROVIDER_DESCRIPTION
,SERV_PROV_DISPATC_HMETHOD
,SERV_PROV_DOUBLE_TIME_RATE
,SERVICE_PROVIDER_EMAIL
,SERV_PROV_EMERGENCY_PHONE
,SERVICE_PROVIDER_FAX_NUMBER
,SERVICE_PROVIDER_HOME_PHONE
,SERVICE_PROVIDER_HOURLY_RATE
,SERVICE_PROVIDER_JOB_TITLE
,SERVICE_PROVIDER_METHOD
,SERVICE_PROVIDER_MOBILE_PHONE
,SERVICE_PROVIDER_PAGER
,SERVICE_PROVIDER_RATES
,SER_PROV_SHIFT_DIFFERENTIAL
,SERV_PROV_STATE_PROVINCE
,SERVICE_PROVIDER_STATUS
,SERV_PROV_WEB_SITE_ADDRESS
,SERVICE_PROVIDER_WORK_PHONE
,SERV_PROV_ZIP_POSTAL_CODE
,SHIFT
,SKILL
,STATUS
,SUBREGION
,TRADE
,VENDOR_ID
,VENDOR_PURCHASING_FAX
,VENDOR_SITECODE
,VENDOR_TICKET
,VENDOR_COMPANYNAME
,VIP
,WORK_ORDER_NO
,WORK_REQUEST
,WORK_REQUEST_CLASS
,WORK_TYPE
,WR_COST
,WR_DESCRIPTION
,WR_DISPATCH_METHOD
,WR_STATUS
,COUNTRY
,CREATE_DATE
VALUES
(cur_rec.jt_id
,cur_rec.ACTUAL_HRS_TO_COMPLETE
,cur_rec.ACTUAL_HRS_TO_RESPOND
,cur_rec.AGENT_NAME
,cur_rec.ASAGENT_SOE_ID
,cur_rec.AP_SYSTEM
,cur_rec.ASSIGN_WORK_REQUEST_COMMENT
,cur_rec.BILLABLE
,cur_rec.BUILDING
,cur_rec.BUILDING_ID
,cur_rec.BUILDING_STATUS
,cur_rec.CAUSE_TYPE
,cur_rec.COMMENTS
,cur_rec.COMPLETED_BY
,cur_rec.CONTACT_EMAIL
,cur_rec.CONTACT_NAME
,cur_rec.CONTACT_PHONE
,cur_rec.CORP_CODE
,cur_rec.COST_CENTER
,cur_rec.DATE_CLOSED
,cur_rec.DATE_COMPLETED
,cur_rec.DATE_REQUESTED
,cur_rec.DATE_RESPONDED
,cur_rec.DATE_RESPONSE_ECD
,cur_rec.DATE_SCHEDULED
,cur_rec.DEFERRAL_REASON
,cur_rec.DESCRIPTION
,cur_rec.ECD
,cur_rec.FACILITY_MANAGER
,cur_rec.FLOOR
,cur_rec.GENERAL_LEDGER
,cur_rec.KIOSK_DATE_REQUESTED
,cur_rec.KIOSK_DISPATCH_CONFIRMED
,cur_rec.KIOSK_DISPATCHED
,cur_rec.LINKED_EQUIPMENT_ALIAS
,cur_rec.LINKED_EQUIPMENT_ID
,cur_rec.LINKED_EQUIPMENT_NAME
,cur_rec.ORIGINATOR_TYPE
,cur_rec.PAYMENT_TERMS
,cur_rec.PRIORITY_CODE
,cur_rec.PROBLEM_TYPE
,cur_rec.PROPERTY
,cur_rec.QUOTE_TOTAL
,cur_rec.REGION
,cur_rec.REPAIR_DEFINITIONS
,cur_rec.REPAIR_DESCRIPTION
,cur_rec.REQUESTOR
,cur_rec.REQUESTOR_COST_CENTER
,cur_rec.REQUESTOR_EMAIL
,cur_rec.REQUESTOR_NAME
,cur_rec.REQUESTOR_PHONE
,cur_rec.RESPONSE_TIME
,cur_rec.ROOM
,cur_rec.SERVICE_PROVIDER
,cur_rec.SERVICE_PROVIDER_ADDRESS
,cur_rec.SERVICE_PROVIDER_CITY
,cur_rec.SERVICE_PROVIDER_CODE
,cur_rec.SERVICE_PROVIDER_COUNTRY
,cur_rec.SERVICE_PROVIDER_CURRENCY
,cur_rec.SERVICE_PROVIDER_DESCRIPTION
,cur_rec.SERV_PROV_DISPATC_HMETHOD
,cur_rec.SERV_PROV_DOUBLE_TIME_RATE
,cur_rec.SERVICE_PROVIDER_EMAIL
,cur_rec.SERV_PROV_EMERGENCY_PHONE
,cur_rec.SERVICE_PROVIDER_FAX_NUMBER
,cur_rec.SERVICE_PROVIDER_HOME_PHONE
,cur_rec.SERVICE_PROVIDER_HOURLY_RATE
,cur_rec.SERVICE_PROVIDER_JOB_TITLE
,cur_rec.SERVICE_PROVIDER_METHOD
,cur_rec.SERVICE_PROVIDER_MOBILE_PHONE
,cur_rec.SERVICE_PROVIDER_PAGER
,cur_rec.SERVICE_PROVIDER_RATES
,cur_rec.SER_PROV_SHIFT_DIFFERENTIAL
,cur_rec.SERV_PROV_STATE_PROVINCE
,cur_rec.SERVICE_PROVIDER_STATUS
,cur_rec.SERV_PROV_WEB_SITE_ADDRESS
,cur_rec.SERVICE_PROVIDER_WORK_PHONE
,cur_rec.SERV_PROV_ZIP_POSTAL_CODE
,cur_rec.SHIFT
,cur_rec.SKILL
,cur_rec.STATUS
,cur_rec.SUBREGION
,cur_rec.TRADE
,cur_rec.VENDOR_ID
,cur_rec.VENDOR_PURCHASING_FAX
,cur_rec.VENDOR_SITECODE
,cur_rec.VENDOR_TICKET
,cur_rec.VENDOR_COMPANYNAME
,cur_rec.VIP
,cur_rec.WORK_ORDER_NO
,cur_rec.WORK_REQUEST
,cur_rec.WORK_REQUEST_CLASS
,cur_rec.WORK_TYPE
,cur_rec.WR_COST
,cur_rec.WR_DESCRIPTION
,cur_rec.WR_DISPATCH_METHOD
,cur_rec.WR_STATUS
,cur_rec.COUNTRY
,ld_curr_time
END LOOP;
COMMIT;
exception
when others then
rollback;
dbms_output.put_line('SQLCODE :'||sqlcode ||' Error :'||sqlerrm);
end work_kiosk_full;
Note : total record inserted 849000.
The same code does not work with bulk collect into caluse.
Please help me out why this is happening.
Thanks & regards
shyam~Shyam,
I agree with Billy.
Why are you not using an INSERT..SELECT ?
Also, what are you trying to achieve by
- incremental commits?
- copying data from one table to another (using expensive I/O)?
- using dynamic DML?
Most of these approaches are typically wrong - and not recommended for scalable and performant Oracle applications.I could see you using a CURSOR FOR LOOP if you were changing the data being inserted in such a way that you couldn't encapsulate the changes in a query, but you are doing a straight insert into the table from your Cursor. A much more efficient way would be to use the following modifications I made to your code example:
PROCEDURE WORK_KIOSK_FULL(AN_JOBID IN NUMBER,
AC_SQLCODE OUT VARCHAR2,
AC_SQLERRM OUT VARCHAR2) IS
BEGIN
EXECUTE IMMEDIATE 'truncate table crstools.drt_bom_work_kiosk';
/* Note: The APPEND hint forces a Direct Path INSERT (see Link below code sample) and is combined with the NOLOGGING Hint */
/* To dramtically increase performance. The Direct Path INSERT inserts records above the High-Water Mark on the table. */
INSERT /*+ APPEND NOLOGGING */ INTO CRSTOOLS.DRT_BOM_WORK_KIOSK
(JT_ID
,ACTUAL_HRS_TO_COMPLETE
,ACTUAL_HRS_TO_RESPOND
,AGENT_NAME
,ASAGENT_SOE_ID
,AP_SYSTEM
-- ,ASSIGN_WORK_REQUEST_COMMENT /* I commented out this COLUMN because it doesn't make sense to me to insert */
,BILLABLE /* a couple of space characters into a table. If the intent is to leave the column NULL */
,BUILDING /* don't include it in your INSERT statement and it will be NULL. If there is a valid reason */
,BUILDING_ID /* for inserting the spaces, then remove the "line comments" from the insert and select statments */
,BUILDING_STATUS
,CAUSE_TYPE
-- ,COMMENTS
,COMPLETED_BY
,CONTACT_EMAIL
,CONTACT_NAME
,CONTACT_PHONE
,CORP_CODE
,COST_CENTER
,DATE_CLOSED
,DATE_COMPLETED
,DATE_REQUESTED
,DATE_RESPONDED
,DATE_RESPONSE_ECD
,DATE_SCHEDULED
,DEFERRAL_REASON
,DESCRIPTION
,ECD
,FACILITY_MANAGER
,FLOOR
,GENERAL_LEDGER
-- ,KIOSK_DATE_REQUESTED
-- ,KIOSK_DISPATCH_CONFIRMED
-- ,KIOSK_DISPATCHED
,LINKED_EQUIPMENT_ALIAS
,LINKED_EQUIPMENT_ID
,LINKED_EQUIPMENT_NAME
,ORIGINATOR_TYPE
-- ,PAYMENT_TERMS
,PRIORITY_CODE
,PROBLEM_TYPE
,PROPERTY
,QUOTE_TOTAL
,REGION
,REPAIR_DEFINITIONS
,REPAIR_DESCRIPTION
,REQUESTOR
-- ,REQUESTOR_COST_CENTER
,REQUESTOR_EMAIL
,REQUESTOR_NAME
,REQUESTOR_PHONE
-- ,RESPONSE_TIME
,ROOM
,SERVICE_PROVIDER
,SERVICE_PROVIDER_ADDRESS
,SERVICE_PROVIDER_CITY
,SERVICE_PROVIDER_CODE
,SERVICE_PROVIDER_COUNTRY
,SERVICE_PROVIDER_CURRENCY
,SERVICE_PROVIDER_DESCRIPTION
,SERV_PROV_DISPATC_HMETHOD
,SERV_PROV_DOUBLE_TIME_RATE
,SERVICE_PROVIDER_EMAIL
,SERV_PROV_EMERGENCY_PHONE
,SERVICE_PROVIDER_FAX_NUMBER
,SERVICE_PROVIDER_HOME_PHONE
,SERVICE_PROVIDER_HOURLY_RATE
,SERVICE_PROVIDER_JOB_TITLE
,SERVICE_PROVIDER_METHOD
,SERVICE_PROVIDER_MOBILE_PHONE
,SERVICE_PROVIDER_PAGER
,SERVICE_PROVIDER_RATES
,SER_PROV_SHIFT_DIFFERENTIAL
,SERV_PROV_STATE_PROVINCE
,SERVICE_PROVIDER_STATUS
,SERV_PROV_WEB_SITE_ADDRESS
,SERVICE_PROVIDER_WORK_PHONE
,SERV_PROV_ZIP_POSTAL_CODE
-- ,SHIFT
-- ,SKILL
,STATUS
,SUBREGION
-- ,TRADE
,VENDOR_ID
,VENDOR_PURCHASING_FAX
,VENDOR_SITECODE
,VENDOR_TICKET
,VENDOR_COMPANYNAME
,VIP
,WORK_ORDER_NO
,WORK_REQUEST
,WORK_REQUEST_CLASS
,WORK_TYPE
-- ,WR_COST
,WR_DESCRIPTION
-- ,WR_DISPATCH_METHOD
,WR_STATUS
,COUNTRY
,CREATE_DATE
VALUES
(SELECT DISTINCT
JT.JT_ID AS JT_ID
,NVL((ROUND((JT_DATE_COMPLETED - JT_DATE_REQUESTED) * 24,2)),0) AS ACTUAL_HRS_TO_COMPLETE
,NVL((ROUND((JT_DATE_RESPONDED - JT_DATE_REQUESTED) * 24,2)),0) AS ACTUAL_HRS_TO_RESPOND
,PEO1.PEO_NAME AS AGENT_NAME
,PEO1.PEO_USER_NAME AS ASAGENT_SOE_ID
,LE.LGLENT_DESC AS AP_SYSTEM
-- ,' ' AS ASSIGN_WORK_REQUEST_COMMENT
,DECODE(JT.JT_BILL_ID,138802,'CLIENT BILLABLE'
,138803,'CONTRACTED'
,138804,'INTERNAL BILLABLE',NULL,' ') AS BILLABLE
,BL.BLDG_NAME_CC AS BUILDING
,BL.BLDG_ID_LS AS BUILDING_ID
,DECODE(BL.BLDG_ACTIVE_CC, 'Y', 'ACTIVE', 'INACTIVE') AS BUILDING_STATUS
,DECODE(JT.JT_WRK_CAUSE_ID,141521,'STANDARD WEAR AND TEAR'
,141522,'NEGLIGENCE'
,141523,'ACCIDENTAL'
,141524,'MECHANICAL MALFUNCTION'
,141525,'OVERSIGHT'
,141526,'VANDAL'
,141527,'STANDARD'
,141528,'PROJECT WORK'
,6058229,'TEST',NULL,' ') AS CAUSE_TYPE
-- ,' ' AS COMMENTS
,PEO3.PEO_NAME AS COMPLETED_BY
,JT.JT_REQUESTOR_EMAIL AS CONTACT_EMAIL
,JT.JT_REQUESTOR_NAME_FIRST || ' ' ||JT.JT_REQUESTOR_NAME_LAST AS CONTACT_NAME
,JT.JT_REQUESTOR_PHONE AS CONTACT_PHONE
,CC.CSTCTRCD_APCODE AS CORP_CODE
,CC.CSTCTRCD_CODE AS COST_CENTER
,JT.JT_DATE_CLOSED AS DATE_CLOSED
,JT.JT_DATE_COMPLETED AS DATE_COMPLETED
,JT.JT_DATE_REQUESTED AS DATE_REQUESTED
,JT.JT_DATE_RESPONDED AS DATE_RESPONDED
,JT.JT_DATE_RESPONSE_ECD AS DATE_RESPONSE_ECD
,JT.JT_DATE_SCHEDULED AS DATE_SCHEDULED
,DECODE(JT.JT_DEF_ID,139949,'WTG VENDOR RESPONSE'
,139950,'WAITING ON PARTS'
,139951,'LABOR AVAILABILITY'
,139952,'DEFERRED- HI PRI WORK'
,139953,'WTG APPROVAL'
,139954,'FUNDING REQUIRED'
,139955,'ACCESS DENIED'
,139956,'WTG MATERIAL',NULL,' ') AS DEFERRAL_REASON
,JT.JT_DESCRIPTION AS DESCRIPTION
,JT.JT_DATE_RESCHED_ECD AS ECD
,FMG.FACILITY_MANAGER AS FACILITY_MANAGER
,FL.FLOORS_TEXT AS FLOOR
,GL.GENLED_DESC AS GENERAL_LEDGER
-- ,' ' AS KIOSK_DATE_REQUESTED
-- ,' ' AS KIOSK_DISPATCH_CONFIRMED
-- ,' ' AS KIOSK_DISPATCHED
,EQP.EQUIP_CUSTOMER_CODE AS LINKED_EQUIPMENT_ALIAS
,EQP.EQUIP_ID AS LINKED_EQUIPMENT_ID
,EQP.EQUIP_TEXT AS LINKED_EQUIPMENT_NAME
,DECODE(JT_ORIGINATOR_TYPE_ID,1000,'PROJECT MOVE REQUEST'
,138834,'CUSTOMER INITIATED CORRECTION'
,138835,'CUSTOMER INITIATED REQUEST'
,138836,'CORRECTIVE MAINTENANCE'
,138837,'CONFERENCE ROOM BOOKING'
,138838,'PROJECT INITIATED REQUEST'
,138839,'PLANNED PREVENTIVE MAINTENANCE'
,138840,'SELF INITATED REQUEST',NULL,' ') AS ORIGINATOR_TYPE
-- ,' ' AS PAYMENT_TERMS
,PRIORITY_TEXT AS PRIORITY_CODE
,SWOTY.SWORKTYPE_TEXT AS PROBLEM_TYPE
,PROP.PROPERTY_NAME_CC AS PROPERTY
,JT.JT_COST_QUOTE_TOTAL AS QUOTE_TOTAL
,PAR.LEVELS_NAME AS REGION
,DECODE(JT.JT_REPDEF_ID,141534,'ADJUSTED SETTING'
,141535,'TRAINING FOR END'
,141536,'NEW REQUEST'
,141537,'NO REPAIR REQUIR'
,141538,'REPLACED PARTS'
,141539,'REPLACE EQUIPMEN'
,1000699,'NEW REQUEST',NULL,' ') AS REPAIR_DEFINITIONS
,JT.JT_REPAIRDESC AS REPAIR_DESCRIPTION
,JT.JT_REQUESTOR AS REQUESTOR
-- ,' ' AS REQUESTOR_COST_CENTER
,JT.JT_REQUESTOR_EMAIL AS REQUESTOR_EMAIL
,JT.JT_REQUESTOR_NAME_FIRST AS REQUESTOR_NAME
,JT.JT_REQUESTOR_PHONE AS REQUESTOR_PHONE
-- ,' ' AS RESPONSE_TIME
,RM.ROOM_NAME_CC AS ROOM
,P1.PEO_PROVIDER_CODE1 AS SERVICE_PROVIDER
,P1.PEO_ADDRESS_1 AS SERVICE_PROVIDER_ADDRESS
,PEOCITY.CITY_TEXT SERVICE_PROVIDER_CITY
,P1.PEO_PROVIDER_CODE1 AS SERVICE_PROVIDER_CODE
,PEOCITY.CITY_COUNTRY_NAME AS SERVICE_PROVIDER_COUNTRY
,PEOCUR.CURRENCY_TEXT AS SERVICE_PROVIDER_CURRENCY
,P1.PEO_NAME AS SERVICE_PROVIDER_DESCRIPTION
,P1.PEO_DISPATCH_METHOD AS SERV_PROV_DISPATC_HMETHOD
,P1.PEO_RATE_DOUBLE AS SERV_PROV_DOUBLE_TIME_RATE
,P1.PEO_EMAIL AS SERVICE_PROVIDER_EMAIL
,P1.PEO_EMERGENCY_PHONE AS SERV_PROV_EMERGENCY_PHONE
,P1.PEO_FAX AS SERVICE_PROVIDER_FAX_NUMBER
,P1.PEO_HOME_PHONE AS SERVICE_PROVIDER_HOME_PHONE
,P1.PEO_RATE_HOURLY AS SERVICE_PROVIDER_HOURLY_RATE
,P1.PEO_TITLE AS SERVICE_PROVIDER_JOB_TITLE
,P1.PEO_METHOD_ID AS SERVICE_PROVIDER_METHOD
,P1.PEO_CELL_PHONE AS SERVICE_PROVIDER_MOBILE_PHONE
,P1.PEO_PAGER AS SERVICE_PROVIDER_PAGER
,P1.PEO_RATE_DIFFERENTIAL AS SERVICE_PROVIDER_RATES
,P1.PEO_RATE_DIFFERENTIAL AS SER_PROV_SHIFT_DIFFERENTIAL
,PEOCITY.CITY_STATE_PROV_TEXT AS SERV_PROV_STATE_PROVINCE
,DECODE(P1.PEO_ACTIVE, 'Y', 'ACTIVE', 'INACTIVE') AS SERVICE_PROVIDER_STATUS
,P1.PEO_URL AS SERV_PROV_WEB_SITE_ADDRESS
,P1.PEO_PHONE AS SERVICE_PROVIDER_WORK_PHONE
,P1.PEO_POSTAL_CODE AS SERV_PROV_ZIP_POSTAL_CODE
-- ,' ' AS SHIFT
-- ,' ' AS SKILL
,DECODE(JT.JT_BIGSTATUS_ID,138813,'NEW'
,138814,'PENDING'
,138815,'OPEN'
,138816,'COMPLETED'
,138817,'CLOSED'
,138818,'CANCELLED',NULL,' ') AS STATUS
,LEV.LEVELS_NAME AS SUBREGION
-- ,' ' AS TRADE
,P1.PEO_LS_INTERFACE_CODE1 AS VENDOR_ID
,P1.PEO_FAX AS VENDOR_PURCHASING_FAX
,P1.PEO_VENDOR_SITE_CODE AS VENDOR_SITECODE
,JT.JT_ID AS VENDOR_TICKET
,P1.PEO_NAME AS VENDOR_COMPANYNAME
,JT.JT_REQUESTOR_VIP AS VIP
,WO.WO_ID AS WORK_ORDER_NO
,JT.JT_ID AS WORK_REQUEST
,JT.JT_CLASS_ID AS WORK_REQUEST_CLASS
,WOTY.WORKTYPE_TEXT AS WORK_TYPE
-- ,' ' AS WR_COST
,JT.JT_DESCRIPTION AS WR_DESCRIPTION
-- ,' ' AS WR_DISPATCH_METHOD
,DECODE(JT.JT_BIGSTATUS_ID,138813,'NEW'
,138814,'PENDING'
,138815,'OPEN'
,138816,'COMPLETED'
,138817,'CLOSED'
,138818,'CANCELLED',NULL,' ') AS WR_STATUS
,CTRY.COUNTRY_NAME AS COUNTRY
,SYSDATE --LD_CURR_TIME
FROM CITI.JOBTICKET JT,
CITI.PROPERTY PROP,
CITI.BLDG BL,
CITI.BLDG_LEVELS BLDGLVL,
CITI.LEVELS LEV,
CITI.LEVELS PAR,
(SELECT CRSTOOLS.STRAGG(PEO_NAME) FACILITY_MANAGER,
BLDGCON_BLDG_ID
FROM CITI.BLDG_CONTACTS, CITI.PEOPLE
WHERE BLDGCON_PEO_ID = PEO_ID
AND BLDGCON_CONTYPE_ID IN (40181, 10142)
GROUP BY BLDGCON_BLDG_ID) FMG,
CITI.FLOORS FL,
CITI.ROOM RM,
CITI.GENERAL_LEDGER GL,
CITI.LEGAL_ENTITY LE,
CITI.COST_CENTER_CODES CC,
CITI.EQUIPMENT EQP,
CITI.WORKTYPE WOTY,
CITI.SUBWORKTYPE SWOTY,
CITI.WORK_ORDER WO,
CITI.JT_WORKERS JTWO,
CITI.PRIORITY,
CITI.COUNTRY CTRY,
CITI.PEOPLE P1,
CITI.PEOPLE PEO3,
CITI.PEOPLE PEO1,
CITI.CITY PEOCITY,
CITI.CURRENCY PEOCUR
WHERE JT.JT_BLDG_ID = BL.BLDG_ID
AND BL.BLDG_ID = BLDGLVL.BLDG_LEVELS_BLDG_ID
AND BLDGLVL.BLDG_LEVELS_LEVELS_ID = LEV.LEVELS_ID
AND LEV.LEVELS_PARENT = PAR.LEVELS_ID(+)
AND PROP.PROPERTY_ID = BL.BLDG_PROPERTY_ID
AND BL.BLDG_ACTIVE_LS = 'N'
AND JT.JT_FLOORS_ID = FL.FLOORS_ID(+)
AND JT.JT_ROOM_ID = RM.ROOM_ID(+)
AND JT.JT_BLDG_ID = FMG.BLDGCON_BLDG_ID(+)
AND JT.JT_GENLED_ID = GL.GENLED_ID(+)
AND GL.GENLED_LGLENT_ID = LE.LGLENT_ID(+)
AND JT.JT_CSTCTRCD_ID = CC.CSTCTRCD_ID(+)
AND JT.JT_EQUIP_ID = EQP.EQUIP_ID(+)
AND JT.JT_ID = JTWO.JTW_JT_ID(+)
AND JT.JT_WORKTYPE_ID = WOTY.WORKTYPE_ID(+)
AND JT.JT_SWORKTYPE_ID = SWOTY.SWORKTYPE_ID(+)
AND JT.JT_WO_ID = WO.WO_ID
AND JT.JT_PRIORITY_ID = PRIORITY_ID(+)
--AND jt.jt_date_requested >= ADD_MONTHS (SYSDATE, -12)
AND JT.JT_LAST_UPDATE >= ADD_MONTHS(LD_CURR_TIME, -12)
AND BL.BLDG_COUNTRY_ID = CTRY.COUNTRY_ID
AND JTWO.JTW_PEO_ID = P1.PEO_ID(+)
AND P1.PEO_CITY_ID = PEOCITY.CITY_ID(+)
AND JT.JT_COMPLETED_BY_PEO_ID = PEO3.PEO_ID(+)
AND P1.PEO_RATE_CURRENCY_ID = PEOCUR.CURRENCY_ID(+)
AND JT.JT_AGENT_PEO_ID = PEO1.PEO_ID(+)
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
DBMS_OUTPUT.PUT_LINE('SQLCODE :' || SQLCODE || ' Error :' || SQLERRM);
END WORK_KIOSK_FULL;Here's the link for infor on the [Oracle Direct-Path INSERT |http://download.oracle.com/docs/cd/B10501_01/server.920/a96524/c21dlins.htm#10778].
Also, if you are truly intent on using a CURSOR FOR LOOP with the BULK COLLECT, I suggest you read Steven Feuerstein's article [PL/SQL Practices: On BULK COLLECT |http://www.oracle.com/technology/oramag/oracle/08-mar/o28plsql.html].
Hope this helps.
Craig...
If my response or the response of another was helpful, please mark it accordingly -
Hello all,
i'm getting error when i try to write sub query in having clause. check out my query
select ROUND( Count( distinct Sales2011_DIVDPTA.DIVDPTA_Item_Dept ),0) AS "F1" , ROUND( Count( Sales2011.Sales2011_DG1.Item_Season ),0) AS "F2"
from Sales2011.Sales2011_JT
INNER JOIN Sales2011.Sales2011_DG1 On Sales2011.Sales2011_DG1.DG1_ID =Sales2011.Sales2011_JT.DG1_ID
LEFT JOIN Sales2011.Sales2011_DIVDPTA On nvl(Sales2011.Sales2011_DIVDPTA.DIVDPTA_ITEM_DIVISION,' ')=nvl(Sales2011.Sales2011_DG1.Item_Division,' ')
AND nvl(Sales2011.Sales2011_DIVDPTA.DIVDPTA_ITEM_DEPT,' ')=nvl(Sales2011.Sales2011_DG1.Item_Dept,' ')
having ( ROUND( Count( Sales2011.Sales2011_DG1.Item_Season ),0) in ( 0)
But it is not executed if I use the sub query in having clause
select ROUND( Count( distinct Sales2011_DIVDPTA.DIVDPTA_Item_Dept ),0) AS "F1" , ROUND( Count( Sales2011.Sales2011_DG1.Item_Season ),0) AS "F2"
from Sales2011.Sales2011_JT
INNER JOIN Sales2011.Sales2011_DG1 On Sales2011.Sales2011_DG1.DG1_ID =Sales2011.Sales2011_JT.DG1_ID
LEFT JOIN Sales2011.Sales2011_DIVDPTA On nvl(Sales2011.Sales2011_DIVDPTA.DIVDPTA_ITEM_DIVISION,' ')=nvl(Sales2011.Sales2011_DG1.Item_Division,' ')
AND nvl(Sales2011.Sales2011_DIVDPTA.DIVDPTA_ITEM_DEPT,' ')=nvl(Sales2011.Sales2011_DG1.Item_Dept,' ')
having ( ROUND( Count( Sales2011.Sales2011_DG1.Item_Season ),0)
in ( select ROUND( Count(
Sales2011.Sales2011_DG1.Item_Season ),0) from Sales2011.Sales2011_DG1 )
Error at Command Line:1 Column:0
Error report:
SQL Error: ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
*Cause:
*Action:any help ???Sorry unintentionally i have posted my question here.
will you please elaborate this? Becoz i'm not using group by clause in both query. First query run successfully but as i put sub query in having clause it raised an error. will you tell where i'm committing mistake?
Aggregates in the HAVING clause do not need to appear in the SELECT list. If the HAVING clause contains a subquery, the subquery can refer to the outer query block if and only if it refers to a grouping column.Edited by: Oracle Studnet on Aug 14, 2011 11:28 PM -
Hi all,
In the middle of the last week for my final year project and having to convert to an Oracle database due to compatibility problems with university Tomcat Server and MS Access. I'm having trouble connecting to the Oracle database and would appreciate some help please.
Running on Windows 98 in the lab here, and the Oracle 9i, release 9.2.0.2.0, J2SDK1.4.0, Classes12.zip installed OK.
Code for connection looks like this inside the constructor of my class:
Class.forName("oracle.jdbc.driver.OracleDriver");
cardSaleConnexion = DriverManager.getConnection("jdbc:oracle:[email protected]:1521:sid","user_name","pwdt");
System.out.println("Connection Successful ");
And I'm getting the following error when calling the constructor in a driver program:
java.sql.SQLException: Invalid Oracle URL specified
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:188)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at CardSale.<init>(CardSale.java:30)
at Driver.main(Driver.java:11)
Exception in thread "main"
Please reply on a very urgent basis.
Kind regards,
PeterTry ojdbc14.jar as the JDBC driver instead of classes12.zip.
Refer:
http://otn.oracle.com/software/tech/java/sqlj_jdbc/htdocs/jdbc9201.html
http://docs.sun.com/source/817-5603-10/index.html
Database Driver
This section describes the known database driver issues and associated solutions.
ID Summary
4700531 On Solaris, an ORACLE JDBC driver error occurs.
This new Java Database Connectivity (JDBC) driver is for Oracle (R) working with JDK1.4. The problem is caused by a combination of the Oracle 9.1 database and ojdbc14.jar. Applying the patch will fix the problem on Solaris 32-bit machine, running an Oracle 9.0.1.3 database.
Solution
Obtain and apply the patch to your server from the Oracle Web site for Bug 2199718. Perform the following steps:
1.��Go to the Oracle web site.
2.��Click the 'patches' button.
3.��Type 2199718 in the patch number field.
4.��Click the 32-bit Solaris OS patch.Go to Metalink.oracle.com.
5.��Click patches.
6.��Under patch number, enter 2199718.
7.��Click the 32 bit Solaris OS patch.
4707531 On Solaris, accessing an Oracle 9.1 database with an Oracle 9.2 Client may cause data corruption.
If you use an Oracle (R) 9.2 client to access an Oracle 9.1 database, data corruption might occur when a number column follows a timestamp column.
The problem might be caused by using the ojdbc14.jar file with an Oracle 9.1 database. Applying the patch might assist in addressing the situation on Solaris 32-bit machines, running an Oracle 9.1 database. This JDBC driver is for Oracle working with JDK1.4.
Solution
Obtain the patch that Oracle might make available from the Oracle web site for Bug 2199718 and apply it to your server.
Regards,
Pankaj D. -
Since the move to Windows 7 we have started getting this error above when people login at random times and on random machines, at first we thought it was only a select few users, but now it seems to have occurred to about 20 different Staff members working
at the school. Also of those 20 odd users it has happened to them on a few occasions.
What we know
We know this problem is only occurring to staff with Roaming Profiles, it seems like somehow the profile is not Synchronizing with the Servers File Share that houses the profiles, which causes the NTUSER.DAT file to become corrupt and go from being around
2 – 3 MBs to 256KB (In all cases where a user has had this issue there NTUSER.DAT file has been 256KB)
Current Resolution to the problem
When a staff member contact us with this problem, we fortunately have Previous Versions working on the profiles folder on the server, so we are able to restore their NTUSER.DAT file from 1 to 2 days before it became corrupt, which then seems to allow them
to log on fine
What we have tried so far & suggested so far
After some research on Google, we found the following thread on EduGeek
http://www.edugeek.net/forums/windows-7/78733-windows-7-user-profile-failed-error-again.html#post700415
Which suggested that the problem may lay within registry, so we implemented the Script that was posted on the website, however this has not seemed to make any difference
In the early stages when only 5 – 10 staff seemed to be having the problem, we believed the issue could be with just certain AD accounts. It had not seemed to happen to any recently created AD accounts so we thought it could be a corrupt attribute on
the user so we delete one of the staff AD accounts that had the problem and creating a brand new one, however within about 2 – 3 weeks that staff member had the issue occur again
Leading on from point two, we also thought the problem could be with people using multiple computers, logging on in 2 places and not logging off properly, but unfortunately the staff member referred to in point 2 only uses the one computer in reception.
Another potential cause that we figured might be the route of the problem, was it could be specific computers that are not communicating properly with the server, which could be causing this problem to occur, but we have no real way of testing this,
as the staff generally log onto 3 – 4 different computers throughout the day and in different location
We log a call with EE and they just pointed us to various websites that we had already checked and wasn’t much help.
In Summary
This error has now occurred with about 20 members of staff, we currently only use Windows 7 at our Senior School & Moving to Windows 7 at our Prep School in the Summer
holidays, we would like to find out the route of this problem ideally before then, as we could potentially be doubling the amount of staff with the problem after the move. Has anyone else seen this problem or have a brain wave on how to solve it?
Regards
AndyHi Dudleya,
First of all ,I would suggest to check the permissions of the NTUSER.DAT registry hive .Here is a link for reference :
The Group Policy Client service failed the logon. Access is denied(Juke Chou`s answer)
https://social.technet.microsoft.com/Forums/windows/en-US/8c0054a3-35be-4fc4-839c-e2176613eb23/the-group-policy-client-service-failed-the-logon-access-is-denied?forum=w7itpronetworking
Please refer to this link and add the registry keys to have a check .Please backup the registry keys before you made modifications to them.
The Group Policy Client Service Failed The Logon In Windows 8(It should also work on windows 7 )
http://www.thewindowsclub.com/fix-group-policy-client-service-failed-logon-windows-8
If the issue persists ,we can refer to this link to troubleshoot this issue .
Troubleshoot User Profiles with Events(It should also be applied to windows 7 )
https://technet.microsoft.com/en-us/library/jj649075.aspx
NOTE: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites.
Best regards
Maybe you are looking for
-
Error in SAP installation ECC 6.0 "HKEY_LOCAL_MACHINE does not exist"
Here is log can any body suggest INFO 2009-02-21 10:17:02 Connection request to guiengine backend by host 192.168.16.249 . INFO 2009-02-21 10:17:07 Copied file 'C:/Program Files/sapinst_instdir/ERP/SYSTEM/ORA/CENTRAL/AS/inifile.xml' to 'C:/Program F
-
I have wanted to install the Italian version of Photoshop Album Starter edition 3.2 on a pc that already had the English version installed. Now the programme doesn't work any longer and in spite of my repairing the installation, when I launch it I ge
-
Am I correct in understanding that the LoginModule supplies a login page already provided by Oracle? If one wants their login page to have a preferred look, you have to provide your own jspx page but then you will not be able to use the Oracle suppli
-
We are migrating from Exchange 2010 to Exchange 2013. We have installed the Exchange 2013 but it only has a couple of mailboxes on this server, all the mailboxes are still on the Exchange 2010 server. I have run a Windows Backup of the Exchange 2013
-
Query Builder - Data types & functions
Hi, I have a couple of questions relating to the Query Builder a) Why can I not select columns of datatype FLOAT? Are there any others? b) Is it possible to add functions to the list of functions in Query Builder. I am trying to read thru the User Gu