Home » SQL & PL/SQL » SQL & PL/SQL » Using an Index
Using an Index [message #275199] |
Thu, 18 October 2007 14:58  |
egray
Messages: 9 Registered: October 2007 Location: Kenner, LA
|
Junior Member |
|
|
Hi all,
I am trying to figure out how to get a unique ID number for a records I would like to Insert/Update on a table. I think I am missing a step in all the articles I have read, so I am turning here for help. My background is in MS SQL, and Oracle PL/SQL is new to me.
I have found the following index below and I need help figuring out how to gather the unique id and complete the insert/update statements.
CREATE UNIQUE INDEX "GN"."SHIPPING_IDX" ON "GN"."SHIPPING" ("PID", "SID", "ENTRYID")
PCTFREE 1 INITRANS 32 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS
STORAGE(INITIAL 655360 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "GREEN_INDEX" ;
SQL> INSERT INTO GN.SHIPPING (PID,SID,ENTRYID,SVALUE) VALUES (:hvPID,:hvSID,:hvENTRYID,:hvSVALUE)
SQL> UPDATE GN.SHIPPING SET ENTRYID=:hvENTRYID,SVALUE=:hvSVALUE WHERE PID=:hvPIDw AND SID=:hvSIDw AND ENTRYID=:hvENTRYIDw
Any help or direction is appreciated. Thanks!
|
|
|
Re: Using an Index [message #275202 is a reply to message #275199] |
Thu, 18 October 2007 15:16   |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
What exactly are you trying to do with the insert? If you are trying to update a specific row and there is a unique index on PID, SID, and ENTRYID then using the three columns in the where clause on the update will only update one row. There is one exception. If all three columns contain null, then you could have 50 rows inserted and an update of the form
where PID IS NULL AND SID IS NULL AND ENTRYID IS NULL would update all 50 rows.
[Updated on: Thu, 18 October 2007 15:19] Report message to a moderator
|
|
|
Re: Using an Index [message #275205 is a reply to message #275199] |
Thu, 18 October 2007 15:35   |
egray
Messages: 9 Registered: October 2007 Location: Kenner, LA
|
Junior Member |
|
|
On an insert, I have the PID, SID, and SVALUE, and only need to generate an ENTRYID value.
On an update, the ENTRYID and SVALUE will be updated, and I only need to generate a new ENTRYID value.
I see on the Create Table statement that PID, SID, and ENTRYID are all NUMBER(38,0) NOT NULL ENABLE.
I'm I looking in the right place in the database for the information we need to do an insert or update?
|
|
|
|
|
|
|
|
Re: Using an Index [message #275403 is a reply to message #275388] |
Fri, 19 October 2007 15:30   |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
Is it 50 or 50000? You give conflicting information.
Ay Caramba! The sequence IDGEN1$ is a sequence in SYS dealing with Transportable tablespace, therefore you should under no circumstances touch it. Who knows what harm you may have caused.
Have you searched for sequences that have a CACHE of 50? A session which does a single insert would cause this too.
[Updated on: Fri, 19 October 2007 15:32] Report message to a moderator
|
|
|
Re: Using an Index [message #275410 is a reply to message #275403] |
Fri, 19 October 2007 16:27  |
egray
Messages: 9 Registered: October 2007 Location: Kenner, LA
|
Junior Member |
|
|
Sorry for the conflicting information. It is 50. The last three digits of the ENTRYID number I posted belong to the the user's ID in the system. The third-party application is tacking that onto to the end of the number as if it were a string.
There is one sequence that has a cache of 50 (MVIEW$_ADVSEQ_GENERIC) and the sequence owner is SYSTEM.
Hopefully I did not cause any harm by running SYS.IDGEN1$.NEXTVAL and SYS.IDGEN1$.CURRVAL. Records are still being processed by the system fine for now. I will keep my fingers crossed and throw a penny in the good luck fountain on the way home.
|
|
|
Goto Forum:
Current Time: Sat May 03 21:42:21 CDT 2025
|