Does Interbase 6 database support passing array parameter to stored procedure? If yes what is the syntax of declaring such variable and using it in the body of procedure?
It looks like even the current version of IB does not support array parameters.
The documentation includes an example of processing array data within the stored procedure to flatten it out, then passing several flat records out of the stored procedure. Of course you could do all this in IB 6 as well.
This example is in the Data Definition manual for XE. See Using stored procedures.
The Interbase documentation on this topic may be useful.
Related
I'm fairly new to stored procedure. I have to design a stored procedure for ATOMIC insert (Mass insert). I'm using COBOL program to call the stored procedure in DB2. I will store values in array and have to insert all at one shot. Below is the query we are using in COBOL program and which I have to convert to stored procedure.
INSERT INTO TABLE_NAME
(COLUMN1
,COLUMN2
,COLUMN3
,COLUMN4
,COLUMN5)
VALUES
(VALUE1
,VALUE2
,VALUE3
,VALUE4
,VALUE5)
FOR WS-SUB ROWS
ATOMIC
VALUE1,VALUE2,VALUE3,VALUE4,VALUE5 are array elements and WS-SUB is number of occurrence.
I want to know, If I can handle array in stored procedure or want to know if its possible to do ATOMIC insert in DB2 stored procedure.
Thanks in advance.
Following the documentation for DB2 on z/OS 12.0.0:
A DB2 Stored Procedure may be configured to use arrays as parameter types, see Example of using arrays in an SQL procedure.
However, if your intention is calling this from COBOL you may run into issues as the documentation for Supported SQL data types in COBOL embedded SQL applications indicates:
Arrays are not supported by the COBOL precompiler
Another approach would be to pass your data as something like a CLOB or VARCHAR delimited by a character and then parse it within your stored procedure.
By default DB2 Stored Procedures does not commit on return, so another option would be to iterate your COBOL tables and call the stored procedure repeatedly.
I'm trying to pass an array of JSON objects to the Stored procedure, so that each JSON object will be stored in a single row of the table.
for an example:
to insert a single entry: INSERT INTO SCHEMA_NAME.TABLE_NAME (id,name) values (1,'my_name')
now i have an array of such data which I want to push into stored procedure to get all data inserted into table without hitting SP again and again.
array example: [{id:1,name:'name1'},{id:2,name:'name2'}]
now i can have number of object to be stored.
so either i would hit the SP again and again to push each object individually or i would pass whole array and run a loop inside a stored procedure to get it done.
I have DB2 10.5 LUW with fixpack 7 installed and using node.js
DB2 10.5 does not support JSON as a native data type, so you won't be able to do this without passing the JSON as a VARCHAR and having the stored procedure parse/deconstruct the JSON. The obvious way to do this would with a C or Java stored procedure.
That said, there are some JSON capabilities (see this series of articles for more details, but this is almost certainly not what you want.
I am using SQL Server 2012 and trying to write a stored procedure that will have two components:
1. Select statement that will return several rows
2. Another component will have an aggregated value based on some conditions.
So, for the second component, I am thinking to declare a variable in the stored procedure and store the aggregated data there.
Now, my question is can I populate my output parameter with the data stored in previously declared variable and access the parameter from SSRS 2012?
I would appreciate any suggestion(s) to get me started.
Thank you
I have a stored procedure mapped ok in the EDMX to retrieve a ObjectResult<> of entities.
However I'm trying to get an additional column from the stored procedure that is the total rows.
I'm using this http://forums.asp.net/post/3000198.aspx variantion to get the total rows, which is working nicely. So I don't particularly want to use output parameters.
Is there anyway of both mapping the entity and getting ahold of the additional columns?
I'm using EF 4.3.1 database first, so I'm taking a look at the generated context file.
I think the trouble is that ObjectContext.ExecuteFunction is strongly typed, so I'm unsure how to get the additional columns. Is there perhaps a way of executing the stored procedure directly and get the mapping?
Let's say I have 'myStoredProcedure' that takes in an Id as a parameter, and returns a table of information.
Is it possible to write a SQL statement similar to this?
SELECT
MyColumn
FROM
Table-ify('myStoredProcedure ' + #MyId) AS [MyTable]
I get the feeling that it's not, but it would be very beneficial in a scenario I have with legacy code & linked server tables
Thanks!
You can use a table value function in this way.
Here is a few tricks...
No it is not - at least not in any official or documented way - unless you change your stored procedure to a TVF.
But however there are ways (read) hacks to do it. All of them basically involved a linked server and using OpenQuery - for example seehere. Do however note that it is quite fragile as you need to hardcode the name of the server - so it can be problematic if you have multiple sql server instances with different name.
Here is a pretty good summary of the ways of sharing data between stored procedures http://www.sommarskog.se/share_data.html.
Basically it depends what you want to do. The most common ways are creating the temporary table prior to calling the stored procedure and having it fill it, or having one permanent table that the stored procedure dumps the data into which also contains the process id.
Table Valued functions have been mentioned, but there are a number of restrictions when you create a function as opposed to a stored procedure, so they may or may not be right for you. The link provides a good guide to what is available.
SQL Server 2005 and SQL Server 2008 change the options a bit. SQL Server 2005+ make working with XML much easier. So XML can be passed as an output variable and pretty easily "shredded" into a table using the XML functions nodes and value. I believe SQL 2008 allows table variables to be passed into stored procedures (although read only). Since you cited SQL 2000 the 2005+ enhancements don't apply to you, but I mentioned them for completeness.
Most likely you'll go with a table valued function, or creating the temporary table prior to calling the stored procedure and then having it populate that.
While working on the project, I used the following to insert the results of xp_readerrorlog (afaik, returns a table) into a temporary table created ahead of time.
INSERT INTO [tempdb].[dbo].[ErrorLogsTMP]
EXEC master.dbo.xp_readerrorlog
From the temporary table, select the columns you want.