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

Is a statement like this possible: SELECT * FROM (CALL myProcedure)

I created a Stored Procedure like this:
CREATE PROCEDURE myProcedure(IN a_tabschema VARCHAR(20))
DYNAMIC RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE rs CURSOR WITH RETURN FOR
SELECT * FROM syscat.tables WHERE tabschema = a_tabschema;
OPEN rs;
END

If I make an CALL myProcedure('SYSIBM') I get an ResultSet

But can I also user the Result in a new Statement like
SELECT * FROM (CALL myProcedure('SYSIBM'));
?

On Question more: Is it possible to set the LIKE-operator
case-insensitive?

Greetings

Markus

Nov 12 '05 #1
5 3547

"Markus" <Th*********@Freenet.de> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I created a Stored Procedure like this:
CREATE PROCEDURE myProcedure(IN a_tabschema VARCHAR(20))
DYNAMIC RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE rs CURSOR WITH RETURN FOR
SELECT * FROM syscat.tables WHERE tabschema = a_tabschema;
OPEN rs;
END

If I make an CALL myProcedure('SYSIBM') I get an ResultSet

But can I also user the Result in a new Statement like
SELECT * FROM (CALL myProcedure('SYSIBM'));
?
No. To do this, what you really want to do is define a table function, and
use that in your SELECT.

For example (slightly abbreviated):

CREATE FUNCTION myFunction(a_tabschema VARCHAR(20))
LANGUAGE SQL
BEGIN
RETURN SELECT * FROM syscat.tables WHERE tabschema = a_tabschema;
END

Then in your application you can do this:

SELECT * FROM TABLE ( myFunction('SYSIBM') ) AS X;
On Question more: Is it possible to set the LIKE-operator
case-insensitive?


No.

--
Matt Emmerton
Nov 12 '05 #2
Markus wrote:
I created a Stored Procedure like this:
CREATE PROCEDURE myProcedure(IN a_tabschema VARCHAR(20))
DYNAMIC RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE rs CURSOR WITH RETURN FOR
SELECT * FROM syscat.tables WHERE tabschema = a_tabschema;
OPEN rs;
END

If I make an CALL myProcedure('SYSIBM') I get an ResultSet

But can I also user the Result in a new Statement like
SELECT * FROM (CALL myProcedure('SYSIBM'));
? Use an SQL Table function.

CREATE FUNCTION myFunction(a_tabschema VARCHAR(20))
RETURNS TABLE (TABSCHEMA VARCHAR(128), .....)
RETURN SELECT * FROM syscat.tables WHERE tabschema = a_tabschema;

SELECT * FROM TABLE(myFunction('Hello')) AS X
On Question more: Is it possible to set the LIKE-operator
case-insensitive?

No.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3
Markus wrote:
I created a Stored Procedure like this:
CREATE PROCEDURE myProcedure(IN a_tabschema VARCHAR(20))
DYNAMIC RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE rs CURSOR WITH RETURN FOR
SELECT * FROM syscat.tables WHERE tabschema = a_tabschema;
OPEN rs;
END

If I make an CALL myProcedure('SYSIBM') I get an ResultSet

But can I also user the Result in a new Statement like
SELECT * FROM (CALL myProcedure('SYSIBM'));
?

On Question more: Is it possible to set the LIKE-operator
case-insensitive?

Greetings

Markus

While the short answer to the second question is no, the sense can be
achieved by something like:

LOWER(attribute) LIKE LOWER(<query-string-containing-%-and/or-_>)

NB This can lead to extensive/expensive tablescans if it is the only
WHERE phrase; in that case CREATE a table/index with a second copy of
attribute with the lower already performed and CREATE an index on that.
Nov 12 '05 #4
Thanks at all for your answers - i'll try this at work. :-)

Markus

Nov 12 '05 #5
Bob Stearns wrote:
While the short answer to the second question is no, the sense can be
achieved by something like:

LOWER(attribute) LIKE LOWER(<query-string-containing-%-and/or-_>)

NB This can lead to extensive/expensive tablescans if it is the only
WHERE phrase; in that case CREATE a table/index with a second copy of
attribute with the lower already performed and CREATE an index on that.


And if you make that a GENERATED ALWAYS ... column, he optimizer can
automatically re-route to the additional column.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #6

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

Similar topics

7
by: William Morris | last post by:
So, what's the prevailing opinion regarding the use of the "CALL" keyword? I'm working with a third-party ASP application, adapting for our system, and the CALL keyword is used everywhere. I've...
5
by: Thomas Baxter | last post by:
Is it possible to have a conditional union statement in a stored proc? Here's an example on the northwind database. If says there's a syntax error near the UNION statement. Looks like it...
2
by: Gadrin77 | last post by:
as a newbie to XSL, is it possible to mimic a SELECT/CASE statement using XSL? I tried a quickie and I kept getting errors either using PARAM or WITH-PARAM in the wrong place or VARIABLE. I...
6
by: Terentius Neo | last post by:
Is it possible to combine (in DB2 UDB 8.1) a stored procedure and a select statement? I mean something like this: Select c.number, call procedure( c.number ) as list from table c With best...
10
by: John Smith | last post by:
Can you do a Select Statement within a Select Statement? I want to build a query similar to queries built in Access which link to other queries but using only SQL Statements. Is it possible? If...
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
0
by: hastha23 | last post by:
Dear Friends, My oracle Version is 10g. I calling a function from sql select same time function body contain DML statement,that time is possible call function from sql? and again one, ...
2
by: sangam56 | last post by:
Greetings. I suppose people out there can help in my problem. I am using sql server of microsoft visual studio 2005 itself. I have created a stored procedure which is give below. It works fine but...
3
by: micky125 | last post by:
Hey guys I have been checking the forum for a way to populate a second select field depending on the choice made from the first one. Basically i am working on projects and the delays that occur. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.