00103错误插入新行

y53ybaqx  于 2021-07-26  发布在  Java
关注(0)|答案(2)|浏览(294)

这将是一个漫长的问题,我很抱歉,如果这个问题不是那么有趣。我只是oracle sql的初学者。我刚接触oracle,现在我尝试编写一个脚本,在表t\u用户中添加新行。
这是我的密码:

SET SERVEROUTPUT ON; --- IT WAS OFF BY DEFAULT

--- declare the variable

DECLARE

TUSERID NUMBER(38,0);
TORGID  NUMBER(38,0) := 'Write-the-Org-ID-Here';
TROLE   NUMBER(38,0) := 'Write-the-role-Here';
TQDL    NUMBER(38,0) := null;
TFIRSTNAME  VARCHAR2(255 BYTE)  := 'Write-the-First-Name-Here';
TLASTNAME   VARCHAR2(255 BYTE) := 'Write-the-Last-Name-Here';
TEMAIL  VARCHAR2(255 BYTE) := 'Write-the-email-Here';
TEMAILSUBSCRIPTION  NUMBER(1,0) := null;
TDIVISION   VARCHAR2(255 BYTE) := 'Write-the-division-Here';
TQNUMBER    VARCHAR2(255 BYTE) := 'Write-the-QNumber-for-the-user-Here';
TACTIVE NUMBER(1,0) := 1;
TCREATOR    NUMBER(38,0);
TCREATED    TIMESTAMP(6);
TEDITOR NUMBER(38,0);
TEDITED TIMESTAMP(6);
TISDELETED  NUMBER(1,0)  := 0;
TLOGIN  VARCHAR2(255 BYTE) := 'Write-the-QNumber-for-the-user-Here';
TSETTINGS   CLOB := null;
TDEFAULTINBOX   NUMBER(38,0) := null;
TACCESSTOPST    NUMBER(38,0) := null;
TTIME_ZONE  VARCHAR2(100 CHAR) := 'Write-the-Time-Zone-Here';
TLIMITEDACCESS  NUMBER(1,0) := null;
TVALID_UNTIL    TIMESTAMP(6);
TCOMMENTS   VARCHAR2(255 CHAR) := null; --- I think you can insert the number of the Incident here
TAFTERSALESACCESS   NUMBER(38,0) := null;
TSOURCE VARCHAR2(5 BYTE) := 'QCAT';

---- BEGIN

BEGIN

SELECT COUNT(USERID) + 1
INTO TUSERID
FROM T_USER;
--------
SELECT USERID
INTO TCREATOR
FROM T_USER
WHERE LOGIN = 'Your-Q-number';
-------
SELECT  systimestamp
INTO TCREATED
FROM dual;
---
SELECT USERID
INTO TEDITOR
FROM T_USER
WHERE LOGIN = 'Your-Q-number';
 ----
SELECT systimestamp
INTO TEDITED
FROM dual;
-----
SELECT TO_CHAR
((select add_months((SELECT systimestamp FROM dual),1 *12) from dual), 'MM-DD-YYYY HH24:MI:SS') ----"TODAY" ?????
INTO TVALID_UNTIL
FROM DUAL; ---- ADD one year to the currrent date

END 

----INSERT INTO

INSERT INTO T_USER (USERID,
ORGID,
ROLE,
QDL,
FIRSTNAME,
LASTNAME,
EMAIL,
EMAILSUBSCRIPTION,
DIVISION,
QNUMBER,
ACTIVE,
CREATOR,
CREATED,
EDITOR,
EDITED,
ISDELETED,
LOGIN,
SETTINGS,
DEFAULTINBOX,
ACCESSTOPST,
TIME_ZONE,
LIMITEDACCESS,
VALID_UNTIL,
COMMENTS,
AFTERSALESACCESS,
SOURCE) 
VALUES(TUSERID,
TORGID,
TROLE,
TQDL,
TFIRSTNAME,
TLASTNAME,
TEMAIL,
TEMAILSUBSCRIPTION,
TDIVISION,
TQNUMBER,
TACTIVE,
TCREATOR,
TCREATED,
TEDITOR,
TEDITED,
TISDELETED,
TLOGIN,
TSETTINGS,
TDEFAULTINBOX,
TACCESSTOPST,
TTIME_ZONE,
TLIMITEDACCESS,
TVALID_UNTIL,
TCOMMENTS,
TAFTERSALESACCESS,
TSOURCE);

我收到以下错误:

Error starting at line : 5 in command -
DECLARE

TUSERID NUMBER(38,0);
TORGID  NUMBER(38,0) := 'Write-the-Org-ID-Here';
TROLE   NUMBER(38,0) := 'Write-the-role-Here';
TQDL    NUMBER(38,0) := null;
TFIRSTNAME  VARCHAR2(255 BYTE)  := 'Write-the-First-Name-Here';
TLASTNAME   VARCHAR2(255 BYTE) := 'Write-the-Last-Name-Here';
TEMAIL  VARCHAR2(255 BYTE) := 'Write-the-email-Here';
TEMAILSUBSCRIPTION  NUMBER(1,0) := null;
TDIVISION   VARCHAR2(255 BYTE) := 'Write-the-division-Here';
TQNUMBER    VARCHAR2(255 BYTE) := 'Write-the-QNumber-for-the-user-Here';
TACTIVE NUMBER(1,0) := 1;
TCREATOR    NUMBER(38,0);
TCREATED    TIMESTAMP(6);
TEDITOR NUMBER(38,0);
TEDITED TIMESTAMP(6);
TISDELETED  NUMBER(1,0)  := 0;
TLOGIN  VARCHAR2(255 BYTE) := 'Write-the-QNumber-for-the-user-Here';
TSETTINGS   CLOB := null;
TDEFAULTINBOX   NUMBER(38,0) := null;
TACCESSTOPST    NUMBER(38,0) := null;
TTIME_ZONE  VARCHAR2(100 CHAR) := 'Write-the-Time-Zone-Here';
TLIMITEDACCESS  NUMBER(1,0) := null;
TVALID_UNTIL    TIMESTAMP(6);
TCOMMENTS   VARCHAR2(255 CHAR) := null; --- I think you can insert the number of the Incident here
TAFTERSALESACCESS   NUMBER(38,0) := null;
TSOURCE VARCHAR2(5 BYTE) := 'QCAT';

---- BEGIN

BEGIN

SELECT COUNT(USERID) + 1
INTO TUSERID
FROM T_USER;
--------
SELECT USERID
INTO TCREATOR
FROM T_USER
WHERE LOGIN = 'Your-Q-number';
-------
SELECT  systimestamp
INTO TCREATED
FROM dual;
---
SELECT USERID
INTO TEDITOR
FROM T_USER
WHERE LOGIN = 'Your-Q-number';
 ----
SELECT systimestamp
INTO TEDITED
FROM dual;
-----
SELECT TO_CHAR
((select add_months((SELECT systimestamp FROM dual),1 *12) from dual), 'MM-DD-YYYY HH24:MI:SS') ----"TODAY" ?????
INTO TVALID_UNTIL
FROM DUAL; ---- ADD one year to the currrent date

END 

----INSERT INTO

INSERT INTO T_USER (USERID,
ORGID,
ROLE,
QDL,
FIRSTNAME,
LASTNAME,
EMAIL,
EMAILSUBSCRIPTION,
DIVISION,
QNUMBER,
ACTIVE,
CREATOR,
CREATED,
EDITOR,
EDITED,
ISDELETED,
LOGIN,
SETTINGS,
DEFAULTINBOX,
ACCESSTOPST,
TIME_ZONE,
LIMITEDACCESS,
VALID_UNTIL,
COMMENTS,
AFTERSALESACCESS,
SOURCE) 
VALUES(TUSERID,
TORGID,
TROLE,
TQDL,
TFIRSTNAME,
TLASTNAME,
TEMAIL,
TEMAILSUBSCRIPTION,
TDIVISION,
TQNUMBER,
TACTIVE,
TCREATOR,
TCREATED,
TEDITOR,
TEDITED,
TISDELETED,
TLOGIN,
TSETTINGS,
TDEFAULTINBOX,
TACCESSTOPST,
TTIME_ZONE,
TLIMITEDACCESS,
TVALID_UNTIL,
TCOMMENTS,
TAFTERSALESACCESS,
TSOURCE);
Error report -
ORA-06550: line 65, column 1:
PLS-00103: Encountered the symbol "INSERT" when expecting one of the following:

   ; <an identifier> <a double-quoted delimited-identifier>
06550. 00000 -  "line %s, column %s:\n%s"

* Cause:    Usually a PL/SQL compilation error.
* Action:

事先谢谢你的帮助。我花了几个小时,这是我能写的最终结果,我不明白我做错了什么。

suzh9iv8

suzh9iv81#

试着在结尾后加一个分号。

d5vmydt9

d5vmydt92#

你的目的地不对。pl/sql中的单元以begin开始,以end结束。你可以有更多的单位,但在你的情况下,你只有一个开始,所以最后一个命令必须是一个结束;

declare 
-- declarantion of variables and cursors
begin
-- processing
end;

所以,在你的代码里

DECLARE

TUSERID NUMBER(38,0);
TORGID  NUMBER(38,0) := 'Write-the-Org-ID-Here';
TROLE   NUMBER(38,0) := 'Write-the-role-Here';
TQDL    NUMBER(38,0) := null;
TFIRSTNAME  VARCHAR2(255 BYTE)  := 'Write-the-First-Name-Here';
TLASTNAME   VARCHAR2(255 BYTE) := 'Write-the-Last-Name-Here';
TEMAIL  VARCHAR2(255 BYTE) := 'Write-the-email-Here';
TEMAILSUBSCRIPTION  NUMBER(1,0) := null;
TDIVISION   VARCHAR2(255 BYTE) := 'Write-the-division-Here';
TQNUMBER    VARCHAR2(255 BYTE) := 'Write-the-QNumber-for-the-user-Here';
TACTIVE NUMBER(1,0) := 1;
TCREATOR    NUMBER(38,0);
TCREATED    TIMESTAMP(6);
TEDITOR NUMBER(38,0);
TEDITED TIMESTAMP(6);
TISDELETED  NUMBER(1,0)  := 0;
TLOGIN  VARCHAR2(255 BYTE) := 'Write-the-QNumber-for-the-user-Here';
TSETTINGS   CLOB := null;
TDEFAULTINBOX   NUMBER(38,0) := null;
TACCESSTOPST    NUMBER(38,0) := null;
TTIME_ZONE  VARCHAR2(100 CHAR) := 'Write-the-Time-Zone-Here';
TLIMITEDACCESS  NUMBER(1,0) := null;
TVALID_UNTIL    TIMESTAMP(6);
TCOMMENTS   VARCHAR2(255 CHAR) := null; --- I think you can insert the number of the Incident here
TAFTERSALESACCESS   NUMBER(38,0) := null;
TSOURCE VARCHAR2(5 BYTE) := 'QCAT';

---- BEGIN

BEGIN

SELECT COUNT(USERID) + 1
INTO TUSERID
FROM T_USER;
--------
SELECT USERID
INTO TCREATOR
FROM T_USER
WHERE LOGIN = 'Your-Q-number';
-------
SELECT  systimestamp
INTO TCREATED
FROM dual;
---
SELECT USERID
INTO TEDITOR
FROM T_USER
WHERE LOGIN = 'Your-Q-number';
 ----
SELECT systimestamp
INTO TEDITED
FROM dual;
-----
SELECT TO_CHAR
((select add_months((SELECT systimestamp FROM dual),1 *12) from dual), 'MM-DD-YYYY HH24:MI:SS') ----"TODAY" ?????
INTO TVALID_UNTIL
FROM DUAL; ---- ADD one year to the currrent date

    ----INSERT INTO

INSERT INTO T_USER (USERID,
ORGID,
ROLE,
QDL,
FIRSTNAME,
LASTNAME,
EMAIL,
EMAILSUBSCRIPTION,
DIVISION,
QNUMBER,
ACTIVE,
CREATOR,
CREATED,
EDITOR,
EDITED,
ISDELETED,
LOGIN,
SETTINGS,
DEFAULTINBOX,
ACCESSTOPST,
TIME_ZONE,
LIMITEDACCESS,
VALID_UNTIL,
COMMENTS,
AFTERSALESACCESS,
SOURCE) 
VALUES(TUSERID,
TORGID,
TROLE,
TQDL,
TFIRSTNAME,
TLASTNAME,
TEMAIL,
TEMAILSUBSCRIPTION,
TDIVISION,
TQNUMBER,
TACTIVE,
TCREATOR,
TCREATED,
TEDITOR,
TEDITED,
TISDELETED,
TLOGIN,
TSETTINGS,
TDEFAULTINBOX,
TACCESSTOPST,
TTIME_ZONE,
TLIMITEDACCESS,
TVALID_UNTIL,
TCOMMENTS,
TAFTERSALESACCESS,
TSOURCE);

COMMIT;

END;

相关问题