Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL Open cursor Parameters
PL/SQL Open cursor Parameters [message #593082] Tue, 13 August 2013 23:12 Go to next message
sniffing
Messages: 6
Registered: August 2006
Junior Member
Hi-

I am running into issue when passing parameter values in open cursor. I am passing the correct parameter values but some how cursor is not returning the values for me. If i hard the same values in the cursor i get the out , not sure what i am doing here. any help would be really appreciated.

even though i am passing valid values to c_vertex cursor it always returns Notfound condition but when i hard the same values in cursor i get Found condition.

create or replace package body apps.pvertex_duplicate_address is



  PROCEDURE io_print(msg IN VARCHAR2, flag IN VARCHAR2) IS
  BEGIN
    IF flag = 'D' THEN
      dbms_output.put_line(msg);
    ELSIF flag = 'L' THEN
      fnd_file.put_line(fnd_file.log, msg);
    ELSIF flag = 'O' THEN
      fnd_file.put_line(fnd_file.output, msg);
    ELSE
      dbms_output.put_line('FLAG IS NULL');
    END IF;
  END;

  PROCEDURE p_duplicate(errbuf OUT VARCHAR2, retcode OUT NUMBER) is
  
    cursor invoices is
      select b.creation_date,
             b.batch_source_name,
             interface_line_attribute1,
             interface_line_attribute2,
             hl.address1,
             hl.address2,
             hl.address3,
             hl.address4,
             upper(hl.city) city,
             hl.state,
             hl.province,
             upper(hl.county) county,
             hl.country,
             hl.postal_code
        from ra_interface_lines_all b,
             hz_cust_acct_sites_all hcas,
             hz_party_sites         hps,
             hz_locations           hl
       where b.creation_date >= sysdate - 30
         and interface_line_attribute1 in ('US031079601') --, '100362183')
         and b.orig_system_ship_address_id = hcas.cust_acct_site_id
         and hcas.party_site_id = hps.party_site_id
         and hps.location_id = hl.location_id;
  
    cursor c_vertex(city   IN VARCHAR2,
                    county IN VARCHAR2 ) is
    
      select lc.LOCNAMECITY
        from VERTEX.LOCCITY lc, vertex.loccounty lco --, vertex.locstate ls
       where lc.LOCNAMECITY = city
         and lco.LOCNAMECOUNTY = county
                   and lc.LOCGEOCOUNTY = lco.LOCGEOCOUNTY;
    
  
    p_vertex c_vertex%ROWTYPE;
    p_city   varchar2(35);
    p_county varchar2(35);
  
    cit varchar2(35);
  
  begin
    for i in invoices loop
    
      p_city   := i.city;
      p_county := i.county;
    
      dbms_output.put_line((p_city));
      dbms_output.put_line(length(i.city));
      dbms_output.put_line((p_county));
      dbms_output.put_line(length(i.county));
      open c_vertex(p_city, p_county /*, i.postal_code*/);
      FETCH c_vertex
        INTO cit;
      IF c_vertex%NOTFOUND THEN
        dbms_output.put_line(cit);
        io_print('Not Validated', 'D');
      else
        io_print('Validated', 'D');
        dbms_output.put_line(cit);
      END IF;
      CLOSE c_vertex;
    
    END LOOP;
  EXCEPTION
    WHEN OTHERS THEN
      errbuf  := SQLERRM;
      retcode := 2;
  END;
END;

*BlackSwan added {code} tags. Please do so yourself in the future!

[Updated on: Tue, 13 August 2013 23:18] by Moderator

Report message to a moderator

Re: PL/SQL Open cursor Parameters [message #593083 is a reply to message #593082] Tue, 13 August 2013 23:17 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
First & foremost, remove, delete, eliminate the whole & complete EXCEPTION handler!

Please read and follow the forum guidelines, to enable us to help you:

http://www.orafaq.com/forum/t/88153/0/

Since we don't have your tables or data, we can't run, test, debug or improve the posted code.

please post complete Test Case!
Re: PL/SQL Open cursor Parameters [message #593084 is a reply to message #593082] Tue, 13 August 2013 23:22 Go to previous messageGo to next message
sniffing
Messages: 6
Registered: August 2006
Junior Member
Sorry this is the first post so i may have not done the right way. I will try to update it. Thanks for your help.

For Example I am passing City name as 'OMAHA' and county as 'DOUGLAS' in open c_vertex(p_city, p_county) cursor and these values exist in the table but this cursor is not returning the data but if i hard code the same values in the cursor i get the data.


{cursor c_vertex(city IN VARCHAR2,
county IN VARCHAR2)
select lc.LOCNAMECITY
from VERTEX.LOCCITY lc, vertex.loccounty lco --, vertex.locstate ls
where lc.LOCNAMECITY = city
and lco.LOCNAMECOUNTY = county
and lc.LOCGEOCOUNTY = lco.LOCGEOCOUNTY;}

[Updated on: Tue, 13 August 2013 23:29]

Report message to a moderator

Re: PL/SQL Open cursor Parameters [message #593085 is a reply to message #593082] Tue, 13 August 2013 23:41 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
sniffing wrote on Wed, 14 August 2013 09:42
  EXCEPTION
    WHEN OTHERS THEN
      errbuf  := SQLERRM;
      retcode := 2;
  END;



Remove WHEN OTHERS
Re: PL/SQL Open cursor Parameters [message #593086 is a reply to message #593085] Tue, 13 August 2013 23:46 Go to previous messageGo to next message
sniffing
Messages: 6
Registered: August 2006
Junior Member
I actually did that sometime back in the Program and that didn't help. this issue is killing me.. Thanks You!
Re: PL/SQL Open cursor Parameters [message #593087 is a reply to message #593085] Tue, 13 August 2013 23:47 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>For Example I am passing City name as 'OMAHA' and county as 'DOUGLAS' in open c_vertex(p_city, p_county) cursor and these values exist in the table but this cursor is not returning the data but if i hard code the same values in the cursor i get the data.

Since we don't have your tables or data, we can't run, test, debug or improve the posted code.

please post complete Test Case!
Re: PL/SQL Open cursor Parameters [message #593105 is a reply to message #593087] Wed, 14 August 2013 03:03 Go to previous messageGo to next message
cookiemonster
Messages: 13972
Registered: September 2008
Location: Rainy Manchester
Senior Member
What datatype is LOCCITY.LOCNAMECITY and loccounty.LOCNAMECOUNTY?

Re: PL/SQL Open cursor Parameters [message #593106 is a reply to message #593084] Wed, 14 August 2013 03:03 Go to previous message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
sniffing wrote on Wed, 14 August 2013 06:22
For Example I am passing City name as 'OMAHA' and county as 'DOUGLAS' in open c_vertex(p_city, p_county) cursor and these values exist in the table but this cursor is not returning the data but if i hard code the same values in the cursor i get the data.

It sounds that some column(s) in LOCCITY or LOCCOUNTY table have the same name(s) as your cursor variables (CITY, COUNTY).

Of course, DDL of both tables would easily reveal it. And, if it is not that case (yes, I am only guessing, as your post is missing a lot of valuable information), complete reproducible (=behaving like you describe) test case (as you were already asked. twice) is necessary for detecting the real reason.
Previous Topic: How to convert a decimal number to a character in pl/sql
Next Topic: Need Logic for SQL query
Goto Forum:
  


Current Time: Fri Sep 05 02:08:15 CDT 2025