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

dynamically created column names

Hi,

is there any idea about creating column names dynamically within a
select statement and without stored procedures?

We have some tables that have column names that consist of chars and
numbers i.e.:
Col0001, Col0002... Now I would like to have a function that returns
the column name Col0001 if i call that function i.e. myfunc(1).

I know it is possible with concat(Col000,myVariable) but DB2 does not
recognice the return value as a column name.

thanks
Michael
Nov 12 '05 #1
3 5452
Michael Gruner wrote:
Hi,

is there any idea about creating column names dynamically within a
select statement and without stored procedures?

We have some tables that have column names that consist of chars and
numbers i.e.:
Col0001, Col0002... Now I would like to have a function that returns
the column name Col0001 if i call that function i.e. myfunc(1).

I know it is possible with concat(Col000,myVariable) but DB2 does not
recognice the return value as a column name.

thanks
Michael


The only way to do this is to use dynamic SQL, first execute myfunc()
then compose the select.
SQL as a language is incapable of this. Come to think of it I know only
very few languages that could possibly do this. LISP being on of the.

Cheers
Serge
Nov 12 '05 #2
Serge Rielau wrote:
Michael Gruner wrote:
Hi,

is there any idea about creating column names dynamically within a
select statement and without stored procedures?

We have some tables that have column names that consist of chars and
numbers i.e.:
Col0001, Col0002... Now I would like to have a function that returns
the column name Col0001 if i call that function i.e. myfunc(1).

I know it is possible with concat(Col000,myVariable) but DB2 does not
recognice the return value as a column name.


What do you need that for? Maybe if we understand the reason for the
request, we could give you some advice.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #3
Knut Stolze schrieb:
What do you need that for? Maybe if we understand the reason for the
request, we could give you some advice.

O.K., we have an AS400 that serves a business application. We'd like to
fill some reports with the data retrieved from a DB2 that accesses the
files that were stored by the application.

The table visible through DB2 is a "one row" table with 365 + 365 + x
columns. That 365 + 365 colums have a static part as well as a dynamic
part, i.e.: abc001 and def001. We now would like to only call a function
with the dynamic part returning abc001 and def001 so we can use it as
column names within a select-statement.

Any ideas?
Michael
Nov 12 '05 #4

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

Similar topics

2
by: Colin McGuigan | last post by:
This is a translation of an ASP page to ASP.Net. First, the background: The goal is to have a grid of different settings for the application -- think something along the lines of the Property...
3
by: david | last post by:
I have posted my question before. It seems that I can not find the solution. The question: I have datasource, say, ds which is bounded to a datagrid, dg. Assume that ds have 5 columns,...
3
by: rn5a | last post by:
A SqlDataReader is populated with the records from a SQL Server 2005 DB table. The records retrieved depends upon 2 conditions (the conditions depend on what a user selects in an ASPX page). If...
2
by: jmarendo | last post by:
Hello, After reading through the "Table Basics - DOM - Refer to table cells" example at mredkj.com , I modified the code for my own purposes. In the modified version, I create a hyperlink and...
4
by: m.wanstall | last post by:
I have a crosstab query that compiles data for Months of the year. I have a stacked select query on top of that crosstab query that uses the latest 2 months data and exports it to a fixed length...
1
by: tsorgi | last post by:
I'm writing a data conversion application to support a system migration. The code is reading formatted text files and loading them into MS SQL 2005 database tables. I wanted to call the existing...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
4
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.