English 中文(简体)
表格中的印刷品
原标题:Print Quotes from nested table

完成以下工作:

    CREATE OR REPLACE 
PROCEDURE POPULATE_ACTOR_QUOTES (id_actor char)
AS
   CURSOR quote_recs IS
      SELECT m.title, 
             m.year, 
             r.roleName,
             q.quotechar 
        from quote q, 
             role r, 
             rolequote rq,  
             actor a, 
             movie m
       where rq.quoteID = q.quoteID
         AND rq.roleID = r.roleID
         AND r.actorID = a.actorID
         AND r.movieID = m.movieID
         AND a.actorID = id_actor;
BEGIN
   FOR row IN quote_recs 
   LOOP
      INSERT INTO table(
      SELECT quotes
        FROM actor_quotes aq
       WHERE aq.actorId = id_actor)
      VALUES(
         ACTOR_QUOTE_TYPE(row.title, row.year, row.roleName, row.quotechar)
      );
   end loop;
END POPULATE_ACTOR_QUOTES;
/

创立一个称为PRINT_ACTOR_QUOTES (通过修改程序POTE_ACTOR_QUOTES)的单一参数: 印刷ACTOR表格中与ACTORID(程序参数)对应的第一份名称和最后名称属性,并印刷从表格中引述的所有信息。

这是我创造的:

CREATE OR REPLACE PROCEDURE PRINT_ACTOR_QUOTES (id_actor char)
AS
CURSOR quote_recs IS
SELECT a.firstName,a.lastName, m.title, m.year, r.roleName ,q.quotechar from quote q, role r,   
rolequote rq, actor a, movie m
where
rq.quoteID = q.quoteID
AND
rq.roleID = r.roleID
 AND
r.actorID = a.actorID
AND
r.movieID = m.movieID
AND
 a.actorID = id_actor;
BEGIN
FOR row IN quote_recs
LOOP
  DBMS_OUTPUT.PUT_LINE( row.firstName ||     || row.lastName );

END LOOP;

END PRINT_ACTOR_QUOTES;
/ 

产出

SQL> EXECUTE PRINT_ACTOR_QUOTES ( 00070 )

Dustin                   Hoffman

有必要创造出一种着眼于以下方面的产出:

JEFF GOLDBLUM

|Title           | Year |       Role     |                Quote                               |
----------------------------------------------------------------------------------------------
|THE FLY         |1986  |SETH BRUNDLE    | “I’m free and you don’t like it’’ |
|INDEPENDENCE DAY| 1996 | DAVID LEVINSON | “I’ve given it a virus”           |

我有第一个名字和第二个名字——需要从封顶的QUOTES表获得的信息。

需要帮助!

下面是引出从引证的引言中得出的所需信息,即:

SELECT REC.*
  FROM ACTOR_QUOTES A,TABLE(A.QUOTES) REC
  WHERE ACTORID = ( 00070 )
最佳回答

我很可能没有东西......

CREATE OR REPLACE PROCEDURE PRINT_ACTOR_QUOTES (id_actor char)
AS
CURSOR quote_recs IS
SELECT a.firstName,a.lastName, m.title, m.year, r.roleName ,q.quotechar from quote q, role r,   
rolequote rq, actor a, movie m
where
rq.quoteID = q.quoteID
AND
rq.roleID = r.roleID
 AND
r.actorID = a.actorID
AND
r.movieID = m.movieID
AND
 a.actorID = id_actor;

is_first boolean := true;

BEGIN
FOR row IN quote_recs
LOOP
if is_first then
  DBMS_OUTPUT.PUT_LINE( row.firstName ||     || row.lastName );
  DBMS_OUTPUT.PUT_LINE(  Title   | Year |    Role     |     Quote   );
  is_first := false;
end if;

  DBMS_OUTPUT.PUT_LINE( row.title||     || row.year||     || row.role ||     || row.quotechar );

END LOOP;

END PRINT_ACTOR_QUOTES;
/ 
问题回答

暂无回答




相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

How to make a one to one left outer join?

I was wondering, is there a way to make a kind of one to one left outer join: I need a join that matches say table A with table B, for each record on table A it must search for its pair on table B, ...

Insert if not exists Oracle

I need to be able to run an Oracle query which goes to insert a number of rows, but it also checks to see if a primary key exists and if it does, then it skips that insert. Something like: INSERT ALL ...

How can I store NULLs in NOT NULL field?

I just came across NULL values in NOT-NULL fields in our test database. How could they get there? I know that NOT-NULL constraints can be altered with NOVALIDATE clause, but that would change table s ...

Type reference scope

I m studying databases and am currently working on a object-relational DB project and I ve encountered a small problem with the number of possible constraints in an object table. I m using "Database ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

热门标签