?
Solved

pl/sql function syntax help

Posted on 2011-09-30
2
Medium Priority
?
331 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 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses
Course of the Month15 days, 3 hours left to enroll

839 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