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

Cant get DECLARE to work for sproc


I created a sproc with 3 input parameters and one output parameter.

I want to test it in the "Run SQL Scripts" app of Navigator.

I wrote this code:

DECLARE RTNDATE CHAR(10) DEFAULT '';
CALL MANLIB.MANDATCL('ADD','20060101','1',RTNDATE)
SELECT MYVAR;
The problem is the first line, where I declare my output parameter.

When I try to run it, the SQL error is:
DECLARE RTNDATE CHAR(10) DEFAULT ''
SQL State: 42601
Vendor Code: -199
Message: [SQL0199] Keyword CHAR not expected. Valid tokens: DYNAMIC
SENSITIVE ASENSITIVE INSENSITIVE. Cause . . . . . : The keyword CHAR
was not expected here. A syntax error was detected at keyword CHAR.
The partial list of valid tokens is DYNAMIC SENSITIVE ASENSITIVE
INSENSITIVE. This list assumes that the statement is correct up to the
unexpected keyword. The error may be earlier in the statement but the
syntax of the statement seems to be valid up to this point. Recovery .
.. . : Examine the SQL statement in the area of the specified keyword.
A colon or SQL delimiter may be missing. SQL requires reserved words
to be delimited when they are used as a name. Correct the SQL statement
and try the request again.

Processing ended because the highlighted statement did not complete
successfully

--
Texeme Construct
Aug 29 '06 #1
6 7645
John Bailo wrote:
I created a sproc with 3 input parameters and one output parameter.

I want to test it in the "Run SQL Scripts" app of Navigator.

I wrote this code:

DECLARE RTNDATE CHAR(10) DEFAULT '';
CALL MANLIB.MANDATCL('ADD','20060101','1',RTNDATE)
SELECT MYVAR;
The problem is the first line, where I declare my output parameter.

When I try to run it, the SQL error is:
DECLARE RTNDATE CHAR(10) DEFAULT ''
You can't declare a variable in SQL Script processor, nor in STRSQL
either. If you look at the SQL Reference for Declare Variable, under
Invocation, it reads:

Invocation
This statement can only be embedded in an
application program. It is not an executable
statement. It must not be specified in Java or REXX.

>
SQL State: 42601
Vendor Code: -199
Message: [SQL0199] Keyword CHAR not expected. Valid tokens: DYNAMIC
SENSITIVE ASENSITIVE INSENSITIVE. Cause . . . . . : The keyword CHAR
was not expected here. A syntax error was detected at keyword CHAR.
The partial list of valid tokens is DYNAMIC SENSITIVE ASENSITIVE
INSENSITIVE. This list assumes that the statement is correct up to the
unexpected keyword. The error may be earlier in the statement but the
syntax of the statement seems to be valid up to this point. Recovery .
. . : Examine the SQL statement in the area of the specified keyword.
A colon or SQL delimiter may be missing. SQL requires reserved words
to be delimited when they are used as a name. Correct the SQL statement
and try the request again.

Processing ended because the highlighted statement did not complete
successfully

--
Texeme Construct
Aug 29 '06 #2
Jonathan Ball wrote:
DECLARE RTNDATE CHAR(10) DEFAULT ''
Invocation
This statement can only be embedded in an
application program. It is not an executable
statement.
Looks like I found a workaround. I just put in null for the output
parameter and the Run SQL Scripts message window will show the value of
the parameter.

So, it looks like:
CALL MANLIB.MANDATCL('ADD','08/01/2006','30',null)
Output Parameter #31 = 20060831

Statement ran successfully
--
Texeme Construct
Aug 29 '06 #3
John Bailo wrote:
Jonathan Ball wrote:
>DECLARE RTNDATE CHAR(10) DEFAULT ''
> Invocation
This statement can only be embedded in an
application program. It is not an executable
statement.

Looks like I found a workaround. I just put in null for the output
parameter and the Run SQL Scripts message window will show the value of
the parameter.

So, it looks like:
CALL MANLIB.MANDATCL('ADD','08/01/2006','30',null)

Output Parameter #31 = 20060831

Statement ran successfully
Interesting. Out of curiosity what happens when you use a question mark
(?) ?
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 30 '06 #4
John Bailo wrote:
Jonathan Ball wrote:
DECLARE RTNDATE CHAR(10) DEFAULT ''
Invocation
This statement can only be embedded in an
application program. It is not an executable
statement.

Looks like I found a workaround. I just put in null for the output
parameter and the Run SQL Scripts message window will show the value of
the parameter.

So, it looks like:
CALL MANLIB.MANDATCL('ADD','08/01/2006','30',null)

Output Parameter #31 = 20060831

Statement ran successfully
You could put any value you want in there, and it would work the same
way. It's an output parameter, so the data type doesn't matter.

I did a quick test:

create procedure ball.jbacounts
(company in char(2), cocount out smallint) language sql
set cocount =
(select count(*)
from chevals.jbaautsapp
where dft_company = company);

Then I ran:

call ball.jbacounts ('42', null)

call ball.jbacounts ('42', 1)

call ball.jbacounts ('42', 'howdy doody')
They all resulted in:

Output Parameter #11 = 7047

Aug 30 '06 #5
Serge Rielau wrote:
John Bailo wrote:
Jonathan Ball wrote:
DECLARE RTNDATE CHAR(10) DEFAULT ''
Invocation
This statement can only be embedded in an
application program. It is not an executable
statement.
Looks like I found a workaround. I just put in null for the output
parameter and the Run SQL Scripts message window will show the value of
the parameter.

So, it looks like:
CALL MANLIB.MANDATCL('ADD','08/01/2006','30',null)
Output Parameter #31 = 20060831

Statement ran successfully
Interesting. Out of curiosity what happens when you use a question mark
(?) ?
Same result.

Aug 30 '06 #6
Jonathan Ball wrote:
Serge Rielau wrote:
>John Bailo wrote:
>>Jonathan Ball wrote:

>DECLARE RTNDATE CHAR(10) DEFAULT ''
Invocation
This statement can only be embedded in an
application program. It is not an executable
statement.

Looks like I found a workaround. I just put in null for the output
parameter and the Run SQL Scripts message window will show the value of
the parameter.

So, it looks like:

CALL MANLIB.MANDATCL('ADD','08/01/2006','30',null)

Output Parameter #31 = 20060831

Statement ran successfully
Interesting. Out of curiosity what happens when you use a question mark
(?) ?

Same result.
Good to know. I don't think the CLP of DB2 for LUW allows anything but a
? for a pure OUT parameter.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Aug 30 '06 #7

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

Similar topics

12
by: scott | last post by:
In LISTING 2, I have a SPROC that returns a recordset and a recordcount in SQL QA. I can access the Recordset with no problem. How can I grab the Recordcount with ASP code at the same time I'm...
4
by: Radu | last post by:
Hi. It seems to be very simple, actually, but I don't know if it is feasible in TSQL. I have a sproc which gathers in one place many calls to different other sprocs, all of them taking a...
5
by: Jiggaz | last post by:
Hi, Look my stored procedure : __________________ ALTER PROCEDURE dbo.CreateAccount @Nickname varchar(30), @Password varchar(15), @Email varchar(50), @Date datetime,
1
by: P | last post by:
Hello, I am having a difficult time updating a record via a stored procedure using the gridview and sqldatasource. I cannot seem to be able to find a way to set everything up so that I can pass...
4
by: Chad Micheal Lawson via .NET 247 | last post by:
I'm stumped at this point and I'm tired of trying things so I'mposting in hopes of some guru with a sharp eye. I have anasp.net app running on a local Win XP Pro box. Within the app,I call a SPROC...
2
by: andrewanderson | last post by:
hi can anyone help me with this prog. cant find the prob why it cant display cout<<"This is the display of your transaction"<<endl; ifstream fobj; //declare input file stream ...
5
by: =?Utf-8?B?UlBhcmtlcg==?= | last post by:
I used the wizard to generate a typed dataset for my table and let it create my SPROCs. It created everything, and the GetData() method and the custom GetByUserName query works great, but when I...
1
by: Looch | last post by:
Hi All, I originally wrote a sproc with one of the parameters set as SqlDBType.nvarchar,8. The parameter in the sproc was defined as 8 cahracters and the column in the table was also set to...
4
zachster17
by: zachster17 | last post by:
Hi everyone, Is there anyway to run a sql server stored procedure from access (using the ADODB.Command object) without locking up the access application? For example, I want a list to populate...
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
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,...
0
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...
0
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...

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.