我試着寫在Oracle開發人員本次交易:在PL/SQL中聲明變量時提交交易
DECLARE @UserID int:
SET @UserID = 2323;
BEGIN TRANSACTION;
DELETE FROM OWNER.TABLE
WHERE USER_ID = @UserID;
COMMIT TRANSACTION
但int
爲紅色 - 錯誤說的是沒有或縮小
我試着寫在Oracle開發人員本次交易:在PL/SQL中聲明變量時提交交易
DECLARE @UserID int:
SET @UserID = 2323;
BEGIN TRANSACTION;
DELETE FROM OWNER.TABLE
WHERE USER_ID = @UserID;
COMMIT TRANSACTION
但int
爲紅色 - 錯誤說的是沒有或縮小
由於這是標記Oracle和你說你正在使用Oracle開發...
您正在使用的語法對於Oracle數據庫完全錯誤 - 您似乎試圖使用專用於SQL SERVER的代碼。
重新寫它爲Oracle可以是簡單的:
DELETE FROM OWNER.TABLE
WHERE USER_ID = 2323;
COMMIT;
但是,如果特別需要然後綁定變量:
VARIABLE UserID NUMBER;
BEGIN
:UserID := 2323;
END;
/
DELETE FROM OWNER.TABLE
WHERE USER_ID = :UserID;
COMMIT;
或(使用PL/SQL變量) :
DECLARE
UserID OWNER.TABLE.USER_ID%TYPE := 2323;
BEGIN
DELETE FROM OWNER.TABLE
WHERE USER_ID = UserID;
COMMIT;
END;
/
但是,如果它是SQL Server的那麼這部作品:
的MS SQL Server 2014架構設置:
CREATE TABLE table_name (User_ID INT);
INSERT INTO table_name VALUES (2322);
INSERT INTO table_name VALUES (2323);
DECLARE @UserID INT = 2323;
BEGIN TRANSACTION;
DELETE FROM table_name
WHERE User_ID = @UserID;
COMMIT TRANSACTION;
查詢1:
SELECT * FROM table_name
| User_ID |
|---------|
| 2322 |
Oracle和tsql?!?一個標籤應該被刪除... – jarlh
如果這是複製/粘貼問題將是'int'後面的冒號應該是分號 –
我更改爲分號,但仍然是錯誤的:( – RafalQA