Solved

pl/sql function syntax help

Posted on 2011-09-30
2
320 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 76

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.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
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…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now