Posts

Showing posts from July, 2010

.Net DataTable Exercise

Every now and then I need to retrieve some data and show it in a grid... uh who am I kidding, I have to do this ALL the time. Well, here is a simple way to filter your data quick and easy. /* CODE */ GridFieldDAO dao = new GridFieldDAO(); DataTable dt = dao.getDT(); DataRow[] drs = dt.Select("(detailID = 1) AND (detailTypeID = 2)"); DataTable dt2 = dt.Clone(); foreach (DataRow d in drs) { dt2.ImportRow(d); } myGrid.DataSource = dt2; myGrid.DataBind(); /* CODE */ The real magic here is how the DataTable Select() method allows you to get subsets of data for display. Most people filter based off changing paramaters and reloading values from the database. If you want to just display filtering for a whole set, this is easier and more efficent. Enjoy!

Working with some Oracle Constraints

I was working with some code and wanted to add a Check Constraint for my test database. Using Oracle 10g I looked up some syntax reference and lo and behold I found Regular Expressions staring right at me! Quick side note : Coming from a programmers point of view I have to say the Oracle's Database is the most powerful and flexible database I have ever dealt with. You can write ANSI SQL, Oracle flavor SQL, and PL/SQL (not counting using Java for procedure language too). Also, every modern programming language works against it! Heck go to http://www.monster.com and search on Oracle - you'll get OVER 1000 postings. Its a great database and their is a REAL shortage of professionals who can work with it. Anyway, back to my simple constraint. Like I said earlier, Oracle does something I like - they support Regular Expressions in their SQL. Regular Expressions basically allow you to pattern match data to determine if it is what you are looking for for validation, etc. If yo