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

Can I pass a parameter from a stored procedure to a table function that is joining on other tables?

I am trying to create a stored procedure that accepts 3 parameters.
Using these parameters I am joining on 2 tables and a UDF that accepts
these 3 parameters to get movement information. When I try to pass
these parameters in the function for each parameter I get and SQL0206
'Position # Column &1 not in specified table'. I am using DB2 on an
AS/400 running V5R2 for the operating system. I will post a n example
below.

CREATE PROCEDURE AFFOOD.AFM_SPGETWHSEDETAIL (
IN IFSCALYEARB INTEGER ,
IN IFSCALYEARE INTEGER ,
IN IFSCALMONTH INTEGER )
DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC AFFOOD.AFM_SPGETWHSEDETAIL
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT
P1 : BEGIN
DECLARE CURSOR1 CURSOR WITH RETURN FOR
Select B.FFIITMN,SUBSTRING(CAST(D.FFJTIHI AS CHAR(4)),3,2) AS IVTIER,
E.HHBPQ08 from (((IDSTEST.FFIITMAP B INNER JOIN IDSTEST.FFJITMBP D ON
FFIITMN=FFJITMN AND FFIDPTN=FFJDPTN) INNER JOIN
TABLE(AFFOOD.AFM_UDFGETFINALMOVEMENT(IFISCALYEARE, IFISCALYEARE,IFISCALYEARE))
AS E ON B.FFIITMN=E.HHBITMN) INNER JOIN AFFOOD.LIEEEITM C ON
B.FFIITMN=C.EEEITMN) WHERE TRIM(FFICMPN)='1' AND TRIM(FFIDIVN)='1' AND
TRIM(FFIDPTN)='1' ORDER BY B.FFIITMN ;

OPEN CURSOR1 ;

END P1 ;

Any help is greatly appreciated. Thanks.

Nov 12 '05 #1
2 1790
I forgot to add that I can call the udf sucessfully if I just put in
constants instead of variables. It works fine if I do it through SQL
Server using SQL Server syntax for both. Thanks Again.

Nov 12 '05 #2
jl******@gmail.com wrote:
I am trying to create a stored procedure that accepts 3 parameters.
Using these parameters I am joining on 2 tables and a UDF that accepts
these 3 parameters to get movement information. When I try to pass
these parameters in the function for each parameter I get and SQL0206
'Position # Column &1 not in specified table'. I am using DB2 on an
AS/400 running V5R2 for the operating system. I will post a n example
below.

CREATE PROCEDURE AFFOOD.AFM_SPGETWHSEDETAIL (
IN IFSCALYEARB INTEGER ,
IN IFSCALYEARE INTEGER ,
IN IFSCALMONTH INTEGER )
DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC AFFOOD.AFM_SPGETWHSEDETAIL
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT
P1 : BEGIN
DECLARE CURSOR1 CURSOR WITH RETURN FOR
Select B.FFIITMN,SUBSTRING(CAST(D.FFJTIHI AS CHAR(4)),3,2) AS IVTIER,
E.HHBPQ08 from (((IDSTEST.FFIITMAP B INNER JOIN IDSTEST.FFJITMBP D ON
FFIITMN=FFJITMN AND FFIDPTN=FFJDPTN) INNER JOIN
TABLE(AFFOOD.AFM_UDFGETFINALMOVEMENT(IFISCALYEARE, IFISCALYEARE,IFISCALYEARE))
AS E ON B.FFIITMN=E.HHBITMN) INNER JOIN AFFOOD.LIEEEITM C ON
B.FFIITMN=C.EEEITMN) WHERE TRIM(FFICMPN)='1' AND TRIM(FFIDIVN)='1' AND
TRIM(FFIDPTN)='1' ORDER BY B.FFIITMN ;

OPEN CURSOR1 ;

END P1 ;


Is there an extraneous 'I' in the UDF parameter names?
TABLE(AFFOOD.AFM_UDFGETFINALMOVEMENT(IFISCALYEARE, IFISCALYEARE,IFISCALYEARE))

IFISCALYEARE -> IFSCALYEARE
^

--
Karl Hanson
Nov 12 '05 #3

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

Similar topics

4
by: Dan | last post by:
I've run into an interesting problem, and seemed to have stumped 3 newsgroups and 2 other forums. For some reason when I try to insert a record into a SQL table that has a Text column, the...
1
by: Sandie Towers | last post by:
We use a number of similar databases and frequently create a new database using a backup restore of another similar database. We try to keep changes between databases in _Additional tables - like...
2
by: KG | last post by:
Hi , I am looking for meta-information about the return recordset of a stored-procedure. The procedure returns a resultset that contains columns of more tables joined together. In all tables, I...
3
by: Mariusz | last post by:
I want to write function to call another function which name is parameter to first function. Other parameters should be passed to called function. If I call it function('f1',10) it should call...
2
by: Nelson Xu | last post by:
Hi All Does anyone knows how to pass an array from .net application to oracle stored procedure Thank you in advance Nelson
3
by: dk | last post by:
Hi all, Would appreciate some advice on the following: I am trying to speed up an Access database connected to a SQL Server back-end. I know I can use a pass-through query to pass the sql...
15
by: Steve | last post by:
I am trying to develop a stored procedure for an existing application that has data stored in numerous tables, each with the same set of columns. The main columns are Time and Value. There are...
7
by: ashtek | last post by:
Hi, I have a generic function that executes a stored procedure & returns a data table. Code: === public static DataTable ExecuteStoredProcedure(string strProc,SqlParameter paramArray) {...
12
by: ArunDhaJ | last post by:
Hi Friends, Is it possible to pass a table as a parameter to a funtion. whos function declaration would look some thing like this.... ALTER FUNCTION TempFunction (@TempTable TABLE, @nPId INT) ...
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...
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
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.