?
Solved

PL/SQL LOOP and SUBSTR Question

Posted on 2009-02-18
2
Medium Priority
?
1,654 Views
Last Modified: 2013-12-07
Hello...
I have 2 questions for the PL/SQL experts here. I'm trying to loop thru a record of filenames that I add to along the way in my pl/sql procedure. I'm use to dealing with cursors that are based on table types and not just a plain record of information. So...1) how do I properly loop through a bunch of plain records? I'm use to "Fetch Into" for a loop...but this record type is not a cursor (see my code below) Do I have it correct?

 ....and my second question is 2) how do i compare two substring values to each other?  (see my code below). I'm getting an error back from the Oracle compiler saying that it was expecting a "=" when that is what I actually have. I'm a bit stumped.

Thx!
Ken
code snippet...
 
  CURSOR bookpagekey_cursor IS
       SELECT e.record_id,
              e.book_page_key,
              e.content_category,
              d.file_name
       FROM vsdm.editorial e, vsdm.doc_renditions d
       WHERE e.record_id=d.record_id;
    
    bookpagekey_record       bookpagekey_cursor%ROWTYPE;
    
    
    TYPE counted_assets IS RECORD
       (asset_filename    varchar2(64));
    
    counted_assets_record    counted_assets;
 
...
 
proceed:='Y';
                   While proceed:='Y' LOOP
                      IF (SUBSTR(bookpagekey_record.file_name, 1, 7) = SUBSTR(counted_assets_record.asset_filename, 1, 7))
                      AND (bookpagekey_record.content_category LIKE '%Primary Image%')
                      THEN proceed:='N';
                      END IF;
                   END LOOP;   
...
-- I insert filenames into the RECORD further below (bottom) in the procedure (snippet below)
  IF ((bookpagekey_record.content_category LIKE '%Primary Image%') AND
                           (bookcode = SUBSTR(bookpagekey_record.book_page_key, 2, 2)))  
                           AND                
                          ((INSTR(bookpagekey_record.file_name, UPPER('_RC'), 1)=0)     AND 
                           (INSTR(bookpagekey_record.file_name, UPPER('_EDIT'), 1)=0)   AND
                           (SUBSTR(bookpagekey_record.file_name, -4, 1) <> '_')         AND
                           (SUBSTR(bookpagekey_record.file_name, -2, 1) <> '_')         AND
                           (INSTR(bookpagekey_record.file_name, UPPER('SPLIT'), 1)=0)   AND
                           (INSTR(bookpagekey_record.file_name, UPPER('COMBO'), 1)=0))
                   
                       THEN PINewScanCount:=PINewScanCount+1;
                            counted_assets_record.asset_filename:=bookpagekey_record.file_name;
                       END IF;

Open in new window

0
Comment
Question by:kencrest
2 Comments
 
LVL 20

Accepted Solution

by:
gatorvip earned 2000 total points
ID: 23670873
>>While proceed:='Y' LOOP

This is where you're getting the "=" error , not in the substr. Change that to "=" instead of ":="
0
 

Author Comment

by:kencrest
ID: 23671265
Nice Catch! Thx for spotting that. I have another PL/SQL question I'm posting. If you could answer it for me asap I'd appreciate it. Thx again!

Ken
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question