473,467 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DB2 Stored Procedure

296 Contributor
The below is an Oracle Stored procedure -->

Expand|Select|Wrap|Line Numbers
  1. create or replace function search_in_table(
  2.  
  3.             owner varchar2,
  4.  
  5.             table_name varchar2,
  6.  
  7.             search_string varchar2)
  8.  
  9.             return varchar2 is
  10.  
  11.             stmt varchar2(32700);
  12.  
  13.             col varchar2(32700);
  14.  
  15. begin
  16.  
  17.             stmt := 'select ';
  18.  
  19.             for c in (
  20.  
  21.                         select column_name
  22.  
  23.                         from all_tab_columns
  24.  
  25.                         where all_tab_columns.table_name=search_in_table.table_name
  26.  
  27.                                     and all_tab_columns.owner=search_in_table.owner
  28.  
  29.                                     and data_type like '%CHAR%' )
  30.  
  31.             loop
  32.  
  33.                         stmt := stmt || 'max(case when REGEXP_LIKE("' || c.column_name ||  '", ''' || search_string || ''') then ''' || c.column_name || ' ''' || ' else null end) || ';
  34.  
  35.             end loop;
  36.  
  37.             stmt:= stmt||'nvl2(count(*),null,null) from "'||owner||'"."'||table_name||'"';
  38.  
  39.             execute immediate stmt into col;
  40.  
  41.             return col;
  42.  
  43. end;

The below Query uses the above function -->

Expand|Select|Wrap|Line Numbers
  1. select table_name,cols from (
  2.  
  3.             select rownum,
  4.  
  5.             table_name,
  6.  
  7.             search_in_table('SYSMAN',table_name,'[[:digit:]]') cols
  8.  
  9.             from all_tables where owner='SYSMAN' and tablespace_name='SYSTEM')
  10.  
  11.             where cols is not null;

Please convert the function and the Query to DB2 Stored Procedure and Query respectively.
May 2 '08 #1
1 1354
docdiesel
297 Recognized Expert Contributor
Hi,

in case you didn't recognize so far: This is not an online forum to roll off your tasks to others. If you try yourself and come to problems, then post the code, the error message etc. and we'll see if we can help.

Regards,

Bernd
May 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
0
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft...
3
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default"...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
8
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
3
by: kd | last post by:
Hi All, How to debug a stored procedure? Thanks, kd
7
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function...
2
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
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
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
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,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.