473,792 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i'm having trouble in defining primary key... HELP ME guySSSS

10 New Member
i'd like to insert lots of data n its hard to determine which field would be the primary key, coz all of them almost similar.

So, i decided to use sequence for its PK by using trigger
here's the code :

Create or replace trigger bef_ins_primer
before insert on dpsj_primer
for each row
begin
insert into dpsj_primer values(:new.sto ,:new.rk,:new.a tas,:new.bawah, :new.dmtr,:new. pjng,:new.awal, :new.akhir,:new .kap,:new.isi,: new.ksb,:new.ks r,:new.cad,:new .repsb,:new.wsu cc,:new.tgl_ini t,prim.nextval) ;
end;


Prim is the sequence's name

when i try 2 insert them, here are the error msg

ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-06512: at "SYSTEM.BEF_INS _PRIMER", line 2
ORA-04088: error during execution of trigger 'SYSTEM.BEF_INS _PRIMER'
ORA-06512: at "SYSTEM.BEF_INS _PRIMER", line 2
ORA-04088: error during execution of trigger 'SYSTEM.BEF_INS _PRIMER'
ORA-06512: at "SYSTEM.BEF_INS _PRIMER", line 2
ORA-04088: error during execution of trigger 'SYSTEM.BEF_INS _PRIMER'
ORA-06512: at "SYSTEM.BEF_INS _PRIMER", line 2
ORA-04088: error during execution of trigger 'SYSTEM.BEF_INS _PRIMER'
ORA-06512: at "SYSTEM.BEF_INS _PRIMER", line 2
ORA-04088: error during execution of trigger 'SYSTEM.BEF_INS _PRIMER'
ORA-06512: at "SYSTEM.BEF_INS _PRIMER", line 2
ORA-04088: error during execution of trigger 'SYSTEM.BEF_INS _PRIMER'
ORA-06512: at "SYSTEM.BEF_INS _PRIMER", line 2
ORA-04088: error during execution of trigger 'SYSTEM.BEF_INS _PRIMER'
ORA-06512: at "SYSTEM.BEF_INS _PRIMER", line 2
ORA-04088: error during execution of trigger 'SYSTEM.BEF_INS _PRIMER'
ORA-06512: at "SYSTEM.BEF_INS _PRIMER",



Help me plizzz... thx before
Jul 22 '08 #1
3 1636
r035198x
13,262 MVP
How are you executing the insert statements? Are they inside a loop?
Jul 22 '08 #2
amitpatel66
2,367 Recognized Expert Top Contributor
In order to make use of a sequence, you will need to do something like this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Create or replace trigger bef_ins_primer
  3. before insert on dpsj_primer
  4. for each row
  5. begin
  6. SELECT prim.nextval INTO :new.column_name FROM DUAL;
  7. end;
  8.  
  9.  
Jul 22 '08 #3
Dave44
153 New Member
what is the nature of the inserts to the table? Is it 1 row at a time or batches of thousands? reason i ask is that there can be a notable time difference when using a trigger vs just inserting the sequence as part of the insert statement.

observe:
Expand|Select|Wrap|Line Numbers
  1. [138]dave@> drop table t;
  2.  
  3. Table dropped.
  4.  
  5. Elapsed: 00:00:00.84
  6. [138]dave@> create table t (
  7.   2  my_id  number primary key,
  8.   3  var    varchar2(4000)
  9.   4  );
  10.  
  11. Table created.
  12.  
  13. Elapsed: 00:00:00.28
  14. [138]dave@> create sequence t_sn;
  15.  
  16. Sequence created.
  17.  
  18. Elapsed: 00:00:00.01
  19. [138]dave@> create or replace trigger t_trg
  20.   2  before insert on t for each row
  21.   3  begin
  22.   4    :new.my_id := t_sn.nextval;
  23.   5  end;
  24.   6  /
  25.  
  26. Trigger created.
  27.  
  28. Elapsed: 00:00:00.04
  29. [138]dave@> insert into t (var) select level from dual connect by level <= 10000;
  30.  
  31. 10000 rows created.
  32.  
  33. Elapsed: 00:00:01.14
  34. [138]dave@> drop trigger t_trg;
  35.  
  36. Trigger dropped.
  37.  
  38. Elapsed: 00:00:00.04
  39. [138]dave@> insert into t select t_sn.nextval, level from dual connect by level <= 10000;
  40.  
  41. 10000 rows created.
  42.  
  43. Elapsed: 00:00:00.37
  44.  
It took nearly 3 times longer to use the trigger vs just doing it in the insert. triggers add overhead, it's another call for each row and it takes time. like i said, if you're inserting 1 row at a time, it probably doesnt matter, if you inserting large numbers at a time, it can add up.
Jul 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

14
2521
by: bolidev | last post by:
I'm new to SQL and can't figure out how to update my table (StoreItemStatus) that contains the current status for items in each store (STORE_KEY, ITEM_KEY, STATUS,...). I get updated status info in a table (I'll call it NewInfo) that has similar fields. NewInfo may contain multiple records for each Store/Item, but I will just use the latest status. I'm not sure how to update StoreItemStatus using each record of NewInfo. Any advice is...
2
1320
by: Nagib Abi Fadel | last post by:
Hi , i'm doing the planification of the courses in a university. I have definned the following tables: 1- Table DAY representing a day (day_id,year,month ...) 2- Table PERIODE representing an hour of a day (periode_id,starting,ending,periode_number) 3- Table TEACHER representing a teacher (teacher_id,name,phone,address ...) 4- Table ROOM representing a ROOM in the university (room_id,description,name ...) 5- Table COURSE representing a...
0
3230
by: lkrubner | last post by:
The idea I'm trying to get at is that I want the tag info for the tag "photography", and I want the date, and I want a count of any comments a tag may have. This following query gets back all the info I want, provided the tag has at least one comment. If It doesn't have any comments, it doesn't show up in the return. But if it has a count of zero, I just want it to come back with a count of zero, I don't want it to disappear from the...
13
2067
by: Jacek Dziedzic | last post by:
Hi! <OT, background> I am in a situation where I use two compilers from different vendors to compile my program. It seems that recently, due to a misconfiguration, library conflict or my ignorance, with one of the compilers I am having trouble related to libuwind.so, which, to my knowledge, deals with the intricacies of unwinding the stack upon an exception. Executables compiled with this compiler crash with a SEGV after throw(), never...
9
1427
by: Pyenos | last post by:
Approach 1: class Class1: class Class2: def __init__(self):self.variable="variable" class Class3: def method():print Class1().Class2().variable #problem Approach 1.1:
9
3784
by: cdriccio | last post by:
Hello, I'm trying to make a gif image out of a total of 5 (currently) images. One background image and 4 small icons. This image also includes text of a specific font. Here are my issues. First... the background image is in color and looks correct. The icons that I merge onto the background image are in black and white. I'm not sure why this is happening. This happens on both my development environment and on my server.
3
4836
by: Shestine | last post by:
I am trying to add a column to a current table, with data in it. I am only learning, and i have no idea how to change this to make it work. Here is the script I have right now it, but what it does is delete the whole table and recreates it, adding in the extra column. I don't want that. I want the data that is currently there to stay there and then add anew column. How do I reword this (If possible) to make it work? if exists (select * from...
8
2382
by: rbukkara | last post by:
Hi guys, I have some trouble with the following query. Please look into this and lemme know the solution ASAP. It certainly involves aggregations and the 'having clause' BROKER( ID integer primary key , NAME string)
1
1417
by: aviansh | last post by:
HI Experts, I have same table structures in two database and one master table which contains Table id, Table name,primary key, data type of primary key. i have to comapare Tables in both tha database and as per result i have to do insert,update or delete. for that i have written query : DECLARE @rowcount_mastertable FLOAT SET @rowcount_mastertable = (select count(*) from master_table)
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.