SQL Server 2000 Output Parameters - stored-procedures

I have created a stored procedure in SQL Server 2000 and within the stored procedure I have created a number of variables that I want to return to the asp classic script.
I have tried declaring the variable like this:
DECLARE #output int OUTPUT
But SQL Server then says that I cannot declare an output variable that way.
So instead, I declared the variable at the beginning of the stored procedure along with the parameters that I am passing from my ASP script. This seems to work but my ASP script now reports an error saying that the stored procedure is expecting certain parameters.
Should I add these parameters into my command object and pass them as NULLs or is there another way to do this.
Thanks

There's a couple of things you need to do:
1) make sure you've defined the OUTPUT parameter in the stored procedure correctly e.g.
CREATE PROCEDURE dbo.ExampleSproc
#output INTEGER OUTPUT
AS
...
2) when calling the sproc from ASP, you need to add the #output parameter to the command, as an output parameter (adParamOutput)

Related

How to create a strong typed sql statement returning multiple result sets

Currently I am using a stored procedure returning multiple result sets. I set up a test and found that the result of the stored procedure can efficiently be read by using the "ExecuteReader" method of the DataConnection class and then Executing or Querying the DataReader.
The problem with this approach is that there is no tight coupling between Code and Stored Procedure. So I would like to replace the Stored Procedure by a Linq2db expression that produces a sql statement with multiple select statements. The ExecuteReader method is expecting a string sql parameter. How can the Sql string be constructed based on a DataConnection object that has knowledge of my Database schema. Is this feature somehow implemented in linq2Db.

Avoiding hard coding Schema in DB2/400 Stored Procedure

I'm creating Stored Procedures to replace Legacy app programs for an IBM i. I'm calling the stored procedure from a Java Web App. I'm using the jt400 JDBC driver
My JDBC URL is jdbc:as400://myhost/;libraries=*LIBL,MYLIB;prompt=false
The stored procedures can call stored procedures
The initial stored procedure call completes normally if it does not make further stored procedure calls
If the stored procedure makes a call to other stored procedures it fails with
com.ibm.as400.access.AS400JDBCSQLSyntaxErrorException: [SQL0204] MY_SP in MYLIB type *N not found.
If I hard code a schema in the stored procedure call statement, the call completes normally.
I want to have the called stored procedures use the same schema as the caller
You need to SET PATH = "MYLIB"
When I am using SQuirreL to call a stored procedure, I need to use the SET PATH statement to get it to find the stored procedure. I don't know if that is because my library list is bad or what, but the current schema is not used to find an unqualified stored procedure.
I actually had this same problem, the stored procedure uses your job description library list. You need to edit that you can use TAATOOL CHGLBLJOBD. I am not in front of an iSeries at the moment but I believe the command was either EDTJOBDLIB or EDTJOBDLIBL WRKJOBDLIBL. It is some variation of that.

Call stored procedure based on parameter from data in Crystal report

I am trying to achieve the following scenario using crystal report:
Call stored procedure from SQL server using parameter that is set from data in each row of table in crystal report. See illustration in the figure below:
Each stored procedure for each row will be executed based on value that is passed to stored procedure.
I have been trying to call stored procedure using Database expert, and use the field for stored procedure the same as I use the field from Tables.
The problem is the report will always ask the value for the parameters, as this approach will generate parameter fields based on the parameter that is defined in stored procedure. I want the parameter values to be set automatically based on the data in each row.
Please let me know whether it is possible to achieve this scenario using crystal report. For the information, I don't have access to the source code that generate this report. So, I have to do this on report file.

derby procedure that does not modify

I'm trying to create a trigger on derby which simply calls a procedure. The stored procedure does not change anything and gets no parameters. It simply check that the time is within an interval (for example between 08:00 and 16:00). On creation of trigger i receive the following error:
"42Z9D: Procedures that modify SQL data are not allowed in BEFORE triggers."
But the procedure makes no changes.
When defining a procedure one should specify if the procedure modifies data or not. If it executes any sql or not. As mentioned in the link provided above by Bryan I should use one the options:
{ NO SQL | MODIFIES SQL DATA | CONTAINS SQL | READS SQL DATA }
If you dont use this options the default value will be assumed that is CONTAINS SQL.

Value Displays when Running Stored Procedure in SSMS but not in SSRS

I have a stored procedure that uses table variables to create a query and runs perfectly when executing in SQL Server Management Studio. However, the column referring to this table variable does not display when running the stored procedure in Query Designer.
I have used this method on many other reports without issue, but cannot figure out why the value will display in SSMS and not in SSRS.
After a fresh nights sleep, I realized it was how a parameter was being passed to the Sub Stored Procedures. The main stored procedure had a where clause that contained a "LIKE #Parameter" but the Sub Stored Procedure contained an "= #Parameter", so when a "%" was passed into the parameter the main Stored Procedure returned results, but nothing was displayed from the Sub Stored Procedure.
Simply just a case of making my job harder on myself...

Resources