home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / database / oracle / 2703 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  3.8 KB

  1. Path: sparky!uunet!stanford.edu!rutgers!concert!aurs01!davis
  2. From: davis@aurs01.uucp (Alan Davis)
  3. Newsgroups: comp.databases.oracle
  4. Subject: Problem with pl/sql declare cursor ... for update of tablename
  5. Message-ID: <61843@aurs01.UUCP>
  6. Date: 6 Jan 93 23:31:12 GMT
  7. Sender: news@aurs01.UUCP
  8. Organization: Alcatel Network Systems, Raleigh NC
  9. Lines: 119
  10.  
  11. I am going bonkers over this :
  12.  
  13. Given the table definition :
  14.  
  15. ----------------------------------------------------------------------
  16. CREATE TABLE PBAPINS
  17.    (
  18.    BOARD_ENTITY         INTEGER,
  19.    REFDES               CHAR(20),
  20.    PIN_NUMBER           CHAR(20),
  21.    PIN_NAME             CHAR(20),
  22.    PAD_STACK_NAME       CHAR(20),
  23.    NET_NAME             CHAR(20),
  24.    DRILL_HOLE_NAME      NUMBER,
  25.    DRILL_HOLE_X         NUMBER,
  26.    DRILL_HOLE_Y         NUMBER,
  27.    PIN_X                NUMBER,
  28.    PIN_Y                NUMBER,
  29.    NODE_NUMBER          INTEGER
  30.    )
  31. ----------------------------------------------------------------------
  32.  
  33. and the Ultrix C function to add a sequential number to each row based on the
  34. net_name column :
  35.  
  36.     status = pbadb_number_nodes(99999); /* sample function call */
  37.  
  38. ----------------------------------------------------------------------
  39. /* int pbadb_number_nodes(long bd_entity)
  40. ** pl/sql block
  41. ** Add a node number to each group of pins with the same netname
  42. */
  43.  
  44. int pbadb_number_nodes(long bd_entity)
  45. {
  46.     EXEC SQL BEGIN DECLARE SECTION;
  47.         long entity;
  48.     EXEC SQL END DECLARE SECTION;        
  49.  
  50.     entity = bd_entity; /* kludge because I can't bind C parameters to pl/sql */
  51.     oraca.orastxtf = 3; /* turn on line number checking in oraca */
  52.  
  53.   EXEC SQL EXECUTE          <---- line 431 in source file
  54.     
  55.     DECLARE 
  56.         CURSOR net_cur IS SELECT *
  57.     FROM pbapins 
  58.             WHERE board_entity = :entity 
  59.             ORDER BY net_name
  60.             FOR UPDATE OF pbapins;
  61.  
  62.         net_rec    net_cur%ROWTYPE;
  63.         curnode INTEGER := 0;
  64.         last_net VARCHAR2;
  65.             
  66.     BEGIN
  67.         last_net := ' ';
  68.  
  69.         OPEN net_cur;
  70.         LOOP
  71.             FETCH net_cur INTO net_rec;
  72.             EXIT WHEN net_cur%NOTFOUND;
  73.  
  74.             IF net_rec.net_name NOT LIKE last_net THEN
  75.                 curnode := curnode + 1;
  76.                 UPDATE pbapins SET pbapins.node_number = (curnode)
  77.                     WHERE CURRENT OF net_cur;
  78.             ELSE
  79.                 UPDATE pbapins SET pbapins.node_number = (curnode)
  80.                     WHERE CURRENT OF net_cur;
  81.             END IF;
  82.  
  83.             last_net := net_rec.net_name;
  84.  
  85.         END LOOP;
  86.     CLOSE net_cur;        
  87.     END;
  88.   END-EXEC;
  89.  
  90.   return(0);
  91.  
  92. error:
  93.     handle_error("pbadb_number_nodes");
  94. /* NOTREACHED */
  95. return (1);
  96.     
  97. }
  98. /* end pbadb_number_nodes */
  99. ----------------------------------------------------------------------
  100.  
  101. The runtime error message is :
  102.  
  103. ----------------------------------------------------------------------
  104. An error has occurred in pbadb_number_nodes.
  105. ORA-06503: PL/SQL: error 0 - Unhandled exception ORA-00904: invalid column name
  106. Num of rows processed is 0.
  107. Last SQL statement:
  108.  DECLARE CURSOR NET_CUR IS SELECT BOARD_ENTITY,REFDES,PIN_NUMBER,PAD_ST
  109. Line number: 431
  110. ----------------------------------------------------------------------
  111.  
  112. What is the problem 'ere? 
  113. I've played with this for days with no luck getting it to work unless
  114. I remove the update ... pbapins stuff.
  115.  
  116. I am running Oracle on Ultrix:
  117.  
  118. ORACLE RDBMS V6.0.34.2.1, transaction processing option - Production
  119. PL/SQL V1.0.34.0.1 - Production
  120. ORACLE Precompiler: Version 1.3.18.1.3 on Wed Jan  6 18:11:43 1993
  121.  
  122. ======================================================================
  123. Alan Davis                      
  124. Alcatel Network Systems         
  125. adavis@rockdal.aud.alcatel.com  
  126.  
  127. Alan Davis                      aur : davis@aurfs1
  128. Alcatel Network Systems         BIX : adavis
  129. adavis@rockdal.aud.alcatel.com  CIS : 72317,3661
  130.