473,587 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can we create UDF using View instead of table

Hi everybody!
I have a UDF. It is working fine.
But when i try apply the same UDF to a view it is not working.
CREATE VIEW SSN_SORTED AS
WITH TEMP(EMP#,SOCSE C#,JOB_FTN,DEPT ,SALARY,DATE_BN ,FST_NAME,LST_N AME) AS
(SELECT MAX(EMP#),MAX(S OCSEC#),MAX(JOB _FTN),MAX(DEPT) ,MAX(SALARY),MA X(DATE_BN)
,MAX(FST_NAME), MAX(LST_NAME)
FROM PERSONNEL
GROUP BY SOCSEC#
FETCH FIRST 20000 ROWS ONLY)
SELECT * FROM TEMP;

Here is UDF fow paging this veiw:
CREATE VIEW SSN_SORTED AS
WITH TEMP(EMP#,SOCSE C#,JOB_FTN,DEPT ,SALARY,DATE_BN ,FST_NAME,LST_N AME) AS
(SELECT MAX(EMP#),MAX(S OCSEC#),MAX(JOB _FTN),MAX(DEPT) ,MAX(SALARY),MA X(DATE_BN)
,MAX(FST_NAME), MAX(LST_NAME)
FROM PERSONNEL
GROUP BY SOCSEC#
FETCH FIRST 20000 ROWS ONLY)
SELECT * FROM TEMP;

UDF example of use:
SELECT * FROM TABLE(GET_PAGES _SSN('000-00-0000'))
FETCH FIRST 20 ROWS ONLY;

sqlcode: -440
No authorized routine named "GET_PAGES_ SSN" of type "FUNCTION
" having compatible arguments was found.
Here is same UDF working without any problem with Tables:

CREATE FUNCTION GET_PAGES(PAGE_ NO INTEGER,LINES INTEGER)
RETURNS TABLE ( EMP# INTEGER
,SOCSEC# CHAR(11)
,JOB_FTN CHAR(4)
,DEPT SMALLINT
,SALARY DECIMAL(7,2)
,DATE_BN DATE
,FST_NAME VARCHAR(20)
,LST_NAME VARCHAR(20)
)
RETURN
Select *
from
PERSONNEL
where
INTEGER(SUBSTR( (CHAR(EMP#)),1, 7)) >= LINES * (PAGE_NO - 1) + 1000000;

EXAMPLE OF USE
SELECT * FROM TABLE(GET_PAGES (3,12))
FETCH FIRST 12 ROWS ONLY;
EMP# SOCSEC# JOB_FTN DEPT SALARY DATE_BN FST_NAME
LST_NAME
----------- ----------- ------- ------ --------- ---------- -----------------
--- --------------------
2000000 182-27-6668 WKR 27 12712.08 02/04/1973 Fehdcd
Eamitaaa
2000001 360-75-6667 WKR 33 12739.97 02/04/1973 Tjiddd
Jeiitaya
2000002 223-88-6663 WKR 20 3143.58 01/01/1978 Xffabc
Feabaimm
2000003 599-41-6664 WKR 18 4255.15 01/02/1977 Jpebbb
Piybeabb
............... ............... ............... ............... ............... ...
............... ............... ............... ...........
Thank's in advance.

--
Message posted via DBMonster.com
http://www.dbmonster.com/Uwe/Forums....m-db2/200809/1

Sep 6 '08 #1
2 2871
>SELECT * FROM TABLE(GET_PAGES _SSN('000-00-0000'))
FETCH FIRST 20 ROWS ONLY;

sqlcode: -440
No authorized routine named "GET_PAGES_ SSN" of type "FUNCTION
" having compatible arguments was found.
You did not describe any function named get_pages_ssn(V ARCHAR()) in your
post.
Only get_pages(integ er, integer)

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Sep 7 '08 #2
Thank you Serge.
I fixed and it is working.

Serge Rielau wrote:
>>SELECT * FROM TABLE(GET_PAGES _SSN('000-00-0000'))
FETCH FIRST 20 ROWS ONLY;

sqlcode: -440
No authorized routine named "GET_PAGES_ SSN" of type "FUNCTION
" having compatible arguments was found.

You did not describe any function named get_pages_ssn(V ARCHAR()) in your
post.
Only get_pages(integ er, integer)

Cheers
Serge
--
Message posted via http://www.dbmonster.com

Sep 8 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1779
by: kackson | last post by:
Hi. I created a simple view with the following statements: CREATE VIEW dbo.VIEW1 AS SELECT dbo.VIEW_ALL.ID, dbo.VIEW_ALL.Code, Another.dbo.OTHER_VIEW.Label as SpecialCode FROM dbo.VIEW_ALL LEFT OUTER JOIN
1
1850
by: aur56 | last post by:
I am using stringbuilder to create a html email message that is basically a two column table with the field name in one column, and the field value in another, and about 30 rows. I don't get any errors when the code runs, but there seems to be always one field that has the wrong background color, or has a "!" in the text of the e-mail message. On the e-mail message, when I click "View Source", I see that at the end of many rows, there is...
6
12269
by: Bruce | last post by:
I want to create a new table based on an existing table, but I don't want the tables to have any enforced relationship. Is this possible without having to do a CREATE TABLE and an INSERT? create table customer_Temp as (select credit_Card_number, personal_id_number from customer) DATA INITIALLY DEFERRED REFRESH deferred; refresh table customer_temp;
7
8841
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
10
8788
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung other things, can create views based on existing tables and a table of column name equivalents. If I accidently introduce a column name equivalent that is the same as another column, I end up with a CREATE VIEW SQL statement that is in error, if...
2
8925
by: Curtiosity | last post by:
I have done a create or replace view called creditcard1. If I do a "select * from creditcard1" it retrieves the data just fine. If I try to do a statement where I am listing the column names it doesn't recognize them. create or replace view creditcard1 as select pidm ,tbraccd_term_code as "Term" ,tbraccd_detail_code as "Detail_Code" ,tbbdetc_desc as "Detc_Desc" ,tbraccd_tran_number as "Tran_Number" ,DECODE(tbbdetc_type_ind,...
2
35105
by: Shirley | last post by:
We are running DB2 on iSeries V5R2. Using AQUA DATA STUDIO with a connection to our iSeries, I created a view using SQL and I am trying to create an index on this view using the code below. CREATE INDEX reports.Ivendorname ON reports.transbyvendor05 (vendorname) However I get the following error:
4
22698
by: cognosqueen | last post by:
I need to create a view of a sql table, but change the data types. I know the syntax below is not correct, and can't figure out if it is wrong or if you just can't do this. I have only created views before with the same data type. CREATE VIEW F0005New(DRKY nchar(3), DRDL01 nchar(30)) INSERT (SELECT rtrim(F0005.DRKY), F0005.DRDL01 FROM F0005 AS F0005 WHERE DRSY = '41' AND DRRT = 'S1')
3
3965
by: suek | last post by:
I have a table with over 4000 records to search upon, and the users don't like a combo box. So what I have been trying to do for the last twelve hours is do some code to get a text box to search. I am learning fast, but I really don't know how to do it, and would appreciate some help. So far I have got to this: Private Sub btnSearch_Click() Dim strFindLocation As String
0
8219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7978
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.