473,387 Members | 1,592 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,387 software developers and data experts.

Very simple Table Function in a View failing when queried ? ....

Can anybody tell me why the select of the following fails ??

--(run'able SQL)
create function f(p_i integer)
returns table (i integer)
begin atomic
declare v_i integer default 1;
declare v_v varchar(10) default 'N';

return select v_i from sysibm.sysdummy1;
--return values (v_i);
end;

create view y as select i from table(f(1)) as f;

select * from y;
[IBM][CLI Driver][DB2/LINUX] SQL0344N The recursive common table
expression "DB2JBSI2.Y" has mismatched data types, lengths or code
pages for column "I". SQLSTATE=42825

There seems to be a fundamental problem returning SQL variables from
Table
functions referenced in views ??

Thanks.

Paul.
Nov 12 '05 #1
2 1336
I can repro, will get back to you. Looks like a bug at first glance.

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2
Guilty as charged, I bow my head in shame.

The DEFAULT 1 from the variable declaration propagated all the way to view.
Since the table function was not expanded when the view was created the
select gets confused because of the sudden appearance.
Fix will be in FP7. Open an APAR and tell support to to route straight
to me if you need a fix before then.

The workaround is to not use the default and have a separate SET
statement. Or to use an expression in teh RETURN insetad of the variable
straight (like var + 0)

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3

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

Similar topics

4
by: Little PussyCat | last post by:
Hello, I have had a request, one of our tables is used as a report and I have been asked that all fieldnames for months have dashes in them, like Jan-05 instead of Jan05 and so on... Now what...
3
by: Jofio | last post by:
My PHP code to read a simple text file is listed below. What could have gone wrong here? When I run it, the browser displays: 'COULD NOT Read' opton of the fread() function. I thought the code was...
1
by: Juris Krumins | last post by:
Couple a weeks ago (19.08.03 Subject: Temporaty tables) I've posted message with question about errors I'm getting while using create temporaty table command. So I'm start digging in src code as...
5
by: Paul Reddin | last post by:
Hi, using ROWNUMBER() is affecting the plan of a view very badly... is there a way of writing the following view to ensure rownumber() is done as the last thing done? i.e after the calling...
0
by: roiavidan | last post by:
Hi, I'm having a bit of a problem with a small application I wrote in C#, which uses an Access database (mdb file) for storing financial data. After looking for a similiar topic and failing to...
14
by: Steve | last post by:
Sorry in advance for my ignorance. Any help would sure be appreciated. I'm writing a fairly simple application with VB.Net and am obviously a bit of a newbie. This application will be used by 1,...
2
by: dbuchanan52 | last post by:
Hello, I am building an application for Windows Forms using. I am new to SQL Server 'Views'. Are the following correct understanding of their use? 1.) I believe a view can be referenced in a...
1
by: Sibongile Khanyile | last post by:
If anyone can help... I have a function that takes one parameter and bring back quite a lot of records. but with a conventional function the field size has a limit of 8000 and i can not use field...
0
debasisdas
by: debasisdas | last post by:
This thread contains some useful tips for using External tables. USING EXTERNAL TABLE ======================= 1.THE TABLE POINTS TO EXTERNAL FILE. IF DATA IS ALTERED IN THE EXTERNAL FILE,DATA...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.