Solved

pl/sql function syntax help

Posted on 2011-09-30
2
323 Views
Last Modified: 2012-05-12
Hello,
Can anybody tell me why I get an error on the If?

FUNCTION fn_GetExporterRegulateeContact
 RETURN cur_RegulateeContact IS
 v_regulateeContact cur_RegulateeContact;
 v_dossier_co_contact_name  varchar2(60);
 
  BEGIN
 
  SELECT DOSSIER_CO_CONTACT_NAME into v_dossier_co_contact_name
  FROM DOSSIER_COMPANY
  WHERE DOS_HWMD_SYS_ENTERED_YR = v_dossieryear
  AND DOSSIER_IDENTIFIER = v_dossierid
  AND DOSSIER_TYPE_CODE = v_dossiertype
  AND DOSSIER_CO_ROLE_CODE = 'G'
  AND COMPANY_SITE_NUMBER = v_companySiteNumber
  AND company_number = v_companyNumber;
 
  OPEN v_regulateeContact FOR
   
      IF (v_dossier_co_contact_name IS NOT NULL) OR (v_dossier_co_contact_name <> ' ') THEN
               
        SELECT DISTINCT cs.contact_name AS FirstName, 'N/A' AS LastName,
          cs.phone_number AS PhoneNumberText, cs.fax_number as FaxText, cs.email_address AS EmailText
        FROM DOSSIER_COMPANY dc INNER JOIN COMPANY_SITE_CONTACT cs
          ON dc.company_number = cs.company_number
          AND dc.company_site_number = cs.company_site_number
        WHERE cs.contact_name = v_dossier_co_contact_name
          AND dc.dos_hwmd_sys_entered_yr = v_dossierYear
          AND dc.dossier_identifier = v_dossierID
          AND dc.dossier_type_code = v_dossierType
          AND dc.DOSSIER_CO_ROLE_CODE = 'G';    
     
      ELSE
     
        SELECT DISTINCT cs.contact_name AS FirstName, 'N/A' AS LastName,
          cs.phone_number AS PhoneNumberText, cs.fax_number as FaxText, cs.email_address AS EmailText
        FROM DOSSIER_COMPANY dc INNER JOIN COMPANY_SITE_CONTACT cs
          ON dc.company_number = cs.company_number
          AND dc.company_site_number = cs.company_site_number
        WHERE cs.contact_name = v_dossier_co_contact_name
          AND dc.dos_hwmd_sys_entered_yr = v_dossierYear
          AND dc.dossier_identifier = v_dossierID
          AND dc.dossier_type_code = v_dossierType
          AND dc.DOSSIER_CO_ROLE_CODE = 'G';
         
      END IF;
     
      RETURN v_regulateeContact;
       
END fn_GetExporterRegulateeContact;
0
Comment
Question by:Mosquitoe
2 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 125 total points
ID: 36893527
"OPEN v_regulateeContact FOR"

After the FOR you need a select statement:

OPEN v_regulateeContact FOR select sysdate from dual;

http://download.oracle.com/docs/cd/B14117_01/appdev.101/b10807/13_elems033.htm
0
 

Author Comment

by:Mosquitoe
ID: 36893571
In the IF statement I look for a value that is just spaces:
IF (v_dossier_co_contact_name IS NOT NULL) OR (v_dossier_co_contact_name <> '  ')
But I just realised that they are not consistent, may be one space or tw spaces or more - is there a better way that I can do that in one statement?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

827 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