insert (merged) [message #308481] |
Mon, 24 March 2008 08:41 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
hi
how can i insert using select
INSERT INTO OT
(TP,MON,SPI) 1,'JAN',select SP_ID from sp
where
sp.SP_ID in(select ds.FK_SP_ID from DET_SP ds
where sp.SP_ID=ds.FK_SP_ID)
thanxs
|
|
|
Re: insert [message #308487 is a reply to message #308481] |
Mon, 24 March 2008 09:28 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
How would you select constants in a regular select?
1, select col from table ?
or
select 1, col from table ?
|
|
|
Re: insert [message #308493 is a reply to message #308487] |
Mon, 24 March 2008 09:45 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
hi
i am inserting only one value that is spi from select sp_id rest
is the value sent ..
cannot i select more then one select statement for insert into table
TP, MON, ,SPI
1 jan
for SPI
select SP_ID from sp where sp.SP_ID in
(select ds.FK_SP_ID from DET_SP ds
where sp.SP_ID=ds.FK_SP_ID);
|
|
|
|
Re: insert [message #308503 is a reply to message #308500] |
Mon, 24 March 2008 10:07 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
got it
select 1,'JAN' ......
any way thanxs ...
hi michel still iam working on that proc and package
hope that resolve by other way ..
|
|
|
Re: insert [message #308505 is a reply to message #308503] |
Mon, 24 March 2008 10:26 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
hi
iam getting at 8th line
ORA-00933: SQL command not properly ended
insert into bs
(
sec,tr_dt,rv,sp
)
select
'Tested' as sec,
v_dt tr_dt,
sp_id FROM Sp
WHERE sp_id IN (SELECT fksp_id FROM CUST
WHERE fksp_id=sp_id),
count(1) rv
from cust c where sub_type = 1
|
|
|
|
|
|
|
|
|
|
|
Re: insert [message #308605 is a reply to message #308535] |
Tue, 25 March 2008 01:00 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
SQL> declare
v_osp number(5);
v_mtsp number(5);
begin
select sp_id into v_osp from sp
where sp_id in(select fk_spi from ot
where fk_spi=sp_id);
select sp_id into v_mtsp from sp
where sp_id in(select fk_msp from mt
where fk_msp=sp_id);
INSERT INTO det_sp
(temp_sp,name,act_rec)
(v_mtsp, 'JAN','Y');
INSERT INTO det_sp
(temp_sp,name,act_rec)
( v_osp,'JAN','Y' );
commit;
end;
/
(v_mtsp, 'JAN','Y');
*
ERROR at line 13:
ORA-06550: line 13, column 2:
PL/SQL: ORA-00928: missing SELECT keyword
ORA-06550: line 11, column 1:
PL/SQL: SQL Statement ignored
ORA-06550: line 16, column 3:
PL/SQL: ORA-00928: missing SELECT keyword
ORA-06550: line 14, column 1:
PL/SQL: SQL Statement ignored
|
|
|
|
variable insert [message #308697 is a reply to message #308481] |
Tue, 25 March 2008 04:12 |
oracle_coorgi
Messages: 188 Registered: September 2006 Location: INDIA-karnataka
|
Senior Member |
|
|
hi
for every records i need insert temp_sp id COMING from sp_id from sp through v_Cot variable
temp_sp, name act_rec
101 Curtest Y
102 Curtest Y
103 Curtest Y
108 Curtest Y
109 Curtest Y
DECLARE
v_Cot NUMBER(6);
CURSOR Cot IS select sp_id from sp
where sp_id in(select fk_spi from ot
where fk_spi=sp_id);
BEGIN
OPEN cot;
FETCH Cot INTO v_Cot;
INSERT INTO det_sp (temp_sp,name,act_rec) values(v_cot, 'curtest','z');
EXIT WHEN Cot%NOTFOUND;
END LOOP;
COMMIT;
CLOSE Cot;
end;
/
|
|
|
|
|
|
|