I'm struggling to write a stored procedure or function that returns a recordset. Below is my SQL, which SQLplus declares as having compilation errors. Please help.
CREATE TABLE TDepartment (department_id NUMERIC(5) CONSTRAINT pk_TDepartment PRIMARY KEY, department_name VARCHAR(30), department_description VARCHAR(50)); create or replace package TRUSTS_ADMIN as type TDEPARTMENT_CURSOR is ref cursor return TDEPARTMENT%ROWTYPE; end TRUSTS_ADMIN; create or replace function GET_ALL_DEPARTMENTS return TRUSTS_ADMIN.TDEPARTMENT_CURSOR is rc TRUSTS_ADMIN.TDEPARTMENT_CURSOR; begin open rc for select * from TDEPARTMENT; return rc; end;
It is hard to say which error you are receiving. To see your error, type SHOW ERRORS after you try to compile a function. This will tell you *exactly* what the problem is.
For More Information
- Dozens more answers to tough Oracle questions from Brian Peasland are available.
- The Best Oracle Web Links: tips, tutorials, scripts, and more.
- Have an Oracle or SQL tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize. Submit your tip today!
- Ask your technical Oracle and SQL questions -- or help out your peers by answering them -- in our live discussion forums.
- Ask the Experts yourself: Our SQL, database design, Oracle, SQL Server, DB2, metadata, object-oriented and data warehousing gurus are waiting to answer your toughest questions.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.