Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8653771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:37:19+00:00 2026-06-12T14:37:19+00:00

I’m trying to write a diff procedure in pl/sql. The error message never says

  • 0

I’m trying to write a diff procedure in pl/sql. The error message never says what the structure should be like, only it expected some other symbol, usually that would indicate the end of the line. Also I keep getting errors on example code…

  1. Why does it stop at the first error instead of giving a list of all errors found?
  2. CREATE TYPE EditCost, found EditCost, expecting some other symbol.
  3. cost_matrix INTEGER[, found [, expecting some other symbol.
  4. original.length, invalid reference.
  5. cost_matrix[, found [, expecting some other symbol.
  6. return cost_matrix, no value allowed after return, then how am I to return values?

This code gives me many errors, I removed parts only to find errors in other parts.

CREATE OR REPLACE PROCEDURE diff_string(original in varchar2, other in varchar2, result out varchar2)
is -- Maybe should be as, don't know.
    CREATE TYPE EditCost { 'Change', 'Copy', 'Delete', 'Insert', 'Kill' };
    cost_matrix INTEGER[original.length, other.length];
BEGIN
   IF original = NULL THEN
      result := other;
   ELSIF other = NULL then
      result := original;
   else
       for i in 1 .. length(original)
       loop
           for j in 1 .. length(other)
           loop
               cost_matrix[i, j] := i * j;
           end loop;
       end loop;
       return cost_matrix;
   end if;
END diff_string;
/
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:37:21+00:00Added an answer on June 12, 2026 at 2:37 pm

    Collections are one-dimensional structure. You can implement multi-dimensional arrays by creating collection whose elements are also collection.

    Here is an example of how you can implement two dimensional array(matrix):

    SQL> set serveroutput on;
    SQL> 
    SQL> create or replace procedure Matrix(p_m in number, p_n in number)
      2  is
      3    type T_Array is table of integer;
      4    type T_Matrix is table of T_Array;
      5    l_Matrix T_Matrix := T_Matrix();
      6    l_m varchar2(101);
      7  begin
      8    for i in 1..p_m
      9    loop
     10      l_m  := '';
     11      l_matrix.extend;
     12      l_Matrix(i) := T_Array();
     13      for y in 1..p_n
     14      loop
     15        l_matrix(i).extend;
     16        l_matrix(i)(y) := y;
     17        l_m := l_m || ' | ' || To_Char(l_matrix(i)(y));
     18      end loop;
     19      dbms_output.put_line(l_m);
     20    end loop;
     21  end;
     22  /
    
    Procedure created
    
    SQL> exec matrix(5,5);
    
     | 1 | 2 | 3 | 4 | 5
     | 1 | 2 | 3 | 4 | 5
     | 1 | 2 | 3 | 4 | 5
     | 1 | 2 | 3 | 4 | 5
     | 1 | 2 | 3 | 4 | 5
    
    PL/SQL procedure successfully completed
    
    SQL> exec matrix(5,7);
    
     | 1 | 2 | 3 | 4 | 5 | 6 | 7
     | 1 | 2 | 3 | 4 | 5 | 6 | 7
     | 1 | 2 | 3 | 4 | 5 | 6 | 7
     | 1 | 2 | 3 | 4 | 5 | 6 | 7
     | 1 | 2 | 3 | 4 | 5 | 6 | 7
    

    Find out more about collections here and here


    Response to the comment

    You can successfully use nested table as well. So your code might look like this:

    SQL> set serveroutput on;
    SQL> 
    SQL> CREATE OR REPLACE PROCEDURE diff_string(original in varchar2, other in varchar2, result out varchar2)
      2  is
      3    type T_Array is table of integer;
      4    type T_Matrix is table of T_Array;
      5    cost_matrix T_Matrix := T_Matrix();
      6    --antwoord T_Matrix;
      7    l_res varchar2(301);
      8  BEGIN
      9     IF original is NULL THEN
     10        result := other;
     11     ELSIF other is NULL then
     12        result := original;
     13     else
     14         for i in 1 .. length(original)
     15         loop
     16             l_res := '';
     17             cost_matrix.extend;
     18             cost_matrix(i) := T_Array();
     19             for j in 1 .. length(other)
     20             loop
     21                cost_matrix(i).extend;
     22                cost_matrix(i)(j) := i * j;
     23                l_res := l_res || ' | ' || To_char(cost_matrix(i)(j));
     24            end loop;
     25             dbms_output.put_line(l_res);
     26         end loop;
     27     end if;
     28  END diff_string;
     29  /
    
    Procedure created
    
    SQL> variable res varchar2(31);
    SQL> exec diff_string('String1', 'String2', :res);
    
     | 1 | 2  | 3  | 4  | 5  | 6  | 7
     | 2 | 4  | 6  | 8  | 10 | 12 | 14
     | 3 | 6  | 9  | 12 | 15 | 18 | 21
     | 4 | 8  | 12 | 16 | 20 | 24 | 28
     | 5 | 10 | 15 | 20 | 25 | 30 | 35
     | 6 | 12 | 18 | 24 | 30 | 36 | 42
     | 7 | 14 | 21 | 28 | 35 | 42 | 49
    
    PL/SQL procedure successfully completed
    res
    ---------
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.