View previous topic :: View next topic
|
Author |
Message |
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
Hi All,
I want to write one generic Service (SQL query) in which I can retrieve the data from any table using primary key.
For example, during the run time my service will get the table name (it could be any table name) as an input. Based on that table name, I have to retrieve the data. But I have to retrieve the data based on the primary key of that particular table.
Can any one suggest how to achieve this?
I have one idea in my mind. I think, we can use dynamic SQL. By using dynamic SQL we can issue Select * from [table name] but difficult to give where clause here. Is it possible to give Index (primary key) dynamically for any table.
Thanks
Simha |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
So why have you posted this in the DFSORT forum ? |
|
Back to top |
|
|
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
I don't know about this. But I am looking for a help. Could you please help me out in this? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
what You ask for is not suitable for a forum reply ..
if You have the skills it' s reasonably easy to do it, NO amount of replies will provide You with the skills needed
Yes it can be done once the requirements are clear, how to do it is a different show
take one of the DSNTEP flavors and modify it according to Your needs
DSNTEP resides in a dataset name along "<some_qualifier>.SDSNSAMP" |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Why do you believe you need to provide a substitute for SPUFI?
Hopefully, you are aware that if "anyone" is permitted to do "whatever they want" on the fly, the system will eventually melt down. . . |
|
Back to top |
|
|
die7nadal
Active User
Joined: 23 Mar 2005 Posts: 156
|
|
|
|
This can done by querying the SQLDA variables. This process has been explained under Varying list Select statements using dynamic query in the IBM manuals. I can't remember exactly which manual at the top of my head.
As far as the primary key is concerned you can get them from the catalogue tables using this query
Code: |
SELECT * FROM SYSIBM.SYSCOLUMNS
WHERE TBNAME = 'NAME'
AND KEYSEQ > 0
WITH UR; |
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
This is a very ambitious project, and, from your basic question, I don't believe you have the necessary skills.
I'm not even sure I have the skills for that!
simha_it wrote: |
I have to retrieve the data based on the primary key of that particular table.
...
but difficult to give where clause here. Is it possible to give Index (primary key) dynamically for any table. |
From the way you posted your question, I feel you mixed the WHERE and ORDER BY clauses.
If you want to force DB2 to use an index, then you should ORDER BY all the key columns.
And yes, handling the WHERE will be very difficult.
You will need to handle all possible row lengths too.
And you will need authorization to access all the tables. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Tonrepeat:
Quote: |
Why do you believe you need to provide a substitute for SPUFI? |
If youn explain what you really want to do, someone may have a suggestion.
What you have asked is about a solution. What is the actual requirement? |
|
Back to top |
|
|
|