Creating a better update table statement
Hello,
I have the following update table statement that I would like to make more effecient. This thing is taking forever. A little background. The source table/views are not indexed and the larger of the two only has 150k records. Any ideas on making more effecient would be appreciate.
Thanks.
Ryan
Script:
DECLARE
V_EID_CIV_ID SBI_EID_W_VALID_ANUM_V.SUBJECT_KEY%TYPE;
V_EID_DOE DATE;
V_EID_POE SBI_EID_W_VALID_ANUM_V.POINT_OF_ENTRY%TYPE;
V_EID_APPR_DATE DATE;
V_CASE_CIV_ID SBI_DACS_CASE_RECORDS.CASE_EID_CIV_ID%TYPE;
V_CASE_DOE DATE;
V_CASE_POE SBI_DACS_CASE_RECORDS.CASE_CODE_ENTRY_PLACE%TYPE;
V_CASE_APPR_DATE DATE;
V_CASE_DEPART_DATE DATE;
V_SBI_UPDATE_STEP SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP%TYPE;
V_SBI_CIV_ID SBI_DACS_CASE_RECORDS.SBI_CIV_ID%TYPE;
CURSOR VALID_CIV_ID_FROM_EID IS
SELECT EID.SUBJECT_KEY,
TO_DATE(EID.PROCESS_ENTRY_DATE),
EID.POINT_OF_ENTRY,
TO_DATE(EID.APPREHENSION_DATE),
DACS.CASE_EID_CIV_ID,
TO_DATE(DACS.CASE_DATE_OF_ENTRY,'YYYYMMDD'),
DACS.CASE_CODE_ENTRY_PLACE,
TO_DATE(DACS.CASE_DATE_APPR,'YYYYMMDD'),
TO_DATE(DACS.CASE_DATE_DEPARTED,'YYYYMMDD'),
DACS.SBI_UPDATE_STEP,
DACS.SBI_CIV_ID
FROM SBI_EID_W_VALID_ANUM_V EID,
SBI_DACS_CASE_RECORDS DACS
WHERE DACS.CASE_NBR_A = EID.ALIEN_FILE_NUMBER;
BEGIN
OPEN VALID_CIV_ID_FROM_EID;
SAVEPOINT A;
LOOP
FETCH VALID_CIV_ID_FROM_EID INTO V_EID_CIV_ID, V_EID_DOE, V_EID_POE,V_EID_APPR_DATE,V_CASE_CIV_ID, V_CASE_DOE,V_CASE_POE,V_CASE_APPR_DATE,V_CASE_DEPART_DATE,V_SBI_UPDATE_STEP,V_SBI_CIV_ID;
DBMS_OUTPUT.PUT_LINE('BEFORE');
EXIT WHEN VALID_CIV_ID_FROM_EID%FOUND;
DBMS_OUTPUT.PUT_LINE('AFTER');
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_CASE_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 1
WHERE V_CASE_CIV_ID IS NOT NULL
AND V_CASE_CIV_ID <> 0;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 2
WHERE V_SBI_CIV_ID IS NULL AND V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE
AND V_EID_APPR_DATE = V_CASE_DEPART_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 3
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 4
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4 ;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 5
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE <> V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 6
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 7
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 8
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 9
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 10
WHERE V_SBI_UPDATE_STEP = 0
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
END LOOP;
CLOSE VALID_CIV_ID_FROM_EID;
COMMIT;
END;
-----Thats it. Thanks for your help.
Ryan
Please use [ code] or [ pre] tags to format code before posing:
DECLARE
V_EID_CIV_ID SBI_EID_W_VALID_ANUM_V.SUBJECT_KEY%TYPE;
V_EID_DOE DATE;
V_EID_POE SBI_EID_W_VALID_ANUM_V.POINT_OF_ENTRY%TYPE;
V_EID_APPR_DATE DATE;
V_CASE_CIV_ID SBI_DACS_CASE_RECORDS.CASE_EID_CIV_ID%TYPE;
V_CASE_DOE DATE;
V_CASE_POE SBI_DACS_CASE_RECORDS.CASE_CODE_ENTRY_PLACE%TYPE;
V_CASE_APPR_DATE DATE;
V_CASE_DEPART_DATE DATE;
V_SBI_UPDATE_STEP SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP%TYPE;
V_SBI_CIV_ID SBI_DACS_CASE_RECORDS.SBI_CIV_ID%TYPE;
CURSOR VALID_CIV_ID_FROM_EID IS
SELECT EID.SUBJECT_KEY,
TO_DATE(EID.PROCESS_ENTRY_DATE),
EID.POINT_OF_ENTRY,
TO_DATE(EID.APPREHENSION_DATE),
DACS.CASE_EID_CIV_ID,
TO_DATE(DACS.CASE_DATE_OF_ENTRY,'YYYYMMDD'),
DACS.CASE_CODE_ENTRY_PLACE,
TO_DATE(DACS.CASE_DATE_APPR,'YYYYMMDD'),
TO_DATE(DACS.CASE_DATE_DEPARTED,'YYYYMMDD'),
DACS.SBI_UPDATE_STEP,
DACS.SBI_CIV_ID
FROM SBI_EID_W_VALID_ANUM_V EID,
SBI_DACS_CASE_RECORDS DACS
WHERE DACS.CASE_NBR_A = EID.ALIEN_FILE_NUMBER;
BEGIN
OPEN VALID_CIV_ID_FROM_EID;
SAVEPOINT A;
LOOP
FETCH VALID_CIV_ID_FROM_EID INTO V_EID_CIV_ID, V_EID_DOE,
V_EID_POE,V_EID_APPR_DATE,V_CASE_CIV_ID, V_CASE_DOE,
V_CASE_POE,V_CASE_APPR_DATE,V_CASE_DEPART_DATE,V_SBI_UPDATE_STEP,V_SBI_CIV_ID;
DBMS_OUTPUT.PUT_LINE('BEFORE');
EXIT WHEN VALID_CIV_ID_FROM_EID%FOUND;
DBMS_OUTPUT.PUT_LINE('AFTER');
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_CASE_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 1
WHERE V_CASE_CIV_ID IS NOT NULL
AND V_CASE_CIV_ID <> 0;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 2
WHERE V_SBI_CIV_ID IS NULL AND V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE
AND V_EID_APPR_DATE = V_CASE_DEPART_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 3
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 4
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4 ;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 5
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE <> V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 6
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 7
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 8
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 9
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 10
WHERE V_SBI_UPDATE_STEP = 0
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
END LOOP;
CLOSE VALID_CIV_ID_FROM_EID;
COMMIT;
END;Peter D.
Similar Messages
-
Update Table statement in pre-commit trigger
Hi,
I would need to update one table before commit in the form and hence I need to write an update table statement in pre-commit trigger. Can anyone help me with the sample code or how sould i be able to write a Update table statement from form-level trigger. Normal update statement is throwing me errors.
Thanks in advI wouldn't recommend the PRE-COMMIT trigger unless it is your requirement to execute the UPDATE statement every time the form commits, whether it is updating or inserting or deleting.
Other wise you can use the PRE-UPDATE, PRE-DELETE and PRE-INSERT triggers; for this case you create a procedure under Program Units node in the Form's navigator that includes your "UPDATE" SQL statement and you call this procedure from the triggers you need to execute it from.
Example:
PROCEDURE UPDATE_MYTABLE IS
BEGIN
UPDATE MYTABLE SET MY_COLUMN1 = MY_VALUE1,
MY_COLUMN2 = MY_VALUE2,
MY_COLUMN3 = MY_VALUE3
WHERE ... condition;
END;
PRE-UPDATE trigger code:
BEGIN
UPDATE_MYTABLE;
END;Try it and let us know if this is your requirement.
Tony
Edited by: Tony Garabedian on Sep 5, 2008 10:29 AM -
LSMW create positions without updating table T528B?
I created many positions by LSMW,
but, in PA40, I can't assign a person to any one of these LSMW-created positions, system says "position xxxxxxxx is not available in T528B",
I've set integration between PA & OM, if I manually created position in PPOME or PP03, the manually created position could be assigned in PA40
So, how could it happen? SAP's bug or our system's bug?
I have to run report RHINTE10 to update T528B.Hi
Please check if value of p0001-otype is missed in IT0001.
Regarding such case, you need to do integration between PA and PD.
For example:
1) Turned on integration (PLOGI ORGA "X") (same result with integration off in step 2-4)
2) Conversion of organisational structure (O, O-O, O-K) via IDoc
3) Conversion of PA-data via IDoc; one infotype at the time in the following order: IT0, IT1, IT2, IT3, IT302. No position entered in IT1
4) Conversion of position and relations to org units and cost centers and jobs via IDoc
5) RHINTE10 report to update new org units and positions (and jobs) I have also tried this step after step 6 (makes no difference)
6) Turned integration off (PLOGI ORGA " ")
7)Conversion of relation from the position to the person (A008 rel.)
8) Turned integration on again (PLOGI ORGA "X")
9) Run RHINTE30 for the converted persons.
The above is just an example for your reference. For more detail, you need refer to the documentation for integration
Regards
Jun -
Update table using merge or Update statement
Hi All,
We have oracle 10G R2 On windows...
We have tables BROK_DEALER_MAP and DTRMIS_REPORT.
create table BROK_DEALER_MAP
SL_NO NUMBER,
BROK_DLR_CODE VARCHAR2(30),
EMP_TAG VARCHAR2(30),
REMARKS VARCHAR2(60),
CONS_CODE VARCHAR2(30),
BROK_DLR_NAME VARCHAR2(50),
BROKER_TYPE VARCHAR2(30),
BROK_DLR_0 VARCHAR2(30),
CATG_DESC VARCHAR2(60),
Category VARCHAR2(30));
desc DTRMIS_REPORT
SL_NO
POSTED_DATE
ZONE
AMC_REGION
CITY
BROK_DLR_CODE
BROK_DLR_NAME
SUB_BROKER
B_TYPE
FOLIO_NO
INVESTOR_NAME
TAX_NO
INV_TAG
SCHEME_CODE
SCHEME_NAME
SCH_CLASS
TRXN_MODE
CHN_TAG
FP_COUNT
FP_AMOUNT
AP_COUNT
AP_AMOUNT
PUR_COUNT
PUR_AMOUNT
SIP_COUNT
SIP_AMOUNT
SI_COUNT
SI_AMOUNT
RED_COUNT
RED_AMOUNT
SO_COUNT
SO_AMOUNT
DR_COUNT
DR_AMOUNT
STP_COUNT
STP_AMOUNT
NET_SALES
DISTRIBUTOR_TYPE
SCHEME_TYPE
FOCUS_PRODUCT
RM_CODE
RM_NAMEtable BROK_DEALER_MAP doesn't have any duplicate records.
table DTRMIS_REPORT have more than 2 lacks duplicate records.
Now i want to update table DTRMIS_REPORT (DISTRIBUTOR_TYPY COLUMN) With the values of BROK_DEALER_MAP (CATEGORY COLUMN).
For that i have written merge statement like below
merge into dtrmis_report a
using brok_dealer_map b
on (a.brok_dlr_code=b.cons_code)
when matched then
update set a.Distributor_type=b.category
where a.brok_dlr_code=b.cons_code;IT's giving error saying ORA-30926: unable to get a stable set of rows in the source tables.
How to update the table.
Please help.Chanchal Wankhade wrote:
IT's giving error saying ORA-30926: unable to get a stable set of rows in the source tables.That means there are duplicate records in your source table.
Please post the output of the below
select cons_code
from brok_dealer_map
group by cons_code
having count(*) > 1;In case of duplicate CONS_CODE, you need to decide with which the target table should get updated
And are you seriously giving a where condition in merge like you posted..?
Edited by: jeneesh on Dec 19, 2012 9:56 AM -
Creating a Dynamic Update Statement based on Select
hi,
i'm trying to create a dynamic update statement based on select statement
my requirment is to query a joint tables and get the results then based on the results i need to copy all the data and create an update statement for each row
for ex
the update statement should look like this
update iadvyy set SO_SWEEP_CNT = '1' where inst_no = '003' and memb_cust_no = 'aaaaaaaaaaaaaaaa';
and the select statement like the following
select substr(key_1,11,9) account_no,sord_mast SO_SWEEP_CNT from
select acct_no,count(*) sord_mast from
(select from_acct_no acct_no,update_mast
from sord where FROM_SYS in ('DEP','INV') and TERM_DATE > 40460
union all
select to_acct_no acct_no,update_mast
from sord where TO_SYS in ('DEP','INV') and TERM_DATE > 40460)
group by Acct_no)
right outer join
invm
on
key_1 = '003'||acct_no
where sord_mast > 0;
so taking the above two columns from the above select statement and substitue the values as separate update statement.
is that doable , please share your knowledge with me if poosible
thanks in advancedis that doable , please share your knowledge with me if poosibleyes
The standard advice when (ab)using EXECUTE IMMEDIATE is to compose the SQL statement in a single VARCHAR2 variable
Then print the SQL before passing it to EXECUTE IMMEDIATE.
COPY the statement & PASTE into sqlplus to validate its correctness. -
Creating Transport request to update / insert Statement
Hi,
In my program i am changing some standard table values through update/insert open sql statements. to keep the identical landscape i have to do the same for quality and production for which i have to transport my prog to quality and prodn .. is there any possability to record the changes ( i made through update /insert statement) into a change request and just transport the change request to insure that same amount of data is effected.
in other words i have to create and populate transport request in runtime.
Regards,
Alnoor ViraniHi
Are you trying to change values in standard SAP tables using insert / update statement.
If Yes, than this is not the right method / approach to modify values.
You need to find User exit / Badi's to populate the values.
SAP may not support this
Pls check
Regards
Madhan D -
How to specify tablespace for a primary key inde in create table statement
How to specify the tablespace for a primary key index in a create table statement?
Does the following statement is right?
CREATE TABLE 'GPS'||TO_CHAR(SYSDATE+1,'YYYYMMDD')
("ID" NUMBER(10,0) NOT NULL ENABLE,
"IP_ADDRESS" VARCHAR2(32 BYTE),
"EQUIPMENT_ID" VARCHAR2(32 BYTE),
"PACKET_DT" DATE,
"PACKET" VARCHAR2(255 BYTE),
"PACKET_FORMAT" VARCHAR2(32 BYTE),
"SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") TABLESPACE "INDEX_DATA"
TABLESPACE "SBM_DATA"; Thank you
Edited by: qkc on 09-Nov-2009 13:42As orafad indicated, you'll have to use the USING INDEX clause from the documentation, i.e.
SQL> ed
Wrote file afiedt.buf
1 CREATE TABLE GPS
2 ("ID" NUMBER(10,0) NOT NULL ENABLE,
3 "IP_ADDRESS" VARCHAR2(32 BYTE),
4 "EQUIPMENT_ID" VARCHAR2(32 BYTE),
5 "PACKET_DT" DATE,
6 "PACKET" VARCHAR2(255 BYTE),
7 "PACKET_FORMAT" VARCHAR2(32 BYTE),
8 "SAVED_TIME" DATE DEFAULT CURRENT_TIMESTAMP,
9 CONSTRAINT "UDP_LOG_PK" PRIMARY KEY ("ID") USING INDEX TABLESP
ACE "USERS"
10 )
11* TABLESPACE "USERS"
SQL> /
Table created.Justin -
Caculated column in a Create Table statement
This is my create table statement:
CREATE TABLE DTPartInv
( partinv_partnbr VARCHAR2(10) NOT NULL,
partinv_prodname VARCHAR2(25),
partinv_desc VARCHAR2(25),
partinv_manufact VARCHAR2(25),
partinv_instock INTEGER NOT NULL,
partinv_category VARCHAR2(20),
partinv_purchdate DATE,
partinv_loc VARCHAR2(15),
partinv_price NUMBER(6,2),
partinv_vendor VARCHAR2(20),
partinv_reorder INTEGER NOT NULL,
partinv_serial VARCHAR2(20),
partinv_flag as (case when partinv_instock < partinv_reorder then 'X' else 'O' end), calculated column
CONSTRAINT DTPartInv_partinv_partnbr_pk
PRIMARY KEY (partinv_partnbr)
and these are my Insert into table statements:
INSERT INTO DTPartInv VALUES('XT40010E',Null,'Exhaust Pipe','TMC Inc',2,'Pipes',TO_DATE('11-APR-10','DD-MON-RR'),Null,45.95,'Oracle Auto Parts',1,Null);
INSERT INTO DTPartInv VALUES('CH9260',Null,'Oil Filter','Mechanical Parts',5,'Fuild Filters',TO_DATE('15-Jan-10','DD-MON-RR'),Null,20.00,'Sink Auto P',2,Null);
INSERT INTO DTPartInv VALUES('15W40',Null,'Oil','Sink Oil',20,'Auto Fuilds',TO_DATE('10-Feb-11','DD-MON-RR'),Null,10.00,'Oracle Auto Parts',5,Null,);
INSERT INTO DTPartInv VALUES('C9262',Null,'Fuel Filter','Mechanical Parts',2,'Fuild Filters',TO_DATE('20-Oct-10','DD-MON-RR'),Null,35.95,'Sink Auto Parts',1,Null);
INSERT INTO DTPartInv VALUES('PS7716',Null,'Fuel/Water Separator','Mechanical Parts',4,'Fuild Filters',TO_DATE('09-Dec-10','DD-MON-RR'),Null,50.00,'Sink Auto Parts',1,Null);
INSERT INTO DTPartInv VALUES('800142',Null,'PPI Valve','Beink Pipes Inc',10,'Valves',TO_DATE('01-Jun-11','DD-MON-RR'),Null,20.00,'Oracle Auto Parts',2,Null);
INSERT INTO DTPartInv VALUES('TTS400',Null,'Butt Clamp','Beink Pipes Inc',10,'Valves',TO_DATE('31-Oct-11','DD-MON-RR'),Null,15.95,'Oracle Auto Parts',2,Null);
INSERT INTO DTPartInv VALUES('TBA400',Null,'Lap Clamp','Beink Pipes Inc',10,'Valves',TO_DATE('10-Nov-11','DD-MON-RR'),Null,30.00,'Oracle Auto Parts',2,Null);
INSERT INTO DTPartInv VALUES('SC16650',Null,'Brake pads','CostVB Mechanical',5,'Mechanical Parts',TO_DATE('15-May-11','DD-MON-RR'),Null,60.00,'Adosql Auto Parts',1,Null);
INSERT INTO DTPartInv VALUES('OB46613',Null,'Emergency Door Latch','CostVB Mechanical',3,'Mechanical Parts',TO_DATE('01-Sep-11','DD-MON-RR'),Null,45.95,'Adosql Auto Parts',1,Null);
And this is a sample of the error I'm geeting:
INSERT INTO DTPartInv VALUES('XT40010E',Null,'Exhaust Pipe','TMC Inc',2,'Pipes',TO_DATE('11-APR-10','DD-MON-RR'),Null,45.95,'Oracle Auto Parts',1,Null)
ERROR at line 1:
ORA-00947: not enough values
I need to figure out, what it is that I am missing here. partinv_flag is supposed to be calculated based on partinv_instock and partinv_reorder.You need to name columns:
1 INSERT INTO DTPartInv
2 (partinv_partnbr, partinv_prodname, partinv_desc, partinv_manufact, partinv_instock, partinv_category, partinv_purchdate,
3 partinv_loc, partinv_price, partinv_vendor, partinv_reorder, partinv_serial)
4* VALUES('XT40010E',Null,'Exhaust Pipe','TMC Inc',2,'Pipes',TO_DATE('11-01-10','DD-MM-RR'),Null,45.95,'Oracle Auto Parts',1,Null)
SQL> /
1 row created.
SQL> select * from dtpartinv;
PARTINV_PA PARTINV_PRODNAME PARTINV_DESC
PARTINV_MANUFACT PARTINV_INSTOCK PARTINV_CATEGORY PARTINV_
PARTINV_LOC PARTINV_PRICE PARTINV_VENDOR PARTINV_REORDER
PARTINV_SERIAL P
XT40010E Exhaust Pipe
TMC Inc 2 Pipes 11/01/10
45,95 Oracle Auto Parts 1
OEdited by: P. Forstmann on 21 nov. 2011 18:57
Edited by: P. Forstmann on 21 nov. 2011 19:00 -
Create Create table statement dynamicallly
I am trying to create a SP that return a “Create table “statement dynamically using a table called “Employee” in database. How can I create a dynamic Create Table
statement using sys.table? The create table statement should contains all the columns from Employee table.. i am using SQL server 2008 R2Hi SSAS_5000,
If you don't care about the constraints,dependency on the Table Employee and what you'd like is the table structure, you may use the below statement where the create statement generated from the SP is executed.
SELECT TOP 1 * INTO desiredTable FROM Eemploy;
TRUNCATE TABLE desiredTable
If you have question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Create table statement from DatabaseMetaData
Hi Experts,
Do you know if it's possible to retrieve a create table statement based on a DatabaseMetaData ? (without looping through columnName / Type)
The idea is to get the DatabaseMetaData from one db server, and execute the Create Table statements on a different db server.
One obvious solution would be to loop through each table's column name/type and construct the create table statement manually, but I'd like to know whether this can be automated.
Thanks in advnace,
SidBigger databases provide a way to access most schema information from the database itself. That doesn't mean that the jdbc meta information is sufficient nor the best way to do that.
There are existing tools that allow for migrations as well. Especially if the migration is a one to one mapping. -
i am accessing the local database through JDBC for an application. but i've been getting "not allowed" errors while trying to execute a CREATE TABLE statement in my servlet. It allows all other statements like insert, delete, select etc. i've been using a default table because of the same reason.
so if someone could please throw some light into it.Hi,
Statements like Create which is a Data definition one
will not be entertained by the program while executing.
The reason being the DB cannot allocate the required buffer for crating a table at the time of execution.
So the alterantive is create your DB table manually in ur Db and try other DML statements.
Hope it helps.
Regards,
Guru -
SQL Developer Create Table Statement to ERD Visio Diagram
I have the following Create table statement from SQL Developer and I am trying to generate an ERD Diagram using 2003 Visio. I was wondering what I need to do to convert the Create Table to an ERD Diagram Using Visio. Thanks
CREATE TABLE “TT_TEAM”.”HR_REVOKED_SECURITY_ORGS”
“ID” NUMBER NOT NULL ENABLE,
“ACAT_CODE” VARCHAR2(6 BYTE) NOT NULL ENABLE,
“APPR_SEQ_NO” NUMBER(3,0) NOT NULL ENABLE,
“USER_ID” VARCHAR2(30 BYTE) NOT NULL ENABLE,
“ACTION_IND” VARCHAR2(1 BYTE) NOT NULL ENABLE,
“ACTIVITY_DATE” DATE NOT NULL ENABLE,
“COAS_CODE” VARCHAR2(1 BYTE),
“ORGN_CODE” VARCHAR2(6 BYTE),
“POSN” VARCHAR2(6 BYTE) NOT NULL ENABLE,
“MANDATORY_APPR_IND” VARCHAR2(1 BYTE),
“APPR_POSN” VARCHAR2(6 BYTE),
“ORGN_MANAGER” VARCHAR2(6 BYTE) NOT NULL ENABLE;I'm pretty Visio is a non-Oracle product.
In the mean-time, you can easily import a DDL script file and create a relational model/diagram using SQL Developer. Use the Import feature and point to your CREATE TABLE script(s) -
SQLPLUS - Create Table statement
Hello gents/ladies.
I have a few tables that I want to import from a DUMP file I have from MySQL. My quickie question : I've removed all the MySQL specific formatting ( I thought ) like Type=MYISAM and similar, and ended up with a CREATE TABLE statement that looks like this:
CREATE TABLE customerdetails (
custid NUMBER(11) NOT NULL auto_increment,
uid_system varchar2(20) NOT NULL default '',
pwd_system varchar2(20) NOT NULL default '',
lastname varchar2(30) NOT NULL default '',
firstname varchar2(30) NOT NULL default '',
middleinitial char(1) default NULL,
day_phone_countrycode char(3) default NULL,
day_phone_main varchar2(16) default NULL,
evening_phone_countrycode char(3) default NULL,
evening_phone_main varchar2(16) default NULL,
email_primary varchar2(80) NOT NULL default '',
email_secondary varchar2(80) default NULL,
street_adress varchar2(80) NOT NULL default '',
state_prov char(3) NOT NULL default '',
zipcode varchar2(11) NOT NULL default '',
countrycode char(3) NOT NULL default '',
PRIMARY KEY (custid),
UNIQUE KEY UC_custid(custid),
UNIQUE KEY IDX_system_uid(uid_system),
KEY idx_lname_fname_mi(lastname,firstname,middleinitial),
KEY IDX_day_phone(day_phone_countrycode,day_phone_main)
I get this error back from SQLPLUS:
CREATE TABLE CUSTOMERDETAILS (
ERROR in line 1:
ORA-00922: missing or invalid option
I've read through the documentation, and can't see what I'm missing here. Could somebody PLEASE point out the obviously screaming error in this statement?
Thanks!
Kind regards,
Henning Kilset Pedersen
Funcom OSLO ASHi Henning Pedersen,
First of all the your query syntax is wrong.
1. the keyword you used "auto_increment" is not in oracle. you need to take it out from query.
2. you are saying some columns are not null but giving default value as '' (two quotes without any space), this is contradiction, since '' is null, this gives you an error.
Need to take it out.
3. the keyword UNIQUE KEY is wrong you need to use only UNIQUE.
4. Another option is not correct it UNIQUE KEY IDX_system_uid(uid_system),
it must be UNIQUE (uid_system)
5. There is not any keyword as a KEY in oracle. you need to take it out from the query too.
The final query will be like :
CREATE TABLE customerdetails (
custid NUMBER(11) NOT NULL ,
uid_system varchar2(20) NOT NULL ,
pwd_system varchar2(20) NOT NULL ,
lastname varchar2(30) NOT NULL ,
firstname varchar2(30) NOT NULL ,
middleinitial char(1) default NULL,
day_phone_countrycode char(3) default NULL,
day_phone_main varchar2(16) default NULL,
evening_phone_countrycode char(3) default NULL,
evening_phone_main varchar2(16) default NULL,
email_primary varchar2(80) NOT NULL ,
email_secondary varchar2(80) default NULL,
street_adress varchar2(80) NOT NULL ,
state_prov char(3) NOT NULL ,
zipcode varchar2(11) NOT NULL ,
countrycode char(3) NOT NULL ,
PRIMARY KEY (custid),
UNIQUE (custid),
UNIQUE (uid_system)---,
---KEY idx_lname_fname_mi(lastname,firstname,middleinitial),
---KEY IDX_day_phone(day_phone_countrycode,day_phone_main)
This would work fine.
Thanx
Arvind.
null -
Hi,
I am facing the following problem:
Database A is running with a great number of tables.
Database B should contain the same tables as A with different data (DB B is empty at the moment).
Therefore I've collected all the 'create table'-statements and packed them into a script.
Because there are several foreign key constraints in DB A (not all deferrable) it seems to be a problem to execute the script.
I have searched the internet how to disable constraints before executing the statements, but I' ve only found solutions for disabling constraints for allready existing tables - not disabling constraint checks will creating.
So, could you please give me a hint what keywords I should use for my further search?
Thanks in advance.steve sastro wrote:
Thanks to all of you.
The point is: I don't really like tools (where I have to click in GUIs). I prefer to see what's going on - just to learn what's happening behind.
As soon as I have tested all of your topics I will reward you with the forum-points. Thx again.
EDIT: Version is 10g
Edited by: steve sastro on 07.12.2009 11:28Being an old-fart command line guy myself, I can appreciate that -- up to a point. But eventually it gets to be simply re-inventing the wheel.
Use exp at the command line. Then use the 'strings' command to examine the output .dmp file. That will give you the education you seek. -
How to manually create a transport for table T604 update?
Hi Gurus,
I upated table T604 with transaction VEU4 - but at the time if saving it did NOT prompt for a transport request
Now, I have to move the data (updated table ) to quality box / prodcution
Instead of using again trx VEU4 in quality / prodcution boxes, I want o create an empty transport manually and then assign table T604 to that transport and move to next box.
Is that possible ? If so, can sombody explain the steps, please : how to manually create a transport and assign ojbects (table object) to it
Thanks,
SMNot sure how you have updated T604 in VEU4, but if you go to SM30 transaction with T604 table and click Customization, then it will take you to the place in SPRO where the table is maintained. From there, use the menu Table View -> Transport and create a transport request. Then select the entries you need to transport (all, if necessary) and go to the menu Edit -> Transport -> Include in Request.
Maybe you are looking for
-
i need to install the new 10.9.2 to my mac but i cant becouse no available data there while i have space there ;therefore, how can i install it
-
How can i use SUM aggregate in select query?
HI, GURUS, How can i use SUM function in Select Query and i want to store that value into itab. for ex: TABLES: vbap. types: begin of ty_vbap, incluse type vbap, sum type string, end of ty_vbap. data: i_vbap type TABLE OF ty_vbap,
-
Auto start service problem with Xp
i installed Oracle 8i (8.1.5) on window XP Pro. it was install ok. but when i am restarting the PC. it is not starting the database service autometic. i check all the values of auto service but i am failed to start it. so can anyone help me to solve
-
When do I need to redeploy a Shared Variable?
I am using 2 network shared variables to share data between cfp-2220s. The shared variables are both clusters of several deifferent data types. Do I need to redeploy the shared variable everytime I add or remove a variable from one of these cluster
-
Package+class=?
Hi, i am confused with formal name of package+class. E.g: java.awt.Frame do you call it: 1. full qualified class name 2. qualifier 3. full name or something else? I think there must be a simple, single and formal word for it? what is that word?