我是PL / SQL的新手,并尝试将SQL语句转换为PL / SQL格式。我的SQL语句为:
SELECT StudentIDNumber
FROM Lease
INNER JOIN Invoice
ON Invoice.LeaseID = Lease.LeaseID
WHERE IsPaid = 'N';
我该怎么做?任何解决方案将不胜感激!
答案 0 :(得分:2)
我认为您只需要在Oracle中指定您的架构即可。其他语法应该是正确的(假设您的表来自相同的Schema /表):
SELECT StudentIDNumber
FROM PRODDATA.Lease
INNER JOIN Invoice
ON Invoice.LeaseID = Lease.LeaseID
WHERE IsPaid = 'N';
Oracle提供的这份文档还有一些基本的语法更改,可能对您有用https://docs.oracle.com/cd/E10405_01/appdev.120/e10379/ss_oracle_compared.htm
答案 1 :(得分:1)
可能会在PlSQL片段下面尝试?
DECLARE
TYPE lv_student_ID IS TABLE OF NUMBER;
BEGIN
-- assuming you are trying to find all students who have not yet paid, you can use a nested table
SELECT StudentIDNumber
BULK COLLECT INTO lv_student_ID
FROM Lease INNER JOIN Invoice ON Invoice.LeaseID = Lease.LeaseID
WHERE IsPaid = 'N';
-- use value as you want
DBMS_OUTPUT.put_line (lv_student_ID.COUNT);
END;