27 August 2022

How to Identify Powerbuilder Application Running Mode

If you are a Powerbuilder Application Developer, there is a nice tips to identify whether our Application is running from within PB IDE or not.

Therefore, we can put some codes in Powerbuilder App and run the code only if our Application running from within PB IDE, otherwise it will not executed.

If Handle(GetApplication())=0 then 

//Running from PB IDE

Else

//Running from Executable file

End If

For example, when it is running from PB IDE, we can inject User and Password in Login Form so we do not need to enter User and Password everytime we run our App during testing/development phase.

If Handle(GetApplication())=0 then 

sle_user.text = 'admin'

        sle_password.text = '123456'

        cb_ok.TriggerEvent (Clicked!)

End If

List of Stored Procedures with Create and Last Modify Date

Use this code to list all your Stored Procedures in your Database with Create and Last Modify Date. 


select db_name() as db_name,

SCHEMA_NAME([schema_id]) as schema_name,

name as sp_name,

create_date, 

modify_date as last_modify_date

from sys.objects

where type = 'P'

ORDER BY last_modify_date




24 August 2022

How to Obtain List of Files in a Folder from SQL Query

USE master; 

GO


-- To allow advanced options to be changed.

EXECUTE sp_configure 'show advanced options', 1; 

GO 


-- To update the currently configured value for advanced options. 

RECONFIGURE; 

GO


-- To enable the feature. 

EXEC sp_configure 'xp_cmdshell', 1; 

GO 


-- To update the currently configured value for this feature. 

RECONFIGURE;


USE MyDATABASE;

GO


CREATE TABLE zListFileName(NamaFile VARCHAR(300));

GO


INSERT INTO zListFileName

EXEC xp_cmdshell 'dir /B "D:\"';

GO


SELECT * FROM zListFileName

GO