473,378 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Function - missing parentheses

46
I'm trying to create a function and the error I keep receiving is that I am missing a ')' in line 34. Line 34 in SQL Server is in bold below:

from schedule s, serviceward w, (select distinct conftype from confattnsrvrate where acyear=@acyear) c

Here is all the code for the function.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER FUNCTION [dbo].[ConfAttnRpt1]
(
@acyear smallint
)
RETURNS TABLE
AS
RETURN

/*
Use in conference attendance report

*/

(
Select top 100 percent * from ViewConfAttnRate
where acyear=@acyear

UNION

SELECT top 100 percent * FROM
(
select dbo.idtoname(eid) [Name],eid,
CAST(acyear AS char(4))
+CASE WHEN rotation>=10 THEN CAST(rotation AS char(2)) ELSE '0'+CAST(rotation AS char(1)) END [Period],
@acyear acyear,rotation,pgy,dbo.idtoTrainPrg(eid) Program,w.srvcode,schrecid,
conftype,0 a,0 b,0 c,0 d,0 e,shortname,hosp,abbrev
from schedule s, serviceward w, (select distinct conftype from confattnsrvrate where acyear=@acyear) c
where acyear=@acyear
and s.srvcode=w.srvcode
)

Please tell me how to fix this because it seems to me I'm not missing another ')'
Thank you.
Mar 12 '08 #1
2 1520
amitpatel66
2,367 Expert 2GB
Yes you are missing one:
Try This:

Expand|Select|Wrap|Line Numbers
  1.  
  2. set ANSI_NULLS ON
  3. set QUOTED_IDENTIFIER ON
  4. go
  5.  
  6.  
  7. ALTER FUNCTION [dbo].[ConfAttnRpt1] 
  8. @acyear smallint
  9. )
  10. RETURNS TABLE 
  11. AS
  12. RETURN 
  13.  
  14. /* 
  15. Use in conference attendance report
  16.  
  17. */
  18.  
  19. (
  20. Select top 100 percent * from ViewConfAttnRate
  21. where acyear=@acyear
  22.  
  23. UNION
  24.  
  25. SELECT top 100 percent * FROM 
  26. (
  27. select dbo.idtoname(eid) [Name],eid,
  28. CAST(acyear AS char(4))
  29. +CASE WHEN rotation>=10 THEN CAST(rotation AS char(2)) ELSE '0'+CAST(rotation AS char(1)) END [Period],
  30. @acyear acyear,rotation,pgy,dbo.idtoTrainPrg(eid) Program,w.srvcode,schrecid,
  31. conftype,0 a,0 b,0 c,0 d,0 e,shortname,hosp,abbrev
  32. from schedule s, serviceward w, (select distinct conftype from confattnsrvrate where acyear=@acyear) c
  33. where acyear=@acyear 
  34. and s.srvcode=w.srvcode
  35. ))
  36.  
  37.  
Mar 12 '08 #2
teneesh
46
Actually - I figured it out!!! I had to name the last set of parentheses. So after putting t after the second group of parentheses, it worked. Here it is:


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go


ALTER FUNCTION [dbo].[ConfAttnRptSmry]

(

@acyear smallint

)

RETURNS TABLE

AS

RETURN

/*

Use in conference attendance report

*/

(

SELECT top 100 percent * FROM ViewConfAttnRate

WHERE acyear=@acyear

UNION

SELECT top 100 percent * FROM

(

SELECT dbo.idtoname(eid) [Name],eid,

CAST(acyear AS char(4))

+CASE WHEN rotation>=10 THEN CAST(rotation AS char(2)) ELSE '0'+CAST(rotation AS char(1)) END [Period],

@acyear acyear,rotation,pgy,dbo.idtoTrainPrg(eid) Program,w.srvcode,

schrecid,conftype,0 a,0 b,0 c,0 d,0 e,shortname,hosp,abbrev

FROM schedule s, serviceward w,

(SELECT DISTINCT conftype FROM confattnsrvrate WHERE acyear=@acyear) c

WHERE acyear=@acyear

AND s.srvcode=w.srvcode

) t )
Mar 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
3
by: ¤ Alias | last post by:
I have a function named getID3info (lvwDiscInfo.SelectedItem). What is the difference between getID3info (lvwDiscInfo.SelectedItem) and Call getID3info(lvwDiscInfo.SelectedItem) ?
10
by: Ken VdB | last post by:
Hi everyone, Is there a reason why the Mid() function only works in one direction in VBScript? This code works in VB6 but not in VBScript? Is there a way around it? I am trying to create an...
14
by: dover | last post by:
/*Copy the line a token at a time into the output*/ copy(istream_iterator<string>(iss), istream_iterator<string>(), ostream_iterator<string>(oss, " ")); What's the meaning of this statement?...
7
by: Corepaul | last post by:
Missing Help Files When I enter "recordset" as the keyword and search the Visual Basic Help index, I get many topics of interest in the resulting list. But there isn't any information available...
7
by: Csaba Gabor | last post by:
I feel like it's the twilight zone here as several seemingly trivial questions are bugging me. The first of the following three lines is a syntax error, while the last one is the only one that...
11
by: 313 Games | last post by:
hi, ive got a question. im making an chat program with server and client using vb 6. but now my problem is, i want to set a topic in each server. i want to send the data from the server to all...
5
by: HSeganfredo | last post by:
Hello again, I´ve made a small substring() function that shoudl give back the a susbtring from a string, given its start and end positions. Is there any chance of the code below give an output...
26
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.