Solved

sp2-0552 bind error message

Posted on 2003-11-22
5
1,174 Views
Last Modified: 2007-12-19
i have a big table and want to add other table to it. if the div and product is found the table will be updated in the appropriate row, but if they are not found a new record will be inserted in the table.

i made two cursors to do this job, but i faced these errors:

ERROR at line 3:
ORA-06550: line 3, column 59:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 3, column 22:
PL/SQL: SQL Statement ignored
ORA-06550: line 3, column 9:
PLS-00341: declaration of cursor 'MATCH_CUR' is incomplete or malformed
ORA-06550: line 7, column 12:
PL/SQL: Item ignored
ORA-06550: line 15, column 24:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 15, column 3:
PL/SQL: SQL Statement ignored

i have oracle 8i 817 and this is my code:

SQL> declare
  2   cursor form_cur is select * from GSV_R1;
  3   cursor match_cur is select * from form1_final where div= match_div AND prodGrp= match_prodGrp;
  4   form_var form_cur%rowtype;
  5   match_div form1_final.div%type;
  6   match_prodGrp form1_final.prodGrp%type;
  7   match_var match_cur%rowtype;
  8  begin
  9   open form_cur;
 10   fetch form_cur into form_var;
 11   while form_cur%found loop
 12    match_div := form_var.div;
 13    match_prodGrp := form_var.prodGrp;
 14    open match_cur;
 15    fetch match_cur into match_var;
 16    if (match_cur%notfound) then
 17     insert into form1_final(
 18      div,
 19      prodGrp,
 20      gsv_Qty_Current_Year,
 21      gsv_Qty_Previous_Year,
 22      gsv_Qty_Var,
 23      gsv_Price_Current_Year,
 24      gsv_Price_Previous_Year,
 25      gsv_Price_Var)
 26     values(form_var.Div,
 27      form_var.ProdGrp,
 28      form_var.Qty_Current_Year,
 29      form_var.Qty_Previous_Year,
 30      form_var.Qty_Var,
 31      form_var.Price_Current_Year,
 32      form_var.Price_Previous_Year,
 33      form_var.Price_Var);
 34    else
 35     update form1_final
 36     set gsv_Qty_Current_Year = form_var.Qty_Current_Year,
 37      gsv_Qty_Previous_Year = form_var.Qty_Previous_Year,
 38      gsv_Qty_Var = form_var.Qty_Var,
 39      gsv_Price_Current_Year = form_var.Price_Current_Year,
 40      gsv_Price_Previous_Year = form_var.Price_Previous_Year,
 41      gsv_Price_Var = form_var.Price_Var
 42     where div= match_div AND prodGrp=match_prodGrp;
 43    end if;
 44    close match_cur;
 45    fetch form_cur into form_var;
 46    end loop;
 47   close form_cur;
 48  end;
 49  /
 cursor match_cur is select * from form1_final where div= match_div AND prodGrp= match_prodGrp;
                                                          *
ERROR at line 3:
ORA-06550: line 3, column 59:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 3, column 22:
PL/SQL: SQL Statement ignored
ORA-06550: line 3, column 9:
PLS-00341: declaration of cursor 'MATCH_CUR' is incomplete or malformed
ORA-06550: line 7, column 12:
PL/SQL: Item ignored
ORA-06550: line 15, column 24:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 15, column 3:
PL/SQL: SQL Statement ignored

please help me !!
0
Comment
Question by:bassamsbd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Author Comment

by:bassamsbd
ID: 9802935
sorry but the title have wrong error code ........ i correct this code and forget to change the title

forgive me

regards,

Bassam
0
 
LVL 23

Accepted Solution

by:
seazodiac earned 63 total points
ID: 9803603
Hi Bassamsbd:

you are spending a lot of time reinventing the wheel...:-(

take a look at this link, you will be amazed how much time and efforts you will save:

http://otn.oracle.com/products/oracle9i/daily/apr30.html
0
 
LVL 15

Assisted Solution

by:andrewst
andrewst earned 62 total points
ID: 9816985
Your error is caused by the fact that your cursor references two variables that haven't been declared yet (match_div and match_prodGrp).  Rearrange to:

declare
  form_var form_cur%rowtype;
  match_div form1_final.div%type;
  match_prodGrp form1_final.prodGrp%type;
  match_var match_cur%rowtype;
  cursor form_cur is select * from GSV_R1;
  cursor match_cur is select * from form1_final where div= match_div AND prodGrp= match_prodGrp;
 
But as seazodiac says, you are doing this the hard way - and inefficiently.  If you are not on 9i and so don't have the MERGE command you can still skip the match_cur bit and simplify the code like this:

begin
 for form_var in (select * from GSV_R1) loop
   -- Try to update it
   update form1_final
   set gsv_Qty_Current_Year = form_var.Qty_Current_Year,
    gsv_Qty_Previous_Year = form_var.Qty_Previous_Year,
    gsv_Qty_Var = form_var.Qty_Var,
    gsv_Price_Current_Year = form_var.Price_Current_Year,
    gsv_Price_Previous_Year = form_var.Price_Previous_Year,
    gsv_Price_Var = form_var.Price_Var
   where div= form_var.div AND prodGrp=form_var.prodGrp;
   if sql%rowcount = 0 then
       -- No row found to update, so insert it instead
         insert into form1_final(
            div,
            prodGrp,
            gsv_Qty_Current_Year,
            gsv_Qty_Previous_Year,
            gsv_Qty_Var,
            gsv_Price_Current_Year,
            gsv_Price_Previous_Year,
            gsv_Price_Var)
         values(form_var.Div,
            form_var.ProdGrp,
            form_var.Qty_Current_Year,
            form_var.Qty_Previous_Year,
            form_var.Qty_Var,
            form_var.Price_Current_Year,
            form_var.Price_Previous_Year,
            form_var.Price_Var);
  end if;
  end loop;
end;
/
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ER Diagram 3 52
Fill Null values 5 55
oracle numeric condition check 4 48
TNS timeout - "Error-2147467259 ORA-12170: TNS Connect timeout occurred” 10 81
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

739 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