SQL wiithout entities???
Hi,
I'm curious how people are doing SQL statements that return data from from several tables. Are the relationships (parent/child) set up in the entities and all the data gets return? For example we have apps where users can query data by entering there query data in a form. An sql statement is built from the data entered and the results returned to them. If the query performed is large isn't this an issue?
I was looking at an example from hibernate:
Iterator results = em.createQuery(
"select cat.color, min(cat.birthdate), count(cat) from Cat cat " +
"group by cat.color")
.getResultList()
.iterator();
while ( results.hasNext() ) {
Object[] row = results.next();
Color type = (Color) row[0];
Date oldest = (Date) row[1];
Integer count = (Integer) row[2];
This actually didn't work. It's like row is meant to be field?
I've also seen examples where people create a dummy entity and pass that into the SQL statement. however that also didn't work.
Which is the best way?
thanks
David
Hi Tom,
The reason for different behaviour in Try Catch block is as mentioned below from -
http://msdn.microsoft.com/en-us/library/ms175976.aspx
The following types of errors are not handled by a CATCH block when they occur at the same level of execution as the TRY…CATCH construct:
Errors that occur during statement-level recompilation, such as object name resolution errors that occur after compilation because of deferred name resolution.
The following example shows how an object name resolution error generated by a
SELECT statement is not caught by the
TRY…CATCH construct, but is caught by the CATCH block when the same
SELECT statement is executed inside a stored procedure.
USE AdventureWorks2012;
GO
BEGIN TRY
-- Table does not exist; object name resolution
-- error not caught.
SELECT * FROM NonexistentTable;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH
The error is not caught and control passes out of the TRY…CATCH construct to the next higher level.
Running the SELECT statement inside a stored procedure will cause the error to occur at a level lower than the
TRY block. The error will be handled by the
TRY…CATCH construct.
-- Verify that the stored procedure does not exist.
IF OBJECT_ID ( N'usp_ExampleProc', N'P' ) IS NOT NULL
DROP PROCEDURE usp_ExampleProc;
GO
-- Create a stored procedure that will cause an
-- object resolution error.
CREATE PROCEDURE usp_ExampleProc
AS
SELECT * FROM NonexistentTable;
GO
BEGIN TRY
EXECUTE usp_ExampleProc;
END TRY
BEGIN CATCH
SELECT
ERROR_NUMBER() AS ErrorNumber
,ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
For other details on SQL Server Object dependencies -
http://sathyadb.blogspot.in/2012/08/sql-server-object-dependencies.html
sathya --------- Please Mark as answered if my post solved your problem and Vote as helpful if my post was useful.
Similar Messages
-
SRKIM: R12: Payables Accounting Data 를 R12 로 upgrade 할때 사용 되는 Scripts
PURPOSE
R11i 의 Payables Accounting 정보를 R12 로 upgrade 시 사용되는 scripts 에 대해 알아보도록 한다.
EXPLANATION
R12 의 AP Accounting 정보를 담는 new tables 은 아래와 같다.
New Tables:
XLA_EVENTS
XLA_AE_HEADERS
XLA_AE_LINES
XLA_TRANSACTION_ENTITIES_UPG
XLA_DISTRIBUTION_LINKS
R12 에서 더 이상 사용하지 않는 tables 목록은 아래와 같다.
Obsolete tables:
AP_ACCOUNTING_EVENTS_ALL
AP_AE_HEADERS_ALL
AP_AE_LINES_ALL
Upgarde Scripts
1) apxlaupg.sql - Transaction entities, events, headers 와 lines 정보를 XLA tables 로 upgrade 하는 script 이다.
a ) XLA_TRANSACTION_ENTITIES_UPG 로 다음 정보를 insert 한다.
ENTITY_CODE = 'AP_INVOICES' OR 'AP_PAYMENTS'
- For AP_INVOICES , data from AP_INVOICES_ALL is used if distributions with accounting_event_id exists
- For AP_PAYMENTS, data from AP_CHECKS_ALL is used
b) XLA EVENTS 에 insert 한다.
b.1: Invoice Related Events:
Invoice 관련 events 는 AP_ACCOUNTING_EVENTS_ALL 와 AP_INVOICES_ALL 를 참조 하여 만들어 진다.
XLA_EVENTS.ENTITY_CODE = 'AP_INVOICES'
XLA_EVENTS.EVENT_TYPE_CODE 은 AP_ACCOUNTING_EVENTS_ALL.event_type_code 에서 참조 하여 만들어 진다.
INVOICE event 는 다음 중 하나로 생성된다:
INVOICE VALIDATED,
CREDIT MEMO VALIDATED,
DEBIT MEMO VALIDATED ,
PREPAYMENT VALIDATED
INVOICE ADJUSTMENT event 는 다음 중 하나로 생성된다:
INVOICE ADJUSTED,
CREDIT MEMO ADJUSTED,
DEBIT MEMO ADJUSTED,
PREPAYMENT ADJUSTED
INVOICE CANCELLATION event 는 다음 중 하나로 생성된다:
INVOICE CANCELLED,
CREDIT MEMO CANCELLED,
DEBIT MEMO CANCELLED,
PREPAYMENT CANCELLED
PREPAYMENT APPLICATION -> PREPAYMENT APPLIED
PREPAYMENT UNAPPLICATION -> PREPAYMENT UNAPPLIED
b.2 :Payment Related Events:
Payment related events 는 AP_ACCOUNTING_EVENTS_ALL 와 AP_CHECKS_ALL XLA_EVENTS.ENTITY_CODE = 'AP_PAYMENTS' 를 베이스로 만들어 진다.
XLA_EVENTS.EVENT_TYPE_CODE 는 AP_ACCOUNTING_EVENTS_ALL.event_type_code 를 근거로 아래와 같이 생성된다.
PAYMENT -> PAYMENT RECORDED or REFUND_RECORDED
PAYMENT ADJUSTMENT -> MANUAL PAYMENT ADJUSTED
PAYMENT CANCELLATION -> PAYMENT CANCELLED or REFUND CANCELLED
PAYMENT CLEARING -> PAYMENT CLEARED
PAYMENT UNCLEARING -> PAYMENT UNCLEARED
PAYMENT MATURITY -> PAYMENT MATURED
b.3 : XLA_EVENTS.EVENT_STATUS_CODE 는 varchar2(1) column 이고
Value 는 AP_ACCOUNTING_EVENTS_ALL.event_status_code 의 값을 참조 하여 만들어 진다.
CREATED -> N
INCOMPLETE -> I
Any other value -> P
b.4 : XLA_EVENTS.PROCESS_STATUS_CODE 는 varchar2(1) column 이고 Value 는 AP_ACCOUNTING_EVENTS_ALL.event_status_code 의 값을 참조 하여 만들어진다.
ACCOUNTED -> P
ACCOUNTED WITH ERROR -> E
Any other value -> U
c) Insert into XLA_AE_HEADERS -> Using rows in AP_AE_HEADERS_ALL
d) Insert into XLA_AE_LINES -> Using rows in AP_AE_LINES_ALL
d.1 : XLA_AE_LINES.ACCOUNTING_CLASS_CODE 는 AP_AE_LINES_ALL.AE_LINE_TYPE_CODE 값을 참조 하여 만들어진다.
AP ACCRUAL -> ACCRUAL
CHARGE -> ITEM EXPENSE
PREPAY -> PREPAID_EXPENSE
RECOVERABLE TAX -> RTAX
NONRECOVERABLE TAX -> NRTAX
AV -> AMT_VARIANCE
ERV -> EXCHANGE_RATE_VARIANCE CASH CLEARING -> CASH_CLEARING
FUTURE PAYMENT -> FUTURE_DATED_PMT
WRITEOFF -> WRITE_OFF
BANK CHARGE -> BANK_CHG
BANK ERROR -> BANK_ERROR
Any other value -> AE_Line_Type_Code
d.2: XLA_AE_LINES.BUSINESS_CLASS_CODE 는 AP_AE_LINES_ALL.AE_LINE_TYPE_CODE 의 값을 참조 하여 만들어 진다.
PREPAY -> AP_PREPAY
LIABILITY -> AP_LIAB
CASH CLEARING -> AP_CASH_CLEARING
FUTURE PAYMENT -> AP_FUTURE_DTD_PMT
Any other value -> NULL
e) Insert into AP_PAYMENT_HISTORY_ALL
TRANSACTION_TYPE 은 AP_ACCOUNTING_EVENTS_ALL.event_type_code 의 값을 참조 하여 만들어진다.
PAYMENT CANCELLATION -> PAYMENT CANCELLED
PAYMENT ADJUSTMENT -> MANUAL PAYMENT ADJUSTED
Any other value -> PAYMENT CREATED
2) apaphuhf.sql
해당 script 은 all Payment History rows 의 historical_flag 를 update 한다.
3) apaxevnt.sql
AX_EVENTS 에 해당 하는 rows 가 있거나 ‘11.5 Upgrade’ 란 description 으로 생성된 record 가 AE HEADER record 에 있으면 AP_ACCOUNTING_EVENTS_ALL의 AX_ACCOUNTED_FLAG을 UPDATE 한다.
4) apgpsupd.sql
application_id = 200 (Payables) and migration_status_code equals ‘P’ 를 가진 gl_period_statuses 의 migration_status_code 를 ‘U’ UPDATE 하는 XLA package (xlaugupg.pkb) 를 호출 한다.
5) apidstln.sql
Invoice distribution links, prepay header, prepay app distributions 와 prepay distribution links 를 UPGRADE 한다.
a) Insert into XLA_DISTRIBUTION_LINKS using AP_INVOICES_ALL, AP_ACCOUNTING_EVENTS_ALL, XLA_AE_HEADERS, XLA_AE_LINES and AP_INVOICE_DISTRIUTIONS_ALL
b) Insert into AP_PREPAY_HISTORY_ALL using AP_INVOICES_ALL, AP_INVOICE_LINES_ALL and AP_INVOICE_DISTRIBUTIONS_ALL
c) Insert into AP_PREPAY_APP_DISTS using AP_INVOICES_ALL, AP_INVOICE_DISTRIBUTIONS_ALL, AP_ACCOUNTING_EVENTS_ALL, AP_PREPAY_HISTORY_ALL, XLA_AE_HEADERS and XLA_AE_LINES
d) Insert into XLA_DISTRIBUTION_LINKS for the prepay distributions.
6) appdstln.sql
Payment distributions 와 payment distribution links 를 UPGRADE 한다.
Insert into AP_PAYMENT_HIST_DISTS and XLA_DISTRIBUTION_LINKS for the payment history distributions
7) apsobtrb.sql
Trial balance upgrade -> Inserts data into AP_TB_BALANCES_TMP which is then used to create initial balances.
8) apintbal.sql
Trial balance upgrade-> Creates initial balances for trial balance
9)apxlainv.sql
Creates Invoice distribution links post upgrade
10) apxlapay.sql
Creates Payment distribution links post upgrade
REFERENCE
NOTE. 443495.1 - What are the upgrade scripts used in Payables Accounting Upgrade to R12 -
Entities from (ms sql) tables = crash
Hi,
I'm trying to create entities from tables in ms sql server, but the wizard exits with no error message and the only entity generated has no members. The only message displayed in the EJB log is "Generating classes for Entity bean Name..."
Is there any log where I could see what the problem is?
RGS
JernejJernej,
Did you try running jdev\bin\jdev.exe from a console window - it should show any stack traces there.
John -
SQL Datamodeler: Transform super/sub-entities to tables
Hello,
Suppose I have the following situation:
Super entity A
with sub-entities B and C
Sub-entity B has a mandatory attibute.
When transforming this to a relational model I expect he following result:
1. One table A, no table B and C
2. a discriminator column (to distinguish between B and C)
3. All attributes of entity A transformed into table A with same optionality
4. All attributes of entities B and C transformed to optional columns in table A
Unfortunately this is not the case. I get one table, I do NOT get a discriminator column.
Furthermore the required attribute of sub-entity B is transformed to a mandatory column of table A.
Is there a way I can influence this (in my opinon wrong) behaviour?
Regards ErikHi Erik,
you cannot influence the process. Enhancement request and bug are logged for that.
Best regards,
Philip -
Engineer to Logical Model in SQL Developer EA4 causes problems
I'm working with SQL Developer 3.0 EA4 (Build MAIN-03.97)
Unfortunately I fond out, that it would be impossible to use the function " Engineer to Logical Model" any more after I change the relational model. In datamodeler.log I got the error message line "[AWT-EventQueue-0] ERROR MDBAction - java.lang.NullPointerException" for each time I use the function "Engineer to Logical Model". I try it out with the sample model "sh_cre_all.sql" and with following steps:
1) Import via DDL File – no problem
2) Engineer to Logical Model – no problem
3) Change some attributes in the relational model – no problem
4) Again Engineer to Logical Model – no problem
5) Save, Exit an Open the sample – no problem
6) Again Step 3 and 4 – no problem
7) Add a table via drag&drop from an oracle schema – no problem
8) Save, Exit an Open the sample – no problem
9) Engineer to Logical Model no longer possible!!!
BerndI have experienced similar problems with 'Engineer to Logical model'.
The scenario was following:
Creating Logical model using 'Engineer to Logical model' from existing Relational model.
Modifying the Relational model and 'Engineer to Logical model' again. No exception occured but the Logical model wasn't updated accordingly.
Removing all entities from the Logical model.
Trying to 'Engineer to Logical model' again. No entities were created in the Logical model (even after few tries).
So I got to situation where I was unable to generate a Logical model, which was quite frustrating.
The workaround was to create new Data Modeller project and import to it from the original project - the 'Engineer to Logical model' worked again. -
PL/SQL EO design issue - OAF
Hi everyone,
A PL/SQL EO should create per business function unlike the Java EOs where we create one EO per database object. Every Java/PLSQL EO should be mapped to some entity. As PLSQL EO is not specific to particular entity (may involves DML operation on more than one table ), i found that we have to associate through some DUMMY table.
But in my case PL/SQL code is acting on entities base and TL tables ( i mean on one view - VL entity )
So i made xxxVLEO as PL/SQL EO. But my PL/SQL code needs some other attributes other than entity attributes. So i added some transient attributes to xxxVLEO and made use of that.
So now there is common xxxVLEO for both PLSQL operations and entity search operations.
Is the way i'm doing is correct???
Can we create PL/SQL EO over view???
Can u please suggest me if anything wrong.
Thanks,
Praveen KumarPraveen,
Try the OA Framework Forum OA Framework
John -
Passing parameters to PL/SQL table types
Hi Everybody,
I have one question about passing PL/SQL tables types and tabs as IN parameter in procedure.I am working in 11.2.0.2.0 environment. I am stuck on how to pass those values to procedure.Please find below more details:
Table 1:
CREATE TABLE ITEMS
ITEM_ID VARCHAR2(40 BYTE) NOT NULL,
ITEM_NAME VARCHAR2(40 BYTE),
SERIAL NUMBER(2),
ADDED_ON DATE);
Table 2:
CREATE TABLE ITEM_ACTIVITY_INFO
ITEM_ID VARCHAR2(40 BYTE) NOT NULL,
ACCOUNT_TYPE VARCHAR2(1 BYTE),
ID_NUMBER NUMBER(3),
ACTIVATION_DATE DATE);
Table 3:
CREATE TABLE ITEM_GROUP
GROUP_ID NUMBER(2) NOT NULL,
ITEM_ID VARCHAR2(40 BYTE),
GROUP_TYPE VARCHAR2(20 BYTE),
GROUP_DATE DATE);
Table 4:
CREATE TABLE ITEM_ADDRESS
GROUP_ID NUMBER(2) NOT NULL,
NAME VARCHAR2(60 BYTE),
ADDRESS VARCHAR2(100));
Following types are created:
CREATE OR REPLACE TYPE ITEMS_TYPE AS OBJECT
ITEM_ID VARCHAR2(40 BYTE),
ITEM_NAME VARCHAR2(40 BYTE),
SERIAL NUMBER(2),
ADDED_ON DATE);
CREATE OR REPLACE TYPE ITEM_ACTIVITY_TYPE AS OBJECT
ITEM_ID VARCHAR2(40 BYTE),
ACCOUNT_TYPE VARCHAR2(1 BYTE),
ID_NUMBER NUMBER(3),
ACTIVATION_DATE DATE);
CREATE OR REPLACE TYPE ITEM_GROUP_COMP_TYPE AS OBJECT
GROUP_ID NUMBER(2) NOT NULL,
ITEM_ID VARCHAR2(40 BYTE),
GROUP_TYPE VARCHAR2(20 BYTE),
GROUP_DATE DATE
ITEM_ADDRESS_IN ITEM_ADDRESS_TYPE);
CREATE OR REPLACE TYPE ITEM_ADDRESS_TYPE AS OBJECT
GROUP_ID NUMBER(2),
NAME VARCHAR2(60 BYTE),
ADDRESS VARCHAR2(100));
CREATE OR REPLACE TYPE ITEM_GROUP_COMP_TAB AS TABLE OF ITEM_GROUP_COMP_TYPE;
Create or replace procedure ITEM_ADD_CHANGE(
ITEM_IN IN ITEMS_TYPE,
ITEM_ACTIVITY_IN IN ITEM_ACTIVITY_TYPE,
ITEM_GROUP_IN IN ITEM_GROUP_COMP_TAB,
ITEM_OUT IN OUT ITEMS.ITEM_ID%TYPE);
Above are the paramteres we are passing to procedure.
I need help in how to pass parameters to above procedure. All comments and responses will be highly appreciated. Thanks everyone for going through the post. Please let me know if more more information is required on this problem.
Regards
DevBilly Verreynne wrote:
Types used in this fashion, only make sense if the table is based on the type. It makes very little sense to have a table structure and then to duplicate the structure using a type.
The 2 structures may be defined the same. But they are NOT interchangeable and requires one to be converted to the other to use. This is not sensible in my view. It is far easier in that case to simply use the PL/SQL macro +%RowType+ to create a duplicate structure definition - one that can natively be used for touching that table, without conversions required.
If you do want to use types, define the type, then define the table of that type, adding the required constraints (pk, fk, not null, check) to the table's definition.Billy:
Just curious, why do you say it makes very little sense to have a type modeled on a table? I do that a lot. In my case, I am getting the values from an external program, not building them manually, but it makes a lot of sense to me.
One application where I do this a lot has a java front-end that parses HL7 messages. Each message contains at least minimal information about a variable number of entities (and often several rows for an entity) in the database, and must be processed as a single atomic trasnaction. So, rather than have potentially hundreds of parameters to the "main" driver procedures for different message types I created a set of types more or less identical to the tables representing the entities. The java program parses the mesasge and populates the type, then calls the appropriate stored procedure for the message type passing in the populated types. My stored procedure then does inserts/updates or deletes as appropriate over potentially dozens of tables.
John -
Trying to use PL/SQL to automatically create a report that show the following:
Daily:
# of Registered Users
# of Completes (assessment) Average per User
# of Starts (assessment) Average per User
Weekly:
# of Registered Users
# of Completes (assessment) Average per User
# of Starts (assessment) Average per User
Yearly:
# of Registered Users
# of Completes (assessment) Average per User
# of Starts (assessment) Average per User
When I run the PL/SQL I get the following
[error]
ORA-01843: not a valid month
[error]
The error occurs on this part of the PL/SQL
--registered users weekly starts
select count(*), trunc(next_day(sysdate-29, 'SUNDAY')-7), trunc(sysdate-29)
into v_weekly_count_total_ru, v_weekly_start_date, v_weekly_end_date
from entities
where list_id = 3290
and participation_code_id = 10
and trunc(participation_date)
between trunc(next_day(sysdate-29, 'SUNDAY')-7) and
trunc(sysdate-29);I'm using the number 29 because I'm using a test database to test this first before moving it into production. And my test data only goes back to early August 2006.
Also, I'm not doing anything with months, so I am suprised that it is throwing this type of error.
thanksI tested a snippet of code in my production environment, just to see if I would get any results:
--registered users weekly starts
select count(*), trunc(next_day(sysdate-1, 'SUNDAY')-7), trunc(sysdate-1)
--into v_weekly_count_total_ru, v_weekly_start_date, v_weekly_end_date
from entities
where list_id = 3290
and participation_code_id = 10
and trunc(participation_date)
between trunc(next_day(sysdate-1, 'SUNDAY')-7) and trunc(sysdate-1);
COUNT(*) TRUNC(NEXT_DAY(SYSDATE-1,'SUND TRUNC(SYSDATE-1)--INTOV_WEEKLY
1 09/10/2006 00:00:00 09/11/2006 00:00:00I did a double check in my test DB to make sure there is data there:
select count(*)
from entities
where trunc(participation_date)
between to_date('01-08-2006','DD-MM-YYYY')
and to_date('14-08-2006','DD-MM-YYYY')
and list_id = 3290;
COUNT(*)
11So I'm pretty sure that I'm not pulling anything null.
thanks -
Report Builder 1.0 for SQL Server Reporting Services 2008 R2
We are trying to implement Ad-Hoc Reporting using SSRS 2008 R2.
First of all, it is very unhelpful that all SSRS books are for either 2008 or 2012, even though SSRS has major changes in 2008 R2 compared to 2008.
Our instructional materials indicate that we should build Report Models to abstract out our databases into terms familiar to our business users.
The problem we are having is the difference in functionality between Report Builder 1.0 and Report Builder 3.0. Report Builder 3.0 is touted as having the modern, ribbon based interface that is supposed to make end-users feel more comfortable. However,
all the documentation says that end users are supposed to use Report Builder 1.0 for Ad-Hoc Reporting. And, it seems, that the reports generated by Report Builder 1.0 are not round-trip compatible with all the other reporting tools for SSRS 2008 R2.
The documentation we have illustrates that Report Builder 1.0 is nice for Ad-Hoc reporting, because is based on connecting directly to Report Models, and the end users can directly drag-and-drop entities and fields into their reports.
When we try working with Report Builder 3.0, it seems we must first connect to the Report Model as a Data Source and then build a Dataset query on the Report Model. Only then are some entity attributes available to be dropped into the report.
If the user decides another source column is needed, they have to go back, edit the query, save the query, and then drag the column from the Dataset to the report. This does not seem end user friendly at all!
We are also concerned that if we train our users on the seemingly soon-to-be-obsolete Report Builder 1.0, and get them used to having direct Report Model access, that at some point we will have to move them to the Dataset-interrupted approach of Report Builder
2+. Highlighting this perception of impending obsolescence of Report Builder 1.0 is that in our shop that is starting with SSRS 2008 R2, we cannot figure out how to get a copy of Report Builder 1.0 in the first place.
We just don't see our end users being savvy enough to handle the steps involved with creating Datasets on top of Report Model Data Sources. So we would have to build the Datasets for them. But in that case, what point is there in creating any
Report Models in the first place if DBAs are the ones to make Datasets?
As such, it is hard to envision a forward-looking SSRS implementation that has the end user ease-of-use Ad-Hoc reporting that the SSRS 2008 documentation presents.
What is it that Microsoft actually wants/expects SSRS implementers to do?
Dan Jameson
Manager SQL Server DBA
CureSearch for Children's Cancer
http://www.CureSearch.orgHi Dan,
Report Builder 1.0
Simple template-based reports
Requires report model
Supports only SQL Server, Oracle, and Analysis Services as data sources
Supports RDL 2005
Bundled in SSRS
Report Builder 2.0 or later
Full-featured reports as the BIDS Report Designer
Doesn't require (but supports) report models
Supports any data source
Supports RDL 2008
Available as a separate web download
In your scenario, you want to use Report Builder 1.0 in SQL Server Reporting Services 2008 R2, I am afraid this cannot achieve. Report Builder 1.0 is available in the box in either SQL 2005 or SQL 2008. It is not available as a separate client apps and is
only available as a click once application.
Report Builder 1.0
Report Builder 3.0
Thank you for your understanding.
Regards,
Charlie Liao
If you have any feedback on our support, please click
here.
Charlie Liao
TechNet Community Support -
Comparing fields from multiple entities in the same report (report builder 1.0)
Created a model that contains 2 entities. I open that model in report builder 1.0. When I drag a field from one of the entities into the design area, i can no longer see the other entity or use any of the fields from that other entity.
I need to use fields from both entities in the same report (join tables). In management studio i would simply write a query and join tables but i cannot figure out how to do this in report builder. Once i select a field from one entity
how do i select fields from more than one entity and drag them into the same report.Would it be possible for you to send me instructions for this? I am not that familiar with SQL coding but I can definitely figure it out. I have been wanting to get information on reports from multiple entities for a very long time! The only way I can
currently do it is have our document management software people write the report for me for quite a large fee. I would much rather do this myself. Right now I can select a few fields from one entity (the main one), some from a second entity under that one,
but I cannot add any fields from a third entity! Quite annoying and hindering! Thank you :) -
How can I load this XML with sql loader ?
Hi,
Im try to load a XML file into a XML table:
Create table TEST of XMLTYPE;
XML file is something like this:
<!DOCTYPE list SYSTEM "myfile.dtd">
<list>
<item id = 1> lot of tags an info here </item>
<item id = 9000> lot of tags an info here </item>
</list>
I dont know how to exactly create an appropriate control file to my XML. All examples I saw in documentation are similar to this one:
this is an example control file
LOAD DATA
INFILE *
INTO TABLE test
APPEND
XMLTYPE (xmldata)
FIELDS
I dont know how to complete this control file. Can anyone help me ?
thank you!
Message was edited by:
pollopoleaWell I found this working code
LOAD DATA
INFILE *
INTO TABLE test APPEND
xmltype(xmldata)
FIELDS
ext_fname filler char(30),
xmldata LOBFILE (ext_fname) TERMINATED BY EOF
BEGINDATA
mifile.xml
mifile2.xml
mifile3.xml
the main diference I found is that when i use:
Insert into test values (XMLType(bfilename('XMLDIR', 'swd_uC000025127.xml'),nls_charset_id('AL32UTF8')));
tag <!DOCTYPE list SYSTEM "myfile.dtd"> is expanded
(I explain at DTD insertion and errors with long DTD entities
Now using sql loader the tag is not modified.
I dont know if is there any difference, between each case. did I lost performance?
Message was edited by:
pollopolea -
Creating and Using View Objects on JDev 10g against SQL Server 2005
I'm currently working on this project on Jdeveloper against a SQL Server 2005 DB (I couldn't talk this people to migrate to Oracle... :-( ), and it's the first time I work with JDev against a database other than 10g.
I had no problem making the connection, and I can see the DB in Conections->Databases, but when I create an app. module, and create entities and views and add them to the app. module to access them through the Data Controls, these don't work. I can see the view on the Data Controls, and when I drag them to my jspx page it shows the menu that let's me choose whether I want to create a table, or a selection, or a tree, but once I choose one, it does nothing.
I've search all over the internet and haven't found a solution, so I come to this forum desperate for help, seriously.
Please get in touch; if anyone knows another solution that doesn't involve not using JDev or SQL Server 2005, please let me know, because I basically need to have a few selectonechoice showing some data from a few tables.
Thanks for reading this post, and hope to get help.
Carlos.Hi,
can you run the model in the ADF BC tester ? If this is possible the SQL Server doesn't seem to be the problem. Are you on JDeveloper 10.1.3.3? If not, just get this latest build
Frank -
Overlapped I/O error 997 installing SQL Server 2014 Express on Windows Server 2012 R2
I'm attempting to install SQL Server 2014 Express on a Windows Server 2012 R2 system. When I do the install, it fails (several times) with an "Error: 997. Overlapped I/O operation is in progress.". From searching the web, I can see many people
have had this problem with this installer and other non-SQL server installers.
I've tried every solution I can find discussed, but none help with my problems The system is fully updated, with the exception of the KB2538243 (VC 2008 SP1 redist), which is probably failing for the same reason.
I've tried removing several updates mentioned in other articles (KB2918614). I've confirmed that I'm not using a temporary profile.
Does anyone have an idea of how I can solve this issue?
Thanks,
Zack
Partial detail from install log file:
Detailed results:
Feature: Management Tools - Complete
Status: Failed: see logs for details
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, and then try the setup process again.
Component name: Microsoft Visual Studio 2010 Redistributables
Component error code: 997
Component log file: C:\Program Files\Microsoft SQL Server\120\Setup Bootstrap\Log\20150205_151618\VC10Redist_Cpu64_1.log
Error description: Error 997.Overlapped I/O operation is in progress.
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=12.0.2000.8&EvtType=vc_red.msi%40ProcessComponents%40997
Feature: Client Tools Connectivity
Status: Failed: see logs for details
Reason for failure: An error occurred for a dependency of the feature causing the setup process for the feature to fail.
Next Step: Use the following information to resolve the error, and then try the setup process again.
Component name: Microsoft Visual Studio 2010 Redistributables
Component error code: 997
Component log file: C:\Program Files\Microsoft SQL Server\120\Setup Bootstrap\Log\20150205_151618\VC10Redist_Cpu64_1.log
Error description: Error 997.Overlapped I/O operation is in progress.
Error help link: http://go.microsoft.com/fwlink?LinkId=20476&ProdName=Microsoft+SQL+Server&EvtSrc=setup.rll&EvtID=50000&ProdVer=12.0.2000.8&EvtType=vc_red.msi%40ProcessComponents%40997
Partial detail from component log file:
MSI (s) (D8:3C) [15:18:29:173]: Resolving source.
MSI (s) (D8:3C) [15:18:29:173]: Resolving source to launched-from source.
MSI (s) (D8:3C) [15:18:29:173]: Setting launched-from source as last-used.
MSI (s) (D8:3C) [15:18:29:188]: PROPERTY CHANGE: Adding SourceDir property. Its value is 'C:\Users\zerhart\Downloads\SQLEXPRWT_x64_ENU\redist\VisualStudioShell\VC10SP1\x64\'.
MSI (s) (D8:3C) [15:18:29:188]: PROPERTY CHANGE: Adding SOURCEDIR property. Its value is 'C:\Users\zerhart\Downloads\SQLEXPRWT_x64_ENU\redist\VisualStudioShell\VC10SP1\x64\'.
MSI (s) (D8:3C) [15:18:29:188]: PROPERTY CHANGE: Adding SourcedirProduct property. Its value is '{1D8E6291-B0D5-35EC-8441-6616F567A0F7}'.
MSI (s) (D8:3C) [15:18:29:188]: SOURCEDIR ==> C:\Users\zerhart\Downloads\SQLEXPRWT_x64_ENU\redist\VisualStudioShell\VC10SP1\x64\
MSI (s) (D8:3C) [15:18:29:188]: SOURCEDIR product ==> {1D8E6291-B0D5-35EC-8441-6616F567A0F7}
MSI (s) (D8:3C) [15:18:29:188]: SECREPAIR: A general error running CryptAcquireContext
MSI (s) (D8:3C) [15:18:29:188]: Determining source type
MSI (s) (D8:3C) [15:18:29:188]: Source type from package 'VC_RED.MSI': 2
MSI (s) (D8:3C) [15:18:29:188]: SECREPAIR: Hash Database: C:\Windows\Installer\SourceHash{1D8E6291-B0D5-35EC-8441-6616F567A0F7}
MSI (s) (D8:3C) [15:18:29:188]: SECREPAIR: SourceHash database file already exists. Deleting it.
MSI (s) (D8:3C) [15:18:29:204]: Note: 1: 2262 2: SourceHash 3: -2147287038
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: New Hash Database creation complete.
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: Crypt Provider not initialized. Error:0
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: Crypt Provider not initialized. Error:0
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: Crypt Provider not initialized. Error:0
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: Crypt Provider not initialized. Error:0
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: Crypt Provider not initialized. Error:0
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: Crypt Provider not initialized. Error:0
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: Crypt Provider not initialized. Error:997
MSI (s) (D8:3C) [15:18:29:235]: SECUREREPAIR: Failed to CreateContentHash of the file: install.res.1040.dll: for computing its hash. Error: 997
MSI (s) (D8:3C) [15:18:29:235]: SECREPAIR: Failed to create hash for the install source files
MSI (s) (D8:3C) [15:18:29:235]: SECUREREPAIR: SecureRepair Failed. Error code: 3e561F257D8
Action start 15:18:29: ProcessComponents.
MSI (s) (D8:3C) [15:19:28:843]:
Error 997.Overlapped I/O operation is in progress.Alberto,
Thanks for your help. Unfortunately, I've already tried that. I did try it again and I get an "This update is not applicable to your computer."
I tried to post the Windows Update log, but it was too large. I've posted some of it below.
Here is the WU log:
2015-02-06 11:24:25:793
5048 50
Misc =========== Logging initialized (build: 7.9.9600.17489, tz: -0500) ===========
2015-02-06 11:24:25:793
5048 50
Misc = Process: C:\Windows\system32\wusa.exe
2015-02-06 11:24:25:793
5048 50
Misc = Module: C:\Windows\System32\wuapi.dll
2015-02-06 11:24:25:793
5048 50
COMAPI ----------- COMAPI: IUpdateServiceManager::AddScanPackageService -----------
2015-02-06 11:24:25:793
5048 50
COMAPI - ServiceName = Windows Update Standalone Installer
2015-02-06 11:24:25:793
5048 50
COMAPI - ScanFileLocation = C:\c5f288db3c43a7e4613232ca1a3c\wsusscan.cab
2015-02-06 11:24:25:808
920 111c
Misc =========== Logging initialized (build: 7.9.9600.17489, tz: -0500) ===========
2015-02-06 11:24:25:808
920 111c
Misc = Process: C:\Windows\system32\svchost.exe
2015-02-06 11:24:25:808
920 111c
Misc = Module: c:\windows\system32\wuaueng.dll
2015-02-06 11:24:25:808
920 111c
Service *************
2015-02-06 11:24:25:808
920 111c
Service ** START ** Service: Service startup
2015-02-06 11:24:25:808
920 111c
Service *********
2015-02-06 11:24:25:824
920 111c
IdleTmr Non-AoAc machine. Aoac operations will be ignored.
2015-02-06 11:24:25:824
920 111c
Agent * WU client version 7.9.9600.17489
2015-02-06 11:24:25:824
920 111c
Agent WARNING: SleepStudyTracker: Machine is non-AOAC. Sleep study tracker disabled.
2015-02-06 11:24:25:824
920 111c
Agent * Base directory: C:\Windows\SoftwareDistribution
2015-02-06 11:24:25:824
920 111c
Agent * Access type: No proxy
2015-02-06 11:24:25:824
920 111c
Service UpdateNetworkState Ipv6, cNetworkInterfaces = 12.
2015-02-06 11:24:25:824
920 111c
Service UpdateNetworkState Ipv4, cNetworkInterfaces = 4.
2015-02-06 11:24:25:824
920 111c
Agent * Network state: Connected
2015-02-06 11:24:25:824
920 111c
Service UpdateNetworkState Ipv6, cNetworkInterfaces = 12.
2015-02-06 11:24:25:824
920 111c
Service UpdateNetworkState Ipv4, cNetworkInterfaces = 4.
2015-02-06 11:24:25:855
920 b64
Misc WARNING: Network Cost is assumed to be not supported as something failed with trying to get handles to wcmapi.dll
2015-02-06 11:24:25:855
920 111c
Agent *********** Agent: Initializing global settings cache ***********
2015-02-06 11:24:25:887
920 111c
Agent * Endpoint Provider: 00000000-0000-0000-0000-000000000000
2015-02-06 11:24:25:887
920 111c
Agent * WSUS server: <NULL>
2015-02-06 11:24:25:887
920 111c
Agent * WSUS status server: <NULL>
2015-02-06 11:24:25:887
920 111c
Agent * Target group: (Unassigned Computers)
2015-02-06 11:24:25:887
920 111c
Agent * Windows Update access disabled: No
2015-02-06 11:24:25:902
920 b64
WuTask WuTaskManager delay initialize completed successfully..
2015-02-06 11:24:25:902
920 b64
AU Timer: 31DA7559-FE27-4810-8FF6-987195B1FD98, Expires 2015-02-07 08:14:01, not idle-only, not network-only
2015-02-06 11:24:25:902
920 b64
AU Timer: CF1ABEC6-7887-4964-BB93-B2E21B31CEC1, Expires 2015-02-06 19:30:54, not idle-only, not network-only
2015-02-06 11:24:25:902
920 b64
AU Timer: 29A863E7-8609-4D1E-B7CD-5668F857F1DB, Expires 2015-02-06 19:30:54, not idle-only, not network-only
2015-02-06 11:24:25:902
920 b64
Report WARNING: CSerializationHelper:: InitSerialize failed : 0x80070002
2015-02-06 11:24:25:902
920 b64
Report CWERReporter::Init succeeded
2015-02-06 11:24:25:902
920 b64
Agent *********** Agent: Initializing Windows Update Agent ***********
2015-02-06 11:24:25:902
920 b64
DnldMgr Download manager restoring 0 downloads
2015-02-06 11:24:25:902
920 111c
AU ########### AU: Initializing Automatic Updates ###########
2015-02-06 11:24:25:902
920 111c
AU AIR Mode is disabled
2015-02-06 11:24:25:902
920 111c
AU # Approval type: Scheduled (User preference)
2015-02-06 11:24:25:902
920 111c
AU # Auto-install minor updates: Yes (User preference)
2015-02-06 11:24:25:902
920 111c
AU # Will interact with non-admins (Non-admins are elevated (User preference))
2015-02-06 11:24:25:902
920 111c
Misc WARNING: IsSessionRemote: WinStationQueryInformationW(WTSIsRemoteSession) failed for session 2, GetLastError=2250
2015-02-06 11:24:25:918
920 111c
AU WARNING: Failed to get Wu Exemption info from NLM, assuming not exempt, error = 0x80240037
2015-02-06 11:24:25:918
920 111c
AU WARNING: Failed to get Network Cost info from NLM, assuming network is NOT metered, error = 0x80240037
2015-02-06 11:24:25:918
920 111c
AU AU finished delayed initialization
2015-02-06 11:24:25:933
920 111c
AU WARNING: Failed to get Network Cost info from NLM, assuming network is NOT metered, error = 0x80240037
2015-02-06 11:24:25:933
920 111c
AU WARNING: Failed to get Network Cost info from NLM, assuming network is NOT metered, error = 0x80240037
2015-02-06 11:24:25:933
920 b64
Misc Validating signature for C:\Windows\SoftwareDistribution\ScanFile\a487aa0f-3e53-4fee-a784-6171b00254e4\Source.cab with dwProvFlags 0x00000080:
2015-02-06 11:24:25:933
920 111c
AU Adding timer:
2015-02-06 11:24:25:933
920 111c
AU Timer: 31DA7559-FE27-4810-8FF6-987195B1FD98, Expires 2015-02-07 08:14:01, not idle-only, not network-only
2015-02-06 11:24:25:949
920 af0
DnldMgr Asking handlers to reconcile their sandboxes
2015-02-06 11:24:25:949
920 b64
Misc Microsoft signed: Yes
2015-02-06 11:24:26:154
920 b64
DtaStor Default service for AU is {7971F918-A847-4430-9279-4A52D1EFE18D}
2015-02-06 11:24:26:154
920 b64
IdleTmr Incremented idle timer priority operation counter to 1
2015-02-06 11:24:26:154
5048 50
COMAPI - Added scan package service, ServiceID = {A487AA0F-3E53-4FEE-A784-6171B00254E4} Third party service
2015-02-06 11:24:26:154
5048 50
COMAPI -------------
2015-02-06 11:24:26:154
5048 50
COMAPI -- START -- COMAPI: Init Search [ClientId = wusa]
2015-02-06 11:24:26:154
5048 50
COMAPI ---------
2015-02-06 11:24:26:154
5048 50
COMAPI -------------
2015-02-06 11:24:26:154
5048 50
COMAPI -- START -- COMAPI: Search [ClientId = wusa]
2015-02-06 11:24:26:154
5048 50
COMAPI ---------
2015-02-06 11:24:26:169
920 b64
IdleTmr WU operation (CSearchCall::Init ID 1) started; operation # 17; does use network; is not at background priority
2015-02-06 11:24:26:169
920 b64
IdleTmr Incremented idle timer priority operation counter to 2
2015-02-06 11:24:26:341
920 b64
Report *********** Report: Initializing static reporting data ***********
2015-02-06 11:24:26:341
920 b64
Report * OS Version = 6.3.9600.0.0.131344
2015-02-06 11:24:26:341
920 b64
Report * OS Product Type = 0x00000021
2015-02-06 11:24:26:357
920 b64
Report * Computer Brand = PowerSpec
2015-02-06 11:24:26:357
920 b64
Report * Computer Model = S Series
2015-02-06 11:24:26:357
920 b64
Report * Platform Role = 1
2015-02-06 11:24:26:357
920 b64
Report * AlwaysOn/AlwaysConnected (AOAC) = 0
2015-02-06 11:24:26:357
920 b64
Report * Bios Revision = 1.1a
2015-02-06 11:24:26:357
920 b64
Report * Bios Name = 1.1a
2015-02-06 11:24:26:357
920 b64
Report * Bios Release Date = 2013-08-20T00:00:00
2015-02-06 11:24:26:357
920 b64
Report * Bios Sku Number = S Series
2015-02-06 11:24:26:357
920 b64
Report * Bios Vendor = American Megatrends Inc.
2015-02-06 11:24:26:357
920 b64
Report * Bios Family = Server
2015-02-06 11:24:26:357
920 b64
Report * Bios Major Release = 4
2015-02-06 11:24:26:357
920 b64
Report * Bios Minor Release = 6
2015-02-06 11:24:26:357
920 b64
Report * Locale ID = 1033
2015-02-06 11:24:26:357
920 b64
Handler Calculating current update level for this session
[ Omitted data ]
http://support.microsoft.com/?kbid=3000850, timestamp 01d039c57a22c0be
2015-02-06 11:24:28:388
920 b64
Handler Done calculating current update level for this session
2015-02-06 11:24:28:982
920 b64
Agent *** START *** Queueing Finding updates [CallerId = wusa Id = 1]
2015-02-06 11:24:28:982
5048 50
COMAPI <<-- SUBMITTED -- COMAPI: Search [ClientId = wusa]
2015-02-06 11:24:28:982
920 11f4
Agent *** END *** Queueing Finding updates [CallerId = wusa Id = 1]
2015-02-06 11:24:28:982
920 11f4
Agent *************
2015-02-06 11:24:28:982
920 11f4
Agent ** START ** Agent: Finding updates [CallerId = wusa Id = 1]
2015-02-06 11:24:28:982
920 11f4
Agent *********
2015-02-06 11:24:28:982
920 11f4
Agent * Online = Yes; Ignore download priority = No
2015-02-06 11:24:28:982
920 11f4
Agent * Criteria = "DeploymentAction='Installation'"
2015-02-06 11:24:28:982
920 11f4
Agent * ServiceID = {A487AA0F-3E53-4FEE-A784-6171B00254E4} Third party service
2015-02-06 11:24:28:982
920 11f4
Agent * Search Scope = {Machine}
2015-02-06 11:24:28:982
920 11f4
Agent * Caller SID for Applicability: S-1-5-21-3157695610-3447843402-2534478823-500
2015-02-06 11:24:28:982
920 11f4
Agent * RegisterService is set
2015-02-06 11:24:29:185
920 11f4
PT +++++++++++ PT: Synchronizing server updates +++++++++++
2015-02-06 11:24:29:185
920 11f4
PT + Offline serviceId = {A487AA0F-3E53-4FEE-A784-6171B00254E4}
2015-02-06 11:24:29:185
920 11f4
PT WARNING: Cached cookie has expired or new PID is available
2015-02-06 11:24:29:185
920 11f4
Agent Reading cached app categories using lifetime 604800 seconds
2015-02-06 11:24:29:185
920 11f4
Agent Read 0 cached app categories
2015-02-06 11:24:29:185
920 11f4
Agent SyncUpdates adding 0 visited app categories
2015-02-06 11:24:29:294
920 11f4
Agent Reading cached app categories using lifetime 604800 seconds
2015-02-06 11:24:29:294
920 11f4
Agent Read 0 cached app categories
2015-02-06 11:24:29:294
920 11f4
Agent SyncUpdates adding 0 visited app categories
2015-02-06 11:24:29:357
920 11f4
Agent Reading cached app categories using lifetime 604800 seconds
2015-02-06 11:24:29:357
920 11f4
Agent Read 0 cached app categories
2015-02-06 11:24:29:357
920 11f4
Agent SyncUpdates adding 0 visited app categories
2015-02-06 11:24:29:638
920 11f4
Agent Reading cached app categories using lifetime 604800 seconds
2015-02-06 11:24:29:638
920 11f4
Agent Read 0 cached app categories
2015-02-06 11:24:29:638
920 11f4
Agent SyncUpdates adding 0 visited app categories
2015-02-06 11:24:30:013
920 11f4
Agent Reading cached app categories using lifetime 604800 seconds
2015-02-06 11:24:30:013
920 11f4
Agent Read 0 cached app categories
2015-02-06 11:24:30:013
920 11f4
Agent SyncUpdates adding 0 visited app categories
2015-02-06 11:24:30:044
920 11f4
Agent Reading cached app categories using lifetime 604800 seconds
2015-02-06 11:24:30:044
920 11f4
Agent Read 0 cached app categories
2015-02-06 11:24:30:044
920 11f4
Agent SyncUpdates adding 0 visited app categories
2015-02-06 11:24:30:044
920 11f4
PT + SyncUpdates round trips: 5
2015-02-06 11:24:30:076
920 11f4
PT +++++++++++ PT: Synchronizing extended update info +++++++++++
2015-02-06 11:24:30:076
920 11f4
PT + Offline serviceId = {A487AA0F-3E53-4FEE-A784-6171B00254E4}
2015-02-06 11:24:30:138
920 11f4
Agent * Found 0 updates and 54 categories in search; evaluated appl. rules of 126 out of 284 deployed entities
2015-02-06 11:24:30:138
920 11f4
Agent *********
2015-02-06 11:24:30:138
920 11f4
Agent ** END ** Agent: Finding updates [CallerId = wusa Id = 1]
2015-02-06 11:24:30:138
920 11f4
Agent *************
2015-02-06 11:24:30:138
920 11f4
IdleTmr WU operation (CSearchCall::Init ID 1, operation # 17) stopped; does use network; is not at background priority
2015-02-06 11:24:30:138
920 11f4
IdleTmr Decremented idle timer priority operation counter to 1
2015-02-06 11:24:30:154
5048 1428
COMAPI >>-- RESUMED -- COMAPI: Search [ClientId = wusa]
2015-02-06 11:24:30:154
5048 1428
COMAPI - Updates found = 0
2015-02-06 11:24:30:154
5048 1428
COMAPI ---------
2015-02-06 11:24:30:154
5048 1428
COMAPI -- END -- COMAPI: Search [ClientId = wusa]
2015-02-06 11:24:30:154
5048 1428
COMAPI ------------- -
Can some one please tell me what is the problem in the below pl/sql block
Hi, I have problem with the following pl/sql block, I need this with bulk operation.
-- Assume the following scenario, we are validating dept (master) and emp(child) which are my temporary tables and updating the status back to
-- dept ( for all the validation errors, even if we have any validation at child it has to update the header record with error message),
-- upon successful validation insert the data into dept3, and emp3 interms of batches
-- I have give the sample example with dept and emp, but i have around 10 million records which has around 30-40 validations,
-- I would like to process them in terms of batches using bulk collection as this would do fast processing
-- Can some one please tell me how to insert them in terms of bulk with every set of 1000 records in each batch in this example,for every set of 1000 records
-- i need update batch id with unique number in dept table
-- with current data i can have 50 batches , I need to pass, deptno as parameter to my emp cursor.
-- can some one please tell me how to make this validation and insertion more efficient. so that while inserting the data for every batch it should insert batch id
-- Tried with LIMIT clause as well but not working
-- I am correcting the code as per your comments Request you to please suggest me so that I can correct , I am new to PL/sql, started learning now.
step - 1:
CREATE TABLE DEPT
(DEPTNO NUMBER(6) primary key,
DNAME VARCHAR2(25),
LOC VARCHAR2(23),
batch_id number );
INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK', null);
INSERT INTO DEPT VALUES (20, 'RESEARCH', 'DALLAS', null);
INSERT INTO DEPT VALUES (30, 'SALES', 'CHICAGO', null);
INSERT INTO DEPT VALUES (40, 'OPERATIONS', 'BOSTON', null);
step - 2:
declare
begin
for i in 1..50000 loop
insert into dept values(40+i, 'OPERATIONS'||i,'BOSTON'||i, null);
end loop;
commit;
exception
when others then
dbms_output.put_line('Exception occured:'||SQLERRM);
end;
step - 3:
create sequence emp_seq start with 1 increment by 1;
step - 4:
CREATE TABLE EMP
(EMPNO NUMBER(15) NOT NULL primary key,
ENAME VARCHAR2(20),
JOB VARCHAR2(20),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7, 2),
COMM NUMBER(7, 2),
DEPTNO NUMBER(6));
INSERT INTO EMP VALUES
(7369, 'SMITH', 'CLERK', 7902,
TO_DATE('17-DEC-1980', 'DD-MON-YYYY'), 800, NULL, 20);
INSERT INTO EMP VALUES
(7499, 'ALLEN', 'SALESMAN', 7698,
TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), 1600, 300, 30);
INSERT INTO EMP VALUES
(7521, 'WARD', 'SALESMAN', 7698,
TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250, 500, 30);
INSERT INTO EMP VALUES
(7566, 'JONES', 'MANAGER', 7839,
TO_DATE('2-APR-1981', 'DD-MON-YYYY'), 2975, NULL, 20);
INSERT INTO EMP VALUES
(7654, 'MARTIN', 'SALESMAN', 7698,
TO_DATE('28-SEP-1981', 'DD-MON-YYYY'), 1250, 1400, 30);
INSERT INTO EMP VALUES
(7698, 'BLAKE', 'MANAGER', 7839,
TO_DATE('1-MAY-1981', 'DD-MON-YYYY'), 2850, NULL, 30);
INSERT INTO EMP VALUES
(7782, 'CLARK', 'MANAGER', 7839,
TO_DATE('9-JUN-1981', 'DD-MON-YYYY'), 2450, NULL, 10);
INSERT INTO EMP VALUES
(7788, 'SCOTT', 'ANALYST', 7566,
TO_DATE('09-DEC-1982', 'DD-MON-YYYY'), 3000, NULL, 20);
INSERT INTO EMP VALUES
(7839, 'KING', 'PRESIDENT', NULL,
TO_DATE('17-NOV-1981', 'DD-MON-YYYY'), 5000, NULL, 10);
INSERT INTO EMP VALUES
(7844, 'TURNER', 'SALESMAN', 7698,
TO_DATE('8-SEP-1981', 'DD-MON-YYYY'), 1500, NULL, 30);
INSERT INTO EMP VALUES
(7876, 'ADAMS', 'CLERK', 7788,
TO_DATE('12-JAN-1983', 'DD-MON-YYYY'), 1100, NULL, 20);
INSERT INTO EMP VALUES
(7900, 'JAMES', 'CLERK', 7698,
TO_DATE('3-DEC-1981', 'DD-MON-YYYY'), 950, NULL, 30);
INSERT INTO EMP VALUES
(7902, 'FORD', 'ANALYST', 7566,
TO_DATE('3-DEC-1981', 'DD-MON-YYYY'), 3000, NULL, 20);
INSERT INTO EMP VALUES
(7934, 'MILLER', 'CLERK', 7782,
TO_DATE('23-JAN-1982', 'DD-MON-YYYY'), 1300, NULL, 10);
commit;
step :- 5
declare
cursor c1 is select * from dept;
k number:=0;
m number:=0;
begin
for i in c1 loop
k:=k+1;
--dbms_output.put_line('k:'||k);
--dbms_output.put_line('i.deptno:'||i.deptno);
m:=0;
for j in 1..5 loop
m:=m+1;
--dbms_output.put_line('m:'||m);
--dbms_output.put_line('i.deptno:'||i.deptno);
insert into emp values
(9000+emp_seq.nextval, 'SMITH'||'_'||emp_seq.currval, 'CLERK'||'_'||emp_seq.currval, 7902,
TO_DATE('17-DEC-1980', 'DD-MON-YYYY'), 800, NULL, i.deptno);
end loop;
end loop;
commit;
exception
when others then
dbms_output.put_line('Exception occured:'||sqlerrm);
end;
step :-6
create table dept3 as select * from dept where 1=2;
create table emp3 as select * from emp where 1=2;
alter table dept add object_id number;
alter table dept add status varchar(20);
alter table dept add err_msg varchar2(200);
alter table emp add object_id number;
-- I have not included the alter statements in the inital creation because i dont want them to insert into dept3 and emp3
CREATE OR REPLACE
PACKAGE test_b
AS
g_batch_id NUMBER;
PROCEDURE emp_ins(
p_EMPNO NUMBER,
p_ENAME VARCHAR2,
p_JOB VARCHAR2,
p_MGR NUMBER,
p_HIREDATE DATE,
p_SAL NUMBER,
p_COMM NUMBER,
p_DEPTNO NUMBER);
PROCEDURE dept_ins(
p_DEPTNO NUMBER,
p_dname VARCHAR2 ,
p_LOC VARCHAR2,
p_batch NUMBER);
PROCEDURE validate_prc;
PROCEDURE main;
TYPE dept_t
IS
TABLE OF dept%ROWTYPE;
hdr_tbl dept_t;
TYPE emp_t
IS
TABLE OF emp%ROWTYPE;
line_tbl emp_t;
TYPE dept_i_t
IS
TABLE OF dept3%ROWTYPE;
hdr_ins_tbl dept_i_t;
TYPE emp_i_t
IS
TABLE OF emp3%ROWTYPE;
line_ins_tbl emp_i_t;
END;
-- pacakge body
CREATE OR REPLACE
PACKAGE body test_b
AS
PROCEDURE emp_ins(
p_EMPNO NUMBER,
p_ENAME VARCHAR2,
p_JOB VARCHAR2,
p_MGR NUMBER,
p_HIREDATE DATE,
p_SAL NUMBER,
p_COMM NUMBER,
p_DEPTNO NUMBER)
IS
BEGIN
INSERT
INTO EMP3
EMPNO ,
ENAME ,
JOB ,
MGR ,
HIREDATE ,
SAL ,
COMM ,
DEPTNO
VALUES
P_EMPNO ,
P_ENAME ,
P_JOB ,
P_MGR ,
P_HIREDATE ,
P_SAL ,
P_COMM ,
P_DEPTNO
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('EXCEPTION AT EMP INSERT'||SQLERRM);
END;
PROCEDURE dept_ins
p_DEPTNO NUMBER,
p_dname VARCHAR2 ,
p_LOC VARCHAR2,
p_batch NUMBER
IS
BEGIN
INSERT
INTO DEPT3
DEPTNO ,
DNAME ,
LOC ,
batch_id
VALUES
p_DEPTNO ,
p_DNAME ,
p_LOC ,
p_batch
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('EXCEPTION AT DEPT INSERT'||SQLERRM);
END ;
PROCEDURE validate_prc
IS
CURSOR c1
IS
SELECT * FROM dept WHERE status IS NULL ;--AND rownum <25;
CURSOR c2(p_dept NUMBER )
IS
SELECT * FROM emp WHERE deptno=p_dept;
e_validation EXCEPTION;
BEGIN
OPEN c1;
LOOP
FETCH c1 BULK COLLECT INTO hdr_tbl limit 5000;
SELECT emp_seq.nextval INTO g_batch_id FROM dual;
EXIT
WHEN hdr_tbl.count = 0;
dbms_output.put_line('batch'||g_batch_id);
END LOOP;
CLOSE c1;
dbms_output.put_line('C1 closed');
--------- Loading data into the inv line table type -------------------------------
FOR i IN 1 .. hdr_tbl.count
LOOP
dbms_output.put_line('started validation');
-- do header level validations
IF hdr_tbl(i).dname IS NULL THEN
hdr_tbl(i).status := 'ERROR';
hdr_tbl(i).err_msg :=',DNAME is null';
END IF;
OPEN c2(hdr_tbl(i).deptno);
LOOP
FETCH c2 BULK COLLECT INTO line_tbl;
-- EXIT WHEN c2%NOTFOUND;
END LOOP;
CLOSE c2;
FOR j IN 1 .. line_tbl.count
LOOP
-- do line validations
IF line_tbl(j).ename IS NULL THEN
hdr_tbl(i).status := 'ERROR';
hdr_tbl(i).err_msg :=',ENAME is null';
END IF;
BEGIN
FORALL j IN line_tbl.FIRST .. line_tbl.LAST
SAVE EXCEPTIONS
UPDATE EMP
SET object_id =3
-- I have multiple columns to update based on validations
WHERE deptno =hdr_tbl(i).deptno------------
AND empno =line_tbl (j).empno;
COMMIT;
line_tbl.DELETE;
dbms_output.put_line( 'Successfully updated emp temp table.');
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
dbms_output.put_line( 'Error while updating line temp table. ' || sqlerrm );
FOR j IN 1 .. sql%BULK_EXCEPTIONS.COUNT
LOOP
DBMS_OUTPUT.put_line(' occurred during line temp table updation ' || sql%BULK_EXCEPTIONS(i).ERROR_INDEX );
END LOOP;
raise e_validation;
END;
END LOOP; -- j
--CLOSE c2;
IF hdr_tbl(i).err_msg IS NULL THEN
hdr_tbl (i).status := 'VALID';
hdr_tbl (i).err_msg := NULL;
END IF;
-- even if I have line validation failed I have to update header status and erorr msg
BEGIN
FORALL i IN hdr_tbl.FIRST .. hdr_tbl.LAST
SAVE EXCEPTIONS
UPDATE DEPT
SET object_id =4,
status = hdr_tbl (i).status,
err_msg = hdr_tbl (i).err_msg
-- batch_id =
-- I have multiple columns to update based on validations
WHERE deptno = hdr_tbl (i).deptno
AND status IS NULL; ------------
COMMIT;
hdr_tbl.DELETE;
dbms_output.put_line( 'Successfully updated dept temp table.');
--close c1;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
dbms_output.put_line( 'Error while updating hdr temp table. ' || sqlerrm );
FOR i IN 1 .. sql%BULK_EXCEPTIONS.COUNT
LOOP
DBMS_OUTPUT.put_line(' occurred during line temp table updation ' || sql%BULK_EXCEPTIONS(i).ERROR_INDEX );
END LOOP;
raise e_validation;
END;
END LOOP; --i
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('EXCEPTION AT validate'||SQLERRM);
END ;
PROCEDURE main
IS
CURSOR dept_ins_cur
IS
SELECT * FROM dept WHERE status='VALID';
CURSOR emp_ins_cur(p_deptno NUMBER)
IS
SELECT * FROM emp WHERE deptno= p_deptno;
BEGIN
validate_prc;
OPEN dept_ins_cur;
LOOP
FETCH dept_ins_cur BULK COLLECT INTO hdr_ins_tbl limit 1000
EXIT
WHEN dept_ins_cur%NOTFOUND;
END LOOP;
CLOSE dept_ins_cur;
--------- Loading data into the inv line table type -------------------------------
FOR i IN 1 .. hdr_tbl.count
loop
dept_ins(hdr_ins_tbl(i).deptno ,
hdr_ins_tbl(i).DNAME ,
hdr_ins_tbl(i).LOC , emp_seq.nextval);
commit;
OPEN emp_ins_cur(hdr_ins_tbl(i).deptno);
LOOP
FETCH emp_ins_cur BULK COLLECT INTO line_ins_tbl;
--EXIT WHEN emp_ins_cur%NOTFOUND;
END LOOP;
CLOSE emp_ins_cur;
for j in 1..line_ins_tbl.count loop
emp_ins(line_ins_tbl(j).EMPNO ,
line_ins_tbl(j).ENAME ,
line_ins_tbl(j).JOB ,
line_ins_tbl(j).MGR ,
line_ins_tbl(j).HIREDATE ,
line_ins_tbl(j).SAL ,
line_ins_tbl(j).comm ,
line_ins_tbl(j).DEPTNO );
end loop;
end loop;
commit;
BEGIN
forall i IN hdr_ins_tbl.first .. hdr_ins_tbl.last
SAVE exceptions
UPDATE dept
SET status = 'INSERTED',
err_msg = null
WHERE deptno=hdr_ins_tbl (i).deptno
AND status = 'VALID';
COMMIT;
hdr_ins_tbl.delete;
dbms_output.put_line( 'inserting into temp tables.');
EXCEPTION
WHEN OTHERS THEN
rollback;
end;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('exception in main' ||SQLERRM);
END ;
END;
Thanks in advance...
Message was edited by: 888025Hi, I have problem with the following pl/sql block
Well, as Hoek already said, that is the understatement of the century.
I can't be absolutely certain but I think that set of DDL and code that you posted has just about every possible error and design issue that there is! It would make an excellent addition to BluShadow's FAQs an an example of what NOT to do.
I don't think it is even possible to 'fix the basics first' as Hoek suggested. IMHO the first step needs to be to create a functional requirements document (FRD) that explains in detail WHAT needs to be done. That doc should also contain info about how any errors/recovery/restart is to be handled. It is premature to try to implement ANY solution without first knowing what is needed functionally.
Once the FRD is done you should do a walk-through based on your current architecture and sample data to make sure that the document really covers ALL of the steps that need to be performed and that it adequately explains how to deal with any processing or data issues that might arise.
The next document you need is the TRD - Technical Requirements Doc that covers the different technical implementions of the FRD that can be done and the advantages/disadvantages of each.
Then you can start working on a prototype.
1. The DDL you posted isn't coherent - there are CREATE table statements and then later ALTER statements that add additional columns. There doesn't appear to be any reason for not including ALL of the columns in the CREATE table statement.
2. You are using PL/SQL types instead of SQL types. That makes it impossible to use those types in SQL statements and makes it much more difficult to test since it is much easier to test a query in SQL (e.g. using sql*plus) that to embed the query in PL/SQL.
3. You are defining the same type twice but giving it different names.
TYPE dept_t
IS
TABLE OF dept%ROWTYPE
INDEX BY binary_integer;
TYPE dept_i_t
IS
TABLE OF dept%ROWTYPE
INDEX BY binary_integer;
Those are both based on the same DEPT table! Why the duplication?
Also you are using associative arrays instead of just using nested tables. Get rid of the INDEX BY clause.
4. You have some serious architectural and data model issues
-- Assume the following scenario, we are validating dept (master) and emp(child) which are my temporary tables and updating the status back to
-- dept ( for all the validation errors, even if we have any validation at child it has to update the header record with error message),
Why would you do that? You say 'it has to update the header record ...'. Says who? That is just one indication that you are trying to implement a 'solution' before you have adequately defined the 'problem'.
Typically you would NOT alter any of the data tables; any validation errors/issues would get inserted into a table specifically designed to hold/log those issues. That table would contain key field values to correlate with the source of the error.
Those 'master' and 'child' entities are two SEPARATE things. Issues with a 'master' row have NOTHING to do with any possible child rows.
And issues with a 'child' row have NOTHING to do with any possible master rows. The ONLY connection between 'child' and 'master' is the foreign key that correlates them.
So you don't necessarily have to validate the 'child' rows in sync with their 'master' row. In many cases you would have a procedure that performs validation of the entire set of 'master' rows and log those issues/problems. You would use a different procedure to validate the entire set of 'child' rows and log their issues.
Those validation procedures can often work with ALL of the data using SQL statements instead of bulk processing.
5. You are using loop constructs that are not valid for the type of processing you are using
LOOP
FETCH c1 BULK COLLECT INTO hdr_tbl;
EXIT
WHEN c1%NOTFOUND;
END LOOP;
There can be NO exit since the bulk collect with either get EVERYTHING or NOTHING. Possibly that is just a holdover from your attempt to use the LIMIT clause but you removed that clause from the FETCH; I don't know.
There is so much wrong with what you posted it is really rather pointless to try to 'fix' it.
I suggest you start over and clarify and DOCUMENT the actual requirements without prejudice about the solution that someone seems to want to force on you. -
Greetings,
What are the entities that can be re-used in different servers, SI App, SI instance? And how?
e.g. can I use a deployed IQStreamable@app1 into app2?
can I use a deployed observable/app1/siInstance1/Server1 into another query/app3/siInstance3/server2?
On the presentation titled "04 – Installing, Deploying and Maintaining the SQL Server 2008 R2 StreamInsight Runtime Engine" with file name SQL10R2UPD05-DECK-04.pptx on ecn.channel9.msdn.com/o9/learn/SQL2008R2TrainingKit/Presentations/SQL10R2UPD05-DECK-04/SQL10R2UPD05-DECK-04.pptx
It is mentioned one of the deployment option is "Deployment: Standalone Server"
and it mention the following:
"Use this option for the following scenarios:
- Metadata objects need to be shared between applications
- Event Types
- Adapter Types
- Query Templates
- A data source registered with the server provides an event stream for another existing application"
Could you please provide good example that explain the above statement?
Cheers, MuhammadFirst, that statement - and those materials - refer to the "legacy" StreamInsight query/adapter model. They do not refer to how things work with the Reactive model introduced in version 2.1. Specifically, it talks about Dynamic Query Composition (DQC).
You cannot use a deployed Observable in another instance of StreamInsight. You may be able to use them across applications in the same instance - off the top of my head, I'm not sure. I'm getting ready to get on a plane but will take a look at it later.
Typically, however, applications act as containers (comparable to .NET AppDomains) so I don't think that you'd be able to do this easily. That said, the code and assemblies
can be reused across multiple instances/applications. You would have separate instances of the classes involved but you would be able to reuse the query logic. That's a common use case.
Can you be more specific about your use case and what you are trying to accomplish here? It's possible that there are alternative ways to do what you are trying to do.
DevBiker (aka J Sawyer)
Microsoft MVP - Sql Server (StreamInsight)
If I answered your question, please mark as answer.
If my post was helpful, please mark as helpful.
Maybe you are looking for
-
Persistant BSOD on Win 7 - HP Z210 Workstation
Hello folks, I have a HP Z210 Workstation that has been an absolute problem child ever since I got it. Ever since I've had it, after a few weeks or normal use, it hits a BCOD, and then slowly, from there, becomes unusable until I have to reinstall th
-
Custom Infotype for Org Management
Hi Experts, I Iam trying to create custom infotype to capture some infomation on an Org Management custom object and I am not sure if I can do this through PM01 because this is neither employee or applicant info but custom object info. Any idea on ho
-
Hi I have a dropbox account on my imac and that is where I save, edit and control everything. I also have a mac book air also with Adobe CS5 on. However on my mac book air, I log on to dropbox via the web and download files that I need. What is ha
-
Information about the disc drive
How much usage is the disc drive in the new MBP able to withstand? i.e. burning/ripping cds/dvds... Also at first the disk drive didn't make any noise, but now it makes a kind of fan noise, is this bad or normal? Thanks.
-
Unresponsive script routine crashes FF 3.6.8
In the past few days I've been getting these unresponsive script errors. When the message pops up it freezes/crashes FF. Any response to the script dialog box is not actionable. Before you tell me to this or that here is what I have done .. uninstall