Monday, March 24, 2008

Rowcounts in PS tables

Here is the SQL that you can use to fetch the number of rows in the PS tables in MS SQL Server database.

SET NOCOUNT ON
DECLARE @tablename VARCHAR (128)
-- Declare cursor
DECLARE tables CURSOR FOR
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'dbo'
AND TABLE_NAME LIKE 'PS_%'
-- Create the table
CREATE TABLE #tables (
tablet CHAR (255),
RecordCount INT)
-- Open the cursor
OPEN tables
-- Loop through all the tables in the database
FETCH NEXT
FROM tables
INTO @tablename

WHILE @@FETCH_STATUS = 0
BEGIN
-- Do the showcontig of all indexes of the table
INSERT INTO #tables
exec('SELECT '+''''+ @tablename + ''''+ ', COUNT(*) FROM '+ @tablename)

FETCH NEXT
FROM tables
INTO @tablename
END

-- Close and deallocate the cursor
CLOSE tables
DEALLOCATE tables

select * from #tables order by 2 desc

Saturday, March 22, 2008

Bypass Component Search Page

We can bypass the component search page in different ways.
1. One way is to set the key values using peoplecode and use the peoplecode function SetSearchDialogBehavior. You can write the code in the SearchInit PeopleCode. Suppose Employee Id is the only key, then the code will look like,


EMPLID = %EmployeeId;
SetSearchDialogBehavior(0);


2. Another way is to use a record which contain only one single row in it eg: PSINSTALLATION.
3. There is another method of using a record with no keys as the component search record. This will also bypass the search.

Based on the requirement you can use any of the above methods.