472,805 Members | 944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 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 1764
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) ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.