0

I'm new to PL/SQL and trying to convert an SQL statement into the PL/SQL format. I have the SQL statement as:

SELECT StudentIDNumber
FROM Lease
INNER JOIN Invoice
ON Invoice.LeaseID = Lease.LeaseID
WHERE IsPaid = 'N';

How would I go about this? Any solutions would be greatly appreciated!

2
  • 1
    The query looks fine. Have you tried it? Commented Apr 6, 2016 at 23:18
  • Your question doesn't make sense. There is no such thing as a "PL/SQL query". PL/SQL is only used for stored procedures, functions and triggers. Anything else is simply SQL. And the query you have is already SQL. So to what exactly do you want to convert that? Commented Apr 7, 2016 at 7:28

2 Answers 2

2

I think you would only need to specify your schema in Oracle and that's about it. The other syntax should be correct (provided your tables are coming from the same Schema/table):

SELECT StudentIDNumber
FROM PRODDATA.Lease
INNER JOIN Invoice
ON Invoice.LeaseID = Lease.LeaseID
WHERE IsPaid = 'N';

This document offered by Oracle also has some basic syntax changes that could prove useful to you https://docs.oracle.com/cd/E10405_01/appdev.120/e10379/ss_oracle_compared.htm

Sign up to request clarification or add additional context in comments.

Comments

1

may be try below PlSQL snippet?

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;

2 Comments

Didn't work, Got an error: Error report - ORA-06550: line 4, column 10: PL/SQL: ORA-00918: column ambiguously defined ORA-06550: line 4, column 3: PL/SQL: SQL Statement ignored ORA-06550: line 9, column 24: PLS-00330: invalid use of type name or subtype name ORA-06550: line 9, column 3: PL/SQL: Statement ignored 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:
seems to be an aliasing issue. Add table alias name (Lease or Invoice) before StudentIDNumber or IsPaid whichever is present in both table and try?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.