Solved

pl/sql function syntax help

Posted on 2011-09-30
2
326 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
[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
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

707 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