Solved

pl/sql function syntax help

Posted on 2011-09-30
2
321 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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
oracle query help 29 77
Export BLOB data from Oracle 10g 4 35
Migrate database to ASM disks. 1 40
Oracle Listener Not Starting 11 26
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 …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
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 video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

920 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

17 Experts available now in Live!

Get 1:1 Help Now