on 11-29-2007 9:39 AM
Hai To EveryOne,
I wrote query to display all fields in particular screen. Iam getting screen name as input.This is the query
SELECT T2.[Name] AS 'TableName' , T1.[Name] AS 'Name', T0.[AliasID] AS 'Title', T0.[Descr] AS 'Description', T0.[EditSize] AS 'Edit Size', T0.[EditType] AS 'Edit Type', T0.[FieldID] AS 'Field'
FROM [dbo].[CUFD] T0 , [dbo].[OUDO] T1 ,
(Select A.[Name],substring(A.[Name],2,len(A.[Name])) as tbl from [dbo].[sysobjects] A Where name like '@%') T2
WHERE T0.[TableID] like '@PUR%' and
T2.[tbl] IN (Select OUDO.[tablename] as tbl from OUDO UNION ALL Select UDO1.[tablename] as tbl from UDO1)
and T2.[tbl]=T1.[TableName]
and T2.[Name]=T0.[TableID]
order by T1.[Name] asc,T2.[Name] desc
In this @pur% is the table name.
Now my problem is if i execute this query only head table is displayed not the detail table i also need detail table.
Does anyone tell me whts the wrong in this query....
Regards,
Anitha
Hi Anitha,
Try and simplify the query a bit. I have modified your query to the query below. I hope it serves the same purpose.
SELECT T0.[TableID] AS 'TableName',
T1.[Name] AS 'ObjectName',
T0.[AliasID] AS 'Title',
T0.[Descr] AS 'Description',
T0.[EditSize] AS 'Edit Size',
T0.[EditType] AS 'Edit Type',
T0.[FieldID] AS 'Field'
FROM [dbo].[CUFD] T0
LEFT OUTER JOIN OUDO T1 on T1.TableName = substring(T0.TableID, 2, Len(T0.TableID)-1)
WHERE T0.[TableID] like '@PUR%'
Hope it helps,
Adele
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anitha,
Try this:
SELECT T0.[TableID] AS 'TableName',
T1.[Name] AS 'ObjectName',
T0.[AliasID] AS 'Title',
T0.[Descr] AS 'Description',
T0.[EditSize] AS 'Edit Size',
T0.[EditType] AS 'Edit Type',
T0.[FieldID] AS 'Field'
FROM [dbo].[CUFD] T0
LEFT OUTER JOIN OUDO T1 on T1.TableName = substring(T0.TableID, 2, Len(T0.TableID)-1)
WHERE T1.[Code] like 'ObjName%'
UNION
SELECT T0.[TableID] AS 'TableName',
T2.[Name] AS 'ObjectName',
T0.[AliasID] AS 'Title',
T0.[Descr] AS 'Description',
T0.[EditSize] AS 'Edit Size',
T0.[EditType] AS 'Edit Type',
T0.[FieldID] AS 'Field'
FROM [dbo].[CUFD] T0
LEFT OUTER JOIN UDO1 T1 on T1.TableName = substring(T0.TableID, 2, Len(T0.TableID)-1)
LEFT OUTER JOIN OUDO T2 on T2.Code = T1.Code
WHERE T1.[Code] like 'ObjName%'
Hope it helps,
Adele
Hi Anitha,
I added a parameter to get the Code of the User-Defined Object as well as removed the [dbo]. as it seemed to cause the error. I really hope this works as I can't spend much more time on this - gotta get some work done too
DECLARE @ObjName VARCHAR(100)
SELECT @ObjName =T4.Code FROM OUDO T4 WHERE T4.Code = '[%0]'
SELECT T0.[TableID] AS 'TableName',
T1.[Name] AS 'ObjectName',
T0.[AliasID] AS 'Title',
T0.[Descr] AS 'Description',
T0.[EditSize] AS 'Edit Size',
T0.[EditType] AS 'Edit Type',
T0.[FieldID] AS 'Field'
FROM [CUFD] T0
LEFT OUTER JOIN OUDO T1 on T1.TableName = substring(T0.TableID, 2, Len(T0.TableID)-1)
WHERE T1.[Code] = @ObjName
UNION
SELECT T0.[TableID] AS 'TableName',
T2.[Name] AS 'ObjectName',
T0.[AliasID] AS 'Title',
T0.[Descr] AS 'Description',
T0.[EditSize] AS 'Edit Size',
T0.[EditType] AS 'Edit Type',
T0.[FieldID] AS 'Field'
FROM [CUFD] T0
LEFT OUTER JOIN UDO1 T1 on T1.TableName = substring(T0.TableID, 2, Len(T0.TableID)-1)
LEFT OUTER JOIN OUDO T2 on T2.Code = T1.Code
WHERE T1.[Code] = @ObjName
Hope it helps,
Adele
Adele,
Is this possible to get the Predefined Screen also by adding some more condition in the query by....this
DECLARE @ObjName VARCHAR(100)
DECLARE @tb VARCHAR(100)
SELECT @ObjName =T4.Code FROM OUDO T4 WHERE T4.Code = 'CAN_UDO'
SELECT @tb=T.TableID FROM CUFD T WHERE T.TableID='OITM'
SELECT T0.[TableID] AS 'TableName',
T1.[Name] AS 'ObjectName',
T0.[AliasID] AS 'Title',
T0.[Descr] AS 'Description',
T0.[EditSize] AS 'Edit Size',
T0.[EditType] AS 'Edit Type',
T0.[FieldID] AS 'Field'
FROM [CUFD] T0
LEFT OUTER JOIN OUDO T1 on T1.TableName = substring(T0.TableID, 2, Len(T0.TableID)-1)
WHERE T1.[Code]=@ObjName AND T0.[TableID]=@tb
UNION
SELECT T0.[TableID] AS 'TableName',
T2.[Name] AS 'ObjectName',
T0.[AliasID] AS 'Title',
T0.[Descr] AS 'Description',
T0.[EditSize] AS 'Edit Size',
T0.[EditType] AS 'Edit Type',
T0.[FieldID] AS 'Field'
FROM [CUFD] T0
LEFT OUTER JOIN UDO1 T1 on T1.TableName = substring(T0.TableID, 2, Len(T0.TableID)-1)
LEFT OUTER JOIN OUDO T2 on T2.Code = T1.Code
WHERE T1.[Code]=@ObjName AND T0.[TableID]=@tb
Thanks & Regards,
Anitha
Hi Anitha,
Your "and T2.[tbl]=T1.[TableName]" condition do this because there is only head table of user-defined object at T1 table (OUDO) not the detail table.
Try to delete this condition as below:
SELECT T2.[Name] AS 'TableName' , T1.[Name] AS 'Name', T0.[AliasID] AS 'Title', T0.[Descr] AS 'Description', T0.[EditSize] AS 'Edit Size', T0.[EditType] AS 'Edit Type', T0.[FieldID] AS 'Field'
FROM [dbo].[CUFD] T0 , [dbo].[OUDO] T1 ,
(Select A.[Name],substring(A.[Name],2,len(A.[Name])) as tbl from [dbo].[sysobjects] A Where name like '@%') T2
WHERE T0.[TableID] like '@PUR%' and
T2.[tbl] IN (Select OUDO.[tablename] as tbl from OUDO UNION ALL Select UDO1.[tablename] as tbl from UDO1)
and T2.[Name]=T0.[TableID]
order by T1.[Name] asc,T2.[Name] desc
This working fine on my side.
HIH,
Anton
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
S Sure,
Iam in Purchase Module I have more than 10 screens in that module.. My aim is that if i give any screen name as input it wants to display all the field names in that particular screen.
For Example,
If i create Purchase Indent with one header part and one detail part with more than 25 fields with two tables named as @PUR_PI_HEAD and @PUR_PI_DETAIL. I have the UDO name for this screen named PI_UDO
If i give the input as PI_UDO all the fields in two tables have to display.....
Regards,
Anitha
User | Count |
---|---|
95 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.