Column prefix and automatic generation of surrogate key
Hello,
I used Oracle Designer and could always generate columns with prefixes and got surragate keys as Primary key. Now I cannot find these properties in data modeler.
Thank you for your help
Siegwin
Hello Siegwin,
Abbreviation (Abkurzung) is on the General (Allgemein) tab in the Properties Dialog for a Table in the Relational Model.
There are 2 alternative ways to run the Transformation script:
1. Right_click on the Relational Model in the Browser, and select Apply Custom Transformation Scripts (Benutzerdefinierte Transformationsskripte anwenden) from the drop-down menu.
Use the right arrow to move "Table abbreviation to column" from the left column into the right column.
Select the Apply (Anwenden) button.
Alternatively
2. From the Tools (Extras) menu select Design Rules/Transformations (Entwurfsregeln/Transformationen).
Select the fourth entry ("Table abbreviation to column") and click the Apply (Anwenden) button.
Then click the Close (Schliessen) button.
Note that you can run Data Modeler in English if you wish.
First close Data Modeler and then edit the file datamodeler.conf (if you are using Data Modeler in 32 bit mode) or datamodeler64.conf (if you are using Data Modeler in 64 bit mode).
These files are in folder datamodeler\datamodeler\bin.
To run Data Modeler in English, you should add the following lines to the file:
AddVMOption -Duser.country=US
AddVMOption -Duser.language=en
Regards,
David
Similar Messages
-
Suppress auto sequence and trigger DDL for surrogate keys?
Is there a way to suppress trigger and sequence creation for surrogate keys when export to DDL file?
I know most of the time the automatic sequence and trigger creation is welcome and very handy.
However I'm migrating from an old Designer model and there only the needed sequences are created.
They have a different name and trigger logic is custom (and generated outside designer).
There is a lot of package code depending on this. So I prefer to create and use different sequences.
Is there a way to achieve this? Any tips are welcome.CreateHi,
Note that generating the DDL for Oracle 12c means that it will attempt to use your Oracle 12c Physical model. So if you normally use Oracle 10g or 11g, you will find that any details from your Oracle 10g or 11g Physical Model will not be included. So this approach may have other implications for you.
If you are not using Oracle 12c, there are some relevant properties on the Auto Increment tab of the Relational Model properties dialog for the Column which may help:
Sequence Name - allows you to specify the name of the Sequence (which can be the name of a Sequence defined in the relevant Physical Model).
Trigger Name - allows you to specify the name of a Trigger (which can be the name of a Trigger that is defined for the Table in the Physical Model).
Generate Trigger - unsetting this will stop the Trigger being generated.
David -
About Automatic generation of Primary key
I have created one Z table. Its composite primary keys are vkorg
and Sales Representive Number. I have to assign Sales Representive number
through system. How it should be done?
Message was edited by:
Nilesh VakilNilesh , You asked the Same question in ABAP General
Please Refer the link.
Re: About Automatic Generation of Primary key
Regards
Rusidar S
Message was edited by:
Rusidar Subramani -
Dear Forum,
I'm relatively new to JEE, and while I've so far enjoyed the convenience of EJB3 for most things, it seems that I have a corner case that can not be handled by the entity manager.
First, here's a quick mockup of my entities:
Gallery
|
-- [1] -------[1] ----> Author
|
-- [1] -------[M] ---> Photo
|
-- [1] ------ [1] -> PhotoImage
|
-- [1] ------ [1] -> IPTCData
|
-- [1] ------ [1] -> EXIFDataI also have a remote, stateless session bean that does nothing more than persist()/merge()/remove() and locate (through find() and a few custom queries) my Gallery and Photo instances.
Now, the abridged version of my problem is this: when I persist a Photo, it naturally gets its primary key generated (I used @Id and @GeneratedValue). However, for some reason none of the other dependent entities inherit Photo's primary key value. In my client, I create a new Gallery locally and then persist it. I then create new Photo, PhotoImage, IPTCData and EXIFData instances. I add the IPTCData and EXIFData instances to PhotoImage (there are PhotoImage methods for adding those); then I add the PhotoImage instance to Photo (again, Photo has a setter for adding a PhotoImage). Then, I persist the Photo.
--- Aside: ------------
I've set up my relationships using annotations like @OneToMany (Gallery references a Collection of Photos), and @OneToOne (Photo's primary key references PhotoImage's primary key; PhotoImage's primary key references the primary keys of IPTCData and EXIFData). I've also added @JoinColumn annotations where necessary.
Finally, I get the Gallery instance's Photo collection (public Collection<Photo> getPhotos()), I add the Photo to the collection, and I add the Photo collection BACK to the Gallery (public void setPhotos(Collection<Photo>)).
At this point, the Gallery should have all of my entities contained inside of itself. However, when I persist the Gallery at this point, all of the entities show up in the database, but none of the primary keys get inherited. Photo's primary key gets generated automatically, of course, but the rest have zero (0) as their PK values. I had wanted, for example, IPTCData to get the value of Photo.id.
I had assumed that the entity manager would persist everything for me provided that I told it, through my annotations, about which entities relate to which. Does persistence only work in the direction of retrieval? That is, does the entity manager only do its thing when fetching (versus setting) data when there is more than 1 object in the graph? I can't believe that it can't, otherwise we'd all be ditching it and going back to straight SQL to do our work.
Thus, I HAVE to be doing something wrong, or else omitting to do something right.
I've made other incarnations of the above setup, and none of them have worked perfectly. I've even set up foreign key constraints in the database, but I had my share of unresolvable problems there, too.
So I guess my big question with all of this is: when you have a deeply nested graph of objects, can the entity manager figure everything out and persist all of the objects correctly and with the right values? If not, boo. If so, how does one accomplish this?
I know that I could persist each and every entity separately in my client code, but I wanted to have a natural-looking way of piecing all of my entities together. More specifically, I could persist IPTCData explicitly; however, I want to be able to add everything to a Photo and only persist the Photo itself, with the idea that all of the objects and sub-objects would be persisted automagically.
Is this possible? Or have I bought into a pipe dream with the guarantee of the proverbial magic bullet?
Thanks to everyone in advance for his/her input.
Regards,
MichaelDaniel,
Late last night I found the solution to my problem. And you're right, it had everything to do with which side is wired to which. I got confused about which side to consider the "owning" side, since one can look at it from the perspective of the database or the application.
Interestingly, the first 2 lines of your example code match my client code almost verbatim: First, I create a new Gallery (or else I get an existing one). I then create a new Photo and then add it to the Gallery's collection using add(). I then persist the Gallery. My session bean internally calls EntityManager.merge(gallery). How it differs from your example, though, is in the fact that, on an application level, a Photo has no knowledge whatsoever of a Gallery. Which is to say that my Photo class does not have a 'getGallery()' method. Somehow, Hibernate is able to figure it all out and still update Photo's 'parentIdRef' column in the database. My logs show that Hibernate issues a SQL UPDATE on the Photo after both a Gallery and a Photo have been created. It sets the Photo's 'parentIdRef' column to the primary key value of the owning Gallery.
Getting back to the matter, my problem was not with being able to map a Photo to a Gallery; rather, I was unable to add a PhotoImage to a Photo and have the relationship get correctly mapped in the database. The relationship between a Photo and a Gallery is many-to-one: there can be many Photo objects inside of a Gallery. In the database, a Photo row contains a 'parentIdRef' column whose value is that of a Gallery's primary key. I used @OneToMany on the Gallery, since a Gallery is, from an application perspective, the "owning" side, even though it's only the Photo that knows who it's referring to since only IT contains the 'parentIdRef' column in the database.
I tried setting up the relationship between a PhotoImage and a Photo in the same manner, with the PhotoImage having a 'parentIdRef' column and referring to a Photo's primary key. I had annotated the Photo's getPhotoImage() method with @OneToOne, along with an appropriate @JoinColumn.
It was THIS part that I had backwards. With a @OneToMany relationship, the child refers back to the parent --- it can be no other way. However, with a @OneToOne relationship, the owner refers to the child.
So, to make a long story short, all I had to do was create extra database columns for Photo. Those columns refer to the primary keys of PhotoImage, EXIFData and IPTCData. Concretely, for example, Photo.photoImageIdRef references PhotoImage.id. And so on and so forth.
The only negative side-effect of this is that my database-level foreign key constraints are now broken, since Hibernate wants to persist PhotoImage, EXIFData and IPTCData before it persists Photo.
I have to investigate more deeply the 'cascade=...' option of the @OneToOne annotation in order to find out it relates, if at all, to a database-level cascade.
Anyway, thanks for the reply. It seems that you had a very good idea about what my problem was. I would have posted the fact that I had resolved the problem last night, except that it was too late and I was heading to bed. If you still want the Duke points, let me know. I don't currently know the rules about if, when and to whom I should issue points in cases like these when I've already solved the problem.
Regards,
Michael -
9i: howto avoid automatic creation of surrogate keys
hi,
i'm modeling multiple intersection entities in the ERD by adding the relationships to UID-elements. Whenever i do this, a surrogate key is automatically created, even when my settings in the DDT are correct. How can i avoid this?
thanks, treviHi,
Note that generating the DDL for Oracle 12c means that it will attempt to use your Oracle 12c Physical model. So if you normally use Oracle 10g or 11g, you will find that any details from your Oracle 10g or 11g Physical Model will not be included. So this approach may have other implications for you.
If you are not using Oracle 12c, there are some relevant properties on the Auto Increment tab of the Relational Model properties dialog for the Column which may help:
Sequence Name - allows you to specify the name of the Sequence (which can be the name of a Sequence defined in the relevant Physical Model).
Trigger Name - allows you to specify the name of a Trigger (which can be the name of a Trigger that is defined for the Table in the Physical Model).
Generate Trigger - unsetting this will stop the Trigger being generated.
David -
Repro steps:
Go to Tools -> Domain Administration. Add new domain named MyIdentifier with logical type UNIQUEIDENTIFIER. Apply and save changes.
Go to Tools -> Preferences, then Data Modeler -> Model -> Relational. Get to Surrogate Column Data Type group box and set Domain = MyIdentifier. Apply changes.
Create new Entity and enable option "Create Surrogate Key". Apply changes.
Engineer to Relational Model with default settings.
Expected result:
Entity_1_ID column's data type is UNIQUEIDENTIFIER
Actual result:
Entity_1_ID column's data type is CHARI've forgot to mention, that my default RDBMS Site is set to SQL Server 2008. In Types Administration UNIQUEIDENTIFIER is mapped to CHAR for Oracle, but it mapped to UNIQUEIDENTIFIER for SQL Server 2008.
-
Surrogate Key and Map for Cube
Hi
I am new to Data Warehousing and am trying to use OWB 11g.
I am trying to create dimensions with multiple levels. When I create more than one level it need to have surrogate as well business key for each dimension level. But I can create only one surrogate in the dimension, there is no option to create multiple surrogate keys in the same dimension. so what am I missing?
My second question is regarding cube. Do I need to create a Mapping for a cube? if yes, should I move the data to the cube from the dimensions? and where will the measures come from? do i need to load the measures or they will be calculated automatically?
please reply...
regards
Arifhi
Got it, Yes that was the reason,
The table was not properly deployed after the dimension was modified.
Anyway, the describe of the table is as follows
describe arif.QUESTION_DIM
Name Null Type
DIMENSION_KEY NOT NULL NUMBER
IGV_ID NUMBER
PER_ID NUMBER
DIM_ID NUMBER
IGO_ID NUMBER
INQ_ID NUMBER
ID NUMBER
DIM_ORDEM NUMBER
DIM_AMBITO VARCHAR2(3)
DIM_NOME VARCHAR2(150)
10 rows selected
Now, I am having another problem,
when, I deploy the Map to load the data from three different tables, it gives the following problem
Name Action Status Log
QUESTION_MAP Create Warning ORA-06550: line 297, column 25:
PLS-00302: component 'ID' must be declared
QUESTION_MAP Create Warning ORA-06550: line 1153, column 11:
PL/SQL: SQL Statement ignored
QUESTION_MAP Create Warning ORA-06550: line 1155, column 15:
PL/SQL: ORA-00904: "QUESTION_DIM"."ID": invalid identifier
QUESTION_MAP Create Warning ORA-06550: line 1155, column 31:
PLS-00302: component 'ID' must be declared
QUESTION_MAP Create Warning ORA-06550: line 233, column 1:
PL/SQL: SQL Statement ignored
QUESTION_MAP Create Warning ORA-06550: line 2539, column 11:
PL/SQL: SQL Statement ignored
QUESTION_MAP Create Warning ORA-06550: line 2541, column 15:
PL/SQL: ORA-00904: "QUESTION_DIM"."ID": invalid identifier
QUESTION_MAP Create Warning ORA-06550: line 2541, column 31:
PLS-00302: component 'ID' must be declared
QUESTION_MAP Create Warning ORA-06550: line 297, column 9:
PL/SQL: ORA-00904: "QUESTION_DIM"."ID": invalid identifier
Edited by: user643560 on Oct 22, 2008 9:38 AM -
About Surrogate Key and Dimension Key on OWB 10.2
Hi, everyone.
I am using OWB 10.2 and I have a question about Surrogate key and Dimension Key.
I indicated the foreign key as VARCHAR2 type in Fact Table and Dimension Key as VARCHAR2 type is operated as Primary key in Dimension Table. I made Single Level in Dimension Table.
I know that Dimension Key stores the surrogate ID for dimension and is the primary key of the table. Also, Surrogate ID should be only NUMBER type.
So, in this case, Surrogate ID is NUMBER type
Dimension key should be NUMBER type to store the surrogate ID.
But, Dimension key also should operate the primary to relate Foreign key as VARCHAR2 type.
How I can solve this confusing condition?
Please let me know that.
JWSHi JWS,
From a SQL point of view it should not be a problem to join a NUMBER field to a VARCHAR2 field because during execution there will be an implicite cast for the NUMBER value to a VARCHAR2 value. See the example below.
SELECT * FROM DUAL
WHERE 1 = '1'From an OWB point of view it is not possible to have a Dimension with an NUMBER value Key that has a relation to a VARCHAR2 value Foreign key in a Fact table. This is caused due to the creation of a Fact table in OWB in which the Foreign keys in it are build from de Dimension tables that refer to them.
You will loose the reference to the Dimension when changing the type of the Foreign Key.
To resolve this issue I would advise you to use a Sequence that generates your Surrogate Key (NUMBER type) for the Dimension table and store it in the Primary Key Column (VARCHAR2 type).
When validating the mapping you will get a warning, but when executing this should give no problems.
Regards,
Ilona -
Apex and Natural Vs Surrogate keys
Hi
We've been using Apex for a few months now and there's a debate raging in our department over whether we should design our database tables using natural or surrogate (based on Oracle sequences / triggers) keys. Our experience as Apex developers shows that Apex itself looks to lean towards surrogate keys, a few examples are below:
- When creating forms on reports / tables Apex only allows 2 primary key columns without adding 'extras' in the background (see a previous post of mine).
- If we have a form on a table and our natural primary keys can be updated, the Apex-created DML statements break, as they look to do the update using the changed key values in the WHERE clause rather than the old ones. The only way around this seems to be to delete the inbuilt DML statements created by Apex and code your own, which is extra work.
- The Apex sample applications themselves seem to use sequences / surrogate keys.
What are people's opinions on this? In particular is there any guidance from the Apex development team on which is best to use with Apex?
Regards
AntillesHi Andrew,
As with abots_d, I only use "natural" keys for lookups.
>
1. the department names were here for 20 years and they never changed
>
But, can you guarantee that they never will? My firm has changed departmental names so many times, it's getting ridiculous! But other things also change over time - consider what happens if a person gets married and changes their name and you've used their previous names as the keys (and consider how much data in other tables may use those keys).
>
2. Server names are uniquely generated by special formula in excel to preciously avoid the duplication problem and guarantee the uniqueness within our glamorous bank.
>
SQL could probably recreate that formula and Unique Key constraints would handle the rest
>
3. no, we are not going to extend this app to cover any other banks
>
Given what's happening with the banking industry right now, who can say ;)
>
4. PK that means smth ( aka "server name" ) has a meaning, whereas meaningless - has no (business) value
>
Why does a bit of data have to have explicit "business value"? I would suggest that a surrogate key is a pointer to a record and allows you to easily create relationships. Once created, the key would never be changed regardless of what happens to the data on its record. Thus, the relationship is maintained. Using personnel (which our firm renamed as "Human Resources" a while back) as an example, it's likely that every employee would have an employee number. Does this number actually mean anything in itself, does it have "business value"? Most likely, it's just a convenient way to identify a person and relate records to them.
I would suggest that any non-numeric/date keys are relatively slow. As strings, the only way to check for their sort order would be to (A) convert to upper or lower case and (B) perform a string comparison left-to-right across the entire string. There's also the possibility of certain characters appearing in the strings that can cause issues - for example, quotes, apostrophes, colons, commas, question marks and percentage signs.
Also, consider the length of a VARCHAR2 that you would have to use - how big would it need to be to cover all possibilities? You may say 20 now but tomorrow you get data with 21 characters in it - do you want to update the table plus all related tables for that?
There are further issues with parent, child, grand-child etc relationships where the keys would have to be passed down in full through the relationships. Depending on how many levels you may have, a fair number of the fields on the bottom-most table would be there just for the keys.
It has been a standard industry practice for many years now to "normalise databases" to avoid lots of issues with keys and "repeating data". Apart from very simple lookup tables, I have stuck with those guidelines for years now without any problems at all.
Andy -
How we generate Surrogate Keys without using identify column
Hi All,
How we generate Surrogate Keys without using identify column.
Regards,
ManishThere are various options
1.IDENTITY columns - simplest to implement
2. Using NEWID(), NEWSEQUENTIALID() functions (if you want to use GUID values as surrogate keys)
3. SEQUENCE object (if SQL 2012 and above)
4. Using custom functions to generate keys yourself
This is an good article which compares use of GUIDs against integers as surrogate keys
http://blog.jonathanoliver.com/integers-vs-guids-and-natural-vs-surrogate-keys/
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
What is the key column name and value column name in JDBC Adapter parameter
Hi
Can any one please tell me what is the Key Column Name and Key Column Value in JDBC adatper parameters. If i dont mention those parameters i am getting the following error
<b> Value missing for mandatory configuration attribute tableEOColumnNameId</b>
Please help me
Best Regards
Ravi Shankar BHi
I am doing DataBase Lookup in XI
First i have created a Table in Database( CheckUser) which has two fields UserName and PhoneNumber and then i have created
I have created one Communication Channel For Reciever Adapter .
I have given the parameters like this
JDBC Driver : com.microsoft.jdbc.sqlserver.SQLServerDriver
Connection : jdbc:microsoft:sqlserver://10.7.1.43:1433;DatabaseName=Ravi;
UserName.... sa
password.... sa
persistence : Database
Database Table Name : CheckUser
Key column name and Value column name i left blank and activated
and then
I have created
Data Types : Source ...... UserName
Destination.... PhoneNumber
Message Types
Message Interfaces
In Message Mapping
I have created one User Defined function DBProcessing_SpecialAPI().This method will get the data from the database....
In this function i have written the following code
//write your code here
String query = " ";
Channel channel = null;
DataBaseAccessor accessor = null;
DataBaseResult resultSet = null;
query = "select Password from CheckUser where UserName = ' " +UserName[0]+ " ' ";
try {
channel = LookupService.getChannel("Ravi","CC_JDBC");
accessor = LookupService.getDataBaseAccessor(channel);
resultSet = accessor.execute(query);
for(Iterator rows = resultSet.getRows();rows.hasNext();){
Map rowMap = (Map)rows.next();
result.addValue((String)rowMap.get("Password"));
catch(Exception e){
result.addValue(e.getMessage());
finally{
try{
if(accessor != null)
accessor.close();
}catch(Exception e){
result.addValue(e.getMessage());
And the i have mapped like this
UserName -
> DBProcessing_SpecialAPI----
>PhoneNumber
when i am testing this mapping i am getting the following error
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Dest_JDBC_MT xmlns:ns0="http://filetofilescenario.com/ilg"><phoneNumber>Plain exception:Problem when calling an adapter by using communication channel CC_JDBC (Party: , Service: Ravi, Object ID: c360bc139a403293afbc49d5c46e4478) Check whether the communication channel exists in the Integration Directory; also check the cache notifications for the instance Integration Server (central Adapter-Engine) Channel object with Id Channel:c360bc139a403293afbc49d5c46e4478 not available in CPA Cache.
com.sap.aii.mapping.lookup.LookupException: Problem when calling an adapter by using communication channel CC_JDBC (Party: , Service: Ravi, Object ID: c360bc139a403293afbc49d5c46e4478) Check whether the communication channel exists in the Integration Directory; also check the cache notifications for the instance Integration Server (central Adapter-Engine) Channel object with Id Channel:c360bc139a403293afbc49d5c46e4478 not available in CPA Cache.
at com.sap.aii.ibrun.server.lookup.AdapterProxyLocal.<init>(AdapterProxyLocal.java:61)
at com.sap.aii.ibrun.server.lookup.SystemAccessorInternal.getProxy(SystemAccessorInternal.java:98)
at com.sap.aii.ibrun.server.lookup.SystemAccessorInternal.<init>(SystemAccessorInternal.java:38)
at com.sap.aii.ibrun.server.lookup.SystemAccessorHmiServer.getConnection(SystemAccessorHmiServer.java:270)
at com.sap.aii.ibrun.server.lookup.SystemAccessorHmiServer.process(SystemAccessorHmiServer.java:70)
at com.sap.aii.utilxi.hmis.server.HmisServiceImpl.invokeMethod(HmisServiceImpl.java:169)
at com.sap.aii.utilxi.hmis.server.HmisServer.process(HmisServer.java:178)
at com.sap.aii.utilxi.hmis.web.HmisServletImpl.processRequestByHmiServer(HmisServletImpl.java:296)
at com.sap.aii.utilxi.hmis.web.HmisServletImpl.processRequestByHmiServer(HmisServletImpl.java:211)
at com.sap.aii.utilxi.hmis.web.workers.HmisInternalClient.doWork(HmisInternalClient.java:70)
at com.sap.aii.utilxi.hmis.web.HmisServletImpl.doWork(HmisServletImpl.java:496)
at com.sap.aii.utilxi.hmis.web.HmisServletImpl.doPost(HmisServletImpl.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
</phoneNumber></ns0:Dest_JDBC_MT>
In RWB i have checked the status of JDBC driver its showing the following error
<b>Value missing for mandatory configuration attribute tableEOColumnNameId</b>
Best Regards
Ravi Shankar B
Message was edited by:
RaviShankar B -
What are the surrogate key and row_number( )
what are the surrogate key and row_number( ) function, and why do not we always make the row_number a primary key in the table.
Mohannad,
we just try to safe your efforts and to prevent common
mistakes you can make.
Look here.
Your requirement is to avoid gaps in sequence.
OK. But it means you HAVE to lock your sequence
exclusively until you commit transaction.
Also, it means you have to rollback sequence
number to original value if you rollback you
entire transaction.
SQL> create table my_tab (id number);
 
Table created.
 
SQL> create table numer_tab (id number);
 
Table created.
 
SQL> insert into numer_tab values(0);
 
1 row created.
 
SQL> create or replace trigger
2 tr_no_gap
3 before insert on my_tab
4 for each row
5 begin
6 /* Let's lock sequence in exclusive mode */
7 update numer_tab set id = id + 1
8 returning id into :new.id;
9 end;
10 /
 
Trigger created.Now I havn't to worry about gaps:
Fisrt session:
SQL> insert into my_tab values(null);
 
1 row created.because my next session is waiting:
SQL> insert into my_tab values(null);
 I do commit in first and second session -everything is OK:
SQL> commit;
 
Commit complete.
 
SQL> select * from my_tab;
 
ID
2
1Now I do the same but do rollback in 1th:
SQL> insert into my_tab values(null);
 
1 row created.
 
SQL> rollback;
 
Rollback complete.and commit in 2th:
SQL> insert into my_tab values(null);
 
1 row created.
 
SQL> commit;
 
Commit complete.No gaps:
SQL> select * from my_tab;
 
ID
2
3
1Now I will not lock sequence resource due a transaction:
SQL> create or replace trigger
2 tr_no_gap
3 before insert on my_tab
4 for each row
5 declare
6 pragma autonomous_transaction;
7 begin
8 /* Let's lock sequence in exclusive mode */
9 update numer_tab set id = id + 1
10 returning id into :new.id;
11 commit;
12 end;
13 /
 
Trigger created.And I repeate my last operation.
Both inserts execute immediately
1th
SQL> insert into my_tab values(null);
 
1 row created.2th
SQL> insert into my_tab values(null);
 
1 row created.Now I rollback the first and commit the second.
And what I see is the gap:
SQL> select * from my_tab;
 
ID
2
3
5
1We are just trying to explain what you will have to
pay the serious price of performance in the
absence of gaps and you will have the lack
of Oracle multithreading advantage in this case.
I doubt your customers will happy with that.
Rgds. -
I need to write a MDX query to show the latest product text again historical facts or a chosen product text in time. I can write this query in TSQL, but new to MDX.
The way I do it in TSQL is joining two queries together on the Natural Key as opposed to the surrogate key.
Can this be done in MDX. I know I could write two separate MDX queries, one which get the product text I wan and the other to get the measure with the actual product text and Natural Key, and use a lookup function in ssrs to show the two result sets I the
same tablix by looking up the Natural Keys. But this should be able to be done in one query shouldn't it.
In the dsv the fact knows to join to the dimension using the surrogate key.
Thanks JHi Jamster,
According to your description, you want to write a query to show the latest product text, right?
In MDX, we can use LastNonEmpty function to return the lastest member winth a dimension. LastNonEmpty is an aggregation function available in the Enterprise version of SQL Server. However, you can create your own with a little bit of recursive MDX. Here
is a sample query for you reference.
With Member Measures.LastHits as
iif(isempty(Measures.Hits),
([Date].[Year Month Day].prevmember,
Measures.LastHits
),Measures.Hits)
Reference
http://cwebbbi.wordpress.com/2011/03/24/last-ever-non-empty-a-new-fast-mdx-approach/
http://richardlees.blogspot.com/2010/07/getting-last-non-empty-value.html
If this is not what you want, please provide us the detail structure of your cube and the expected result, so that we can make further analysis and give you the exactly MDX query.
Regards,
Charlie Liao
TechNet Community Support -
Day dimension and surrogate keys
Hello,
I'm trying to create a 'day' dimension using OWB. I was thinking about a set of levels like this:
- 'date_id'
- 'special_value' (such as unknown)
- 'calendar_date'
- 'month_day'
- 'month'
- 'year'
How can I implement something similar with OWB? I have to create one level for each dimension column? And how can I determine the value of date_id in the mapping?
Thanks in advance for the help
CosmaHi Cosma,
There's an example for this in the Oracle-by-Example session for OWB: http://www.oracle.com/technology/obe/obe9ir2/obe-dwh/owb/owb.htm
Around halfway through you'll find it.
Good luck, Patrick -
How to Maintain Surrogate Key Mapping (cross-reference) for Dimension Tables
Hi,
What would be the best approach on ODI to implement the Surrogate Key Mapping Table on the STG layer according to Kimball's technique:
"Surrogate key mapping tables are designed to map natural keys from the disparate source systems to their master data warehouse surrogate key. Mapping tables are an efficient way to maintain surrogate keys in your data warehouse. These compact tables are designed for high-speed processing. Mapping tables contain only the most current value of a surrogate key— used to populate a dimension—and the natural key from the source system. Since the same dimension can have many sources, a mapping table contains a natural key column for each of its sources.
Mapping tables can be equally effective if they are stored in a database or on the file system. The advantage of using a database for mapping tables is that you can utilize the database sequence generator to create new surrogate keys. And also, when indexed properly, mapping tables in a database are very efficient during key value lookups."
We have a requirement to implement cross-reference mapping tables with Natural and Surrogate Keys for each dimension table. These mappings tables will be populated automatically (only inserts) during the E-LT execution, right after inserting into the dimension table.
Someone have any idea on how to implement this on ODI?
Thanks,
DaniloHi,
first of all please avoid bolding something. After this according Kimball (if i remember well) is a 1:1 mapping, so no-surrogate key.
After that personally you could use Lookup Table
http://www.odigurus.com/2012/02/lookup-transformation-using-odi.html
or make a simple outer join filtering by your "Active_Flag" column (remember that this filter need to be inside your outer join).
Let us know
Francesco
Maybe you are looking for
-
Error When Transporting the DTP's
HI All, I was facing the problem with Transporting the DTP's to Quality. Transport log error : Program Terminated (job : RDDEXEC,no.: 09463801). (Program RDDEXECL'Which was started in the background,was terminated abnormally.) W
-
Sql server 2005 log file shrinking issue.
hi, one of my production server database log file size is increasing continuously,we can take log backup but no use, we can change the database recovery model from full to simple we shrink the log file, log file shrink successfully but space is not
-
Scan of multiple serial numbers in outbound delivery
Hi gurus, I need to record several serial numbers in an outbound delivery (VL02N) at the picking time into "Extras" / "Serial Numbers". At that time, a pop up appears to record SNs. To achieve this, I'm using a scanner for better efficiency. My probl
-
How can I get BC4J to handle my look ups without including the key value in the form? I'd like to be able to just show the value, without the key value, but, of course, have the key value be inserted into the main table. Anyone doing this? Joe
-
FCP HD 4.5 quits when clicking Log and Capture window
I am running FCP 4.5 with a G4 dual 1.42 Ghz Tiger and everytime I click Log and capture FCP quits...I have uninstalled and reinstalled from my original disks and still no luck...have used FCP rescue...no luck..... Really not having fun tonight...if