當我輸入:
INSERT INTO reserve VALUES (
(SELECT branch_code FROM branch WHERE branch_contact_no = '8888888883'),
(SELECT bc_id FROM book_copy WHERE book_call_no = '005.74 C822D 2018' AND
SELECT branch_code FROM branch WHERE branch_contact_no = '8888888881'
TO_DATE('20/09/2018 16:00:00', 'DD/MM/YYYY HH24:MI:SS'),
seq_borrower.currVal);
一直出現
Error report -
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
請問如何修正.
google 關鍵字 oracle insert into
我觀落陰了一下...先放棄BOR_NO 是甚麼..
你看看insert into 吧...
create table BRANCH(
BRANCH_CODE number(10)
,BRANCH_NAME varchar2(50)
,BRANCH_ADDERSS varchar2(50)
,BRANCH_CONTACT_NO varchar2(50)
,BRANCH_COUNT_BOOKS number(10)
,MAN_ID number(10)
);
insert into BRANCH(BRANCH_CODE,BRANCH_NAME,BRANCH_ADDERSS,BRANCH_CONTACT_NO,BRANCH_COUNT_BOOKS,MAN_ID)
values(10,'aaa','bbb','8888888881',5000,1);
insert into BRANCH(BRANCH_CODE,BRANCH_NAME,BRANCH_ADDERSS,BRANCH_CONTACT_NO,BRANCH_COUNT_BOOKS,MAN_ID)
values(12,'ccc','ggg','8888888883',45000,1);
create table BOOK_COPY(
BRANCH_CODE number(10)
,BC_ID number(10)
,BC_PURCHASE_PRICE number(10)
,BC_RESERVE_FLAG varchar2(5)
,BOOK_CALL_NO varchar2(50)
);
insert into BOOK_COPY(BRANCH_CODE,BC_ID,BC_PURCHASE_PRICE,BC_RESERVE_FLAG,BOOK_CALL_NO)
values(10,6,120,'Y','005.74 C822D 2018');
insert into BOOK_COPY(BRANCH_CODE,BC_ID,BC_PURCHASE_PRICE,BC_RESERVE_FLAG,BOOK_CALL_NO)
values(11,6,120,'Y','005.74 C822D 2018');
insert into BOOK_COPY(BRANCH_CODE,BC_ID,BC_PURCHASE_PRICE,BC_RESERVE_FLAG,BOOK_CALL_NO)
values(12,6,120,'Y','005.74 C822D 2018');
create table RESERVE(
BRANCH_CODE number(10)
,BC_ID number(10)
,RESERVE_Date TIMESTAMP
,BOR_NO varchar2(5)
);
insert into RESERVE(BRANCH_CODE
,BC_ID
,RESERVE_Date
)
select (
SELECT branch_code FROM branch WHERE branch_contact_no = '8888888883'
) branch_code
,bc_id
,TO_DATE('2018/09/20 16:00:00', 'yyyy/mm/dd hh24:mi:ss') test_date
FROM book_copy a
LEFT JOIN branch b on a.branch_code = b.branch_code
WHERE book_call_no = '005.74 C822D 2018'
AND branch_contact_no = '8888888881';
test url:
http://sqlfiddle.com/#!4/2f38b4/2