Does Netezza support the Cursor declaration like in PL/SQL - netezza

Does Netezza support the Cursor declaration like in PL/SQL?
I believe, FOR Loops does support a select query. But do we have any explicit way to define a cursor in Netezza?

Netezza has a construct called RECORDS. It has limited per-record capabilities. Documentation is available here.
https://www.ibm.com/docs/en/netezza?topic=grammar-records

Related

Questions in Sybase lag and over by concept

I have table like this below in my sybase database
ID,Col1,Col2
1,100,300
2,300, 400
3,400,500
4,900,1000.
I want result like this below only in sybase.
1,100,500 --- cross interrow checking the values
2,900,1000.
SInce you did not specify which database you're using, I'm assuming your using Sybase ASE (rather than Sybase IQ or Sybase SQL Anywhere, which do support lag/lead etc.)
Also it's not quite clear what you want since you have not defined how the relation between the various rows and columns should be interpreted. But I'm guessing you're essentially hinting at a dependency graph between Col2->Col1.
In ASE, you'll need to write this as a multi-step, loop-based algorithm whereby you determine the dependency graph. Since you don't know how many levels deep this will run, you need a loop rather than a self-join. You need to keep track of the result in a temporary table.
Can't go further here... but that's the sort of approach you'll need.

how to write insert stored procedure when tablename and columnnames are unknown?

i want to write a stored procedure in SQL server that will insert records to database in which i want to pass table-name and column-names with their values as arguments to the stored procedure.
i am using asp.net three-tier technology if that helps.
if it's impossible than please tell me some alternatives.
thanks in advance
The best answer is "Don't Do That!"
A relational database is best used for modelling.... relationships and to do that you need to have bounds and a design about what data you are going to store. That means that you (or your ORM) will know what the underlying tables look like.
If you want a place to simply throw objects at then think about using a nosql document store like MongoDB instead.
Build your SQL in a NVARCHAR dynamically, and pass it to stored procedure sp_executesql:
DECLARE #sql NVARCHAR(MAX);
-- build your SQL in the NVARCHAR
EXEC sp_executesql #sql;
This is possible in theory but I’m afraid that’s not really the best solution.
Issues with this approach is that you don’t know many parameters upfront such as column names, how many column names exist, what is their type and such.
This means that you would have to pass parameters as some default type for example nvarchar and then convert this type to specific column type which can lead to performance and other issues.
I’d suggest you try using Entity framework or some other ORM tool to handle inserts for you.

dynamic insertion with xml or stored procedure

I have 20 record group that i need to batch insert them all in one connection so there is two solution (XML or stored procedure). this operation frequently executed so i need fast performance and least overhead
1) I think XML is performs slower but we can freely specify how many record we need to insert as a batch by producing the appropriate XML, I don't know the values of each field in a record, there maybe characters that malformed our XML like using " or filed tags in values so how should i prevent this behavior ?
2) using stored procedure is faster but i need to define all input parameters which is boring task and if i need to increase or decrease the number of records inserted in a batch then i need to change the SP
so which solution is better in my environment with respect to my constrains
XML is likely the better choice, however there are other options
If you're using SQL Server 2008 you can use Table Valued parameters instead.
Starting with .NET 2.0 you had the option to use the SQLBulkCopy
If you're using oracle you can pass a user defined type but I'm not sure what versions of ODP and Oracle that works with.
Note these are all .NET samples. I don't know that this will work for you. It would probably help if you include the database and version and client technology that you're using.

Is it possible to force Business Objects 6.5 to create proper ANSI joins?

The SQL that Business Objects generates seems to be stuck in a bygone era for SQL joins -- it insists on using the old Sybase outer-join syntax (*=, etc.), which is illegal in SQL Server 2005 when running at level 90. Is there an option somewhere to make it use modern join syntax (i.e., joining using the JOIN keyword rather than using commas in the FROM statement)?
From memory, there's a universe parameter called ANSI92 that does exactly what you want.

SQL Server Common function for getting max(id)

In my application many I time we use MAX(). How can I write a common function where I can pass table name and column name and get MAX().
I mean single function for any table/field.
Thanks,
Tanmay.
In MSSQL there are no particularly elegant ways to use UDFs with dynamic table/field names, so personally I would just stick to a simple SELECT MAX().
If the IDs are IDENTITY columns you can just use IDENT_CURRENT('the_table')

Resources