Tuesday, January 31, 2006

kat's journal: "*masarap daw magmahal ng bolero, d dahil sa gusto ko lang magpaloko....kundi dahil gusto lang kita magbago... dahil nais ko sanang marinig buhat sa bibig mo...'sa dami ng niloko ko ikaw na ba ang karma ko...?'"

Saturday, January 28, 2006

Why is PGSQL better than MySQL:

If PostgreSQL is like that old saying "Make it right, then make it fast", I
guess my$ql is "Make it fast, then make it right". Seems like a no brainer
to me :-)

Why is PGSQL better than MySQL:

John,  when i first started developing in open source,
i did a lot of research on dbs. mysql had a HUGE,
HUGE, HUGE advantage in documentation at the time -
and that was a big factor since i'd be starting from
scratch.

i chose postgrsql inspite of this. native foreign key
constraints was a big reason. i came to like
transactions and it is more sql compliant than mysql.
it is also less buggy.

the license is also much more application developer
friendly - and this is HUGE if you ever want to
develop a product and market it.

having said that, mysql is an INCREDIBLY popular
database. those people that know it inside and out
will not be inclined to change easily - the devil you
know is better than the devil you don't know...

Why is PGSQL better than MySQL:

Re: Why is PGSQL better than MySQL
On Mon, 2005-12-12 at 20:02 -0600, John Mohr wrote:
> But does anyone know if there is a quasi-categorical comparison of the
> two so that I could speak with more conviction other than "I know it's
> better".


I've been involved in that comparison at work, and after some boring
theoretical discussions, i once turned to my CTO and said:

"Do a test. On the same machine, do a script that executes 50.000
inserts, OR any other 50.000 SQL operations you want, and benchmark the
results".

He did, and Postgres immediately got another die-hard fan.
The facts spoke more clearly than i could ever do, with just words.
Nowadays, he is even more "defensive" of PGSQL over MySQL than i am.

Spanish and Portuguese names:

It was also common for surnames originating from Castile and Álava to have the form "(patronymic) de placename". Hence for José Ignacio López de Arriortúa, "López de Arriortúa" is just one surname. This can cause confusion as both "López" and "de Arriortúa" can be found as single surnames. In Spain, unlike in neighboring France, the prefix "de" (meaning "of") on a surname does not typically indicate noble origin. It may be introduced just to mark a surname that can be misunderstood as a forename. Thus, Luis de Miguel Pérez marks that his forename is just Luis, not Luis Miguel. In short forms, the de may be included (Hernando de Soto is known as "de Soto") or not (Felipe de Borbón is a "Borbón", not a "de Borbón").

In Spanish, most surnames ending in "-ez" originated as patronymics. Thus "López" originally meant "son of Lope", "Fernández" meant "son of Fernando", etc. Other common examples of this are "Hernández" (from Hernando, a variant of "Ferdinand" / "Fernando"), "Rodríguez" (from "Rodrigo"), "Sánchez" (from "Sancho"), "Martínez" (from "Martín"), and "Álvarez" (from "Álvaro"). "Cortez" (e.g. Alberto Cortez), however, is a variant of "Cortés" (e.g. "Hernán Cortés").

After the recognition of co-official languages in Spain, the law allowed the translation or respelling of names to the official languages.

In 1849, the Spanish admnistration of the Philippines commanded every Filipino to take a Spanish surname from an approved list. Because of this, a Spanish surname does not necessarily imply any Spanish ancestry among all Filipinos.

Number of names

The official records keep at most two forenames and two surnames per person. However, people can be baptized with more than two forenames, which is a frequent practice among the royalty.

People can also keep track of more than two surnames. This is more frequent in the Basque Country. For example, the founder of Basque nationalism, Sabino Arana, demanded several Basque surnames from his followers to certify that there was no admixture of "foreigners" in their ancestry.

Code Switching

Tagalog language - Wikipedia, the free encyclopedia:

Code-switching

Code-switching is prevalent in the Philippines. The most common form of code-switching is between Tagalog and English called Taglish.

The intensity of code-switching varies. It can be as simple as one-word borrowings.

Nasirà ang computer ko kahapon!
"My computer broke yesterday!"

The language can even change in mid-sentence.

Huwág kang maninigarilyo, because it is harmful to your health.
"Never smoke cigarettes, ..."

Although it's generally looked down upon, code-switching is prevalent in all levels of society, though urban-dwellers, those with high education, and those born around World War II are more likely to do it. Politicians, like President Gloria Macapagal Arroyo, have code-switched in interviews.

It is common in television, radio, and print media as well. In the US, advertisements from companies like Wells Fargo, Wal-Mart, Albertsons, and Western Union have had Taglish on them.

The Chinese and the non-Tagalog communities also frequently code-switch their language, be it Cebuano or Min Nan Chinese, with Taglish.

Filipino Spanish speakers (very few) also frequently code switch with Tagalog and Spanish.

Tagalog language - Wikipedia, the free encyclopedia: "Batangas is the heartland of the Tagalog language, and so, the Tagalog spoken here closely resembles Old Tagalog better than the other dialects. Words of Sanskrit, Arabic, and Persian origin are still used. Its intonation is quite different from that of Manila, Batangan Tagalog being spoken fast and with a thick accent. Area: Batangas"

code generator to do

RsDetailSrc.Fields.Append "FobPrice", DataTypeEnum.adDecimal

kailangan idagdag eto mga sumusunod para sa datatype na decimal or numeric, walang precision and numericscale ang append method

RsDetailSrc.Fields("FobPrice").Precision = 5

RsDetailSrc.Fields("FobPrice").NumericScale = 2

Friday, January 27, 2006

How To Enable ODBC Connection Pooling in a Visual Basic ADO Application:

This article was previously published under Q237844
SUMMARY
By default, ADO uses OLEDB session pooling to maintain a pool of connections to the database. In some cases, you might want to use ODBC connection pooling instead of OLEDB session pooling. This article describes what is necessary to enable ODBC connection pooling from a Visual Basic/ADO application.

Note The following only applies if you are using an ODBC driver to establish the connection to your database.
MORE INFORMATION
To enable ODBC connection pooling from a Visual Basic/ADO application, there are two necessary steps:
1. Open the ODBC Data Source Administrator from the control panel. Select the Connection Pooling tab. Find the driver that you are using in the list and double-click on it. Choose the option Pool connections to this driver and enter a timeout value.

Note This only applies to the ODBC Administrator version 3.5 or later. If you are using an earlier version of the Administrator, then you need to find the CPTimeout value for your driver in the registry under the following registry key and set the value:
HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBCINST.INI/Driver_Name
For more information on setting this value in the registry, please see the following document:
http://msdn.microsoft.com/library/techart/pooling2.htm (http://msdn.microsoft.com/library/techart/pooling2.htm)
The second step is to add an ODBC API function call to SQLSetEnvAttr in your application with the appropriate options to enable ODBC connection pooling for the process. This function should only be called once per process and must be called prior to executing any ADO code. Below are the steps necessary to create a complete Visual Basic code sample demonstrating this:
1. Create a new Visual Basic Standard EXE project. Form1 is created by default.
2. From the Project menu, choose References and add a reference to Microsoft ActiveX Data Objects.
3. On the default form, add a CommandButton.
4. Cut and paste the following code into the form. You need to modify the connection string so that it connects to your database:

Note You must change User ID=<User ID> and password=<Strong Password> to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database.

Option Explicit
Dim rc As Long

Const dbconnstring = "DSN=<Your DSN>;uid=<User ID>;pwd=<Strong Password>;OLE DB Services=-2"

Const SQL_ATTR_CONNECTION_POOLING = 201
Const SQL_CP_ONE_PER_DRIVER = 1
Const SQL_IS_INTEGER = -6
Const SQL_CP_OFF = 0

Private Declare Function SQLSetEnvAttr Lib "odbc32.dll" ( _
ByVal EnvironmentHandle As Long, _
ByVal EnvAttribute As Long, _
ByVal ValuePtr As Long, _
ByVal StringLength As Long) As Integer

Private Sub Command1_Click()

Dim SQL As String

'Test connection pooling
Dim i As Long
For i = 1 To 10
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Open dbconnstring
cn.Close
Set cn = Nothing
Next

MsgBox "Connection finished"

End Sub

Private Sub Form_Load()

'Enable connection pooling .. this must be done before any ADO calls
'are made. Only needs to occur one time per process
rc = SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_ONE_PER_DRIVER, _
SQL_IS_INTEGER)
If rc <> 0 Then
Debug.Print "SQLSetEnvAttr Error " & rc
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

Call SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_OFF, _
SQL_IS_INTEGER)

End Sub


5. Compile the project into an EXE. Before running the compiled EXE, you might want to use some utility to monitor the connections being made to the database. With SQL Server 7.0, you can use Profiler (SQL Trace with SQL Server 6.5). Run this program and you should see only one connection made to the database. Each subsequent connection utilizes the existing connection in the pool.

How To Enable ODBC Connection Pooling in a Visual Basic ADO Application:


This article was previously published under Q237844
SUMMARY
By default, ADO uses OLEDB session pooling to maintain a pool of connections to the database. In some cases, you might want to use ODBC connection pooling instead of OLEDB session pooling. This article describes what is necessary to enable ODBC connection pooling from a Visual Basic/ADO application.

Note The following only applies if you are using an ODBC driver to establish the connection to your database.
MORE INFORMATION
To enable ODBC connection pooling from a Visual Basic/ADO application, there are two necessary steps:
1. Open the ODBC Data Source Administrator from the control panel. Select the Connection Pooling tab. Find the driver that you are using in the list and double-click on it. Choose the option Pool connections to this driver and enter a timeout value.

Note This only applies to the ODBC Administrator version 3.5 or later. If you are using an earlier version of the Administrator, then you need to find the CPTimeout value for your driver in the registry under the following registry key and set the value:
HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBCINST.INI/Driver_Name
For more information on setting this value in the registry, please see the following document:
http://msdn.microsoft.com/library/techart/pooling2.htm (http://msdn.microsoft.com/library/techart/pooling2.htm)
The second step is to add an ODBC API function call to SQLSetEnvAttr in your application with the appropriate options to enable ODBC connection pooling for the process. This function should only be called once per process and must be called prior to executing any ADO code. Below are the steps necessary to create a complete Visual Basic code sample demonstrating this:
1. Create a new Visual Basic Standard EXE project. Form1 is created by default.
2. From the Project menu, choose References and add a reference to Microsoft ActiveX Data Objects.
3. On the default form, add a CommandButton.
4. Cut and paste the following code into the form. You need to modify the connection string so that it connects to your database:

Note You must change User ID= and password= to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database.

Option Explicit
Dim rc As Long

Const dbconnstring = "DSN=;uid=;pwd=;OLE DB Services=-2"

Const SQL_ATTR_CONNECTION_POOLING = 201
Const SQL_CP_ONE_PER_DRIVER = 1
Const SQL_IS_INTEGER = -6
Const SQL_CP_OFF = 0

Private Declare Function SQLSetEnvAttr Lib "odbc32.dll" ( _
ByVal EnvironmentHandle As Long, _
ByVal EnvAttribute As Long, _
ByVal ValuePtr As Long, _
ByVal StringLength As Long) As Integer

Private Sub Command1_Click()

Dim SQL As String

'Test connection pooling
Dim i As Long
For i = 1 To 10
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Open dbconnstring
cn.Close
Set cn = Nothing
Next

MsgBox "Connection finished"

End Sub

Private Sub Form_Load()

'Enable connection pooling .. this must be done before any ADO calls
'are made. Only needs to occur one time per process
rc = SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_ONE_PER_DRIVER, _
SQL_IS_INTEGER)
If rc <> 0 Then
Debug.Print "SQLSetEnvAttr Error " & rc
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

Call SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_OFF, _
SQL_IS_INTEGER)

End Sub


5. Compile the project into an EXE. Before running the compiled EXE, you might want to use some utility to monitor the connections being made to the database. With SQL Server 7.0, you can use Profiler (SQL Trace with SQL Server 6.5). Run this program and you should see only one connection made to the database. Each subsequent connection utilizes the existing connection in the pool.

How To Enable ODBC Connection Pooling in a Visual Basic ADO Application:


How To Enable ODBC Connection Pooling in a Visual Basic ADO Application


This article was previously published under Q237844
SUMMARY

By default, ADO uses OLEDB session pooling to maintain a pool of connections to the database. In some cases, you might want to use ODBC connection pooling instead of OLEDB session pooling. This article describes what is necessary to enable ODBC connection pooling from a Visual Basic/ADO application.

Note The following only applies if you are using an ODBC driver to establish the connection to your database.
MORE INFORMATION

To enable ODBC connection pooling from a Visual Basic/ADO application, there are two necessary steps:
1.Open the ODBC Data Source Administrator from the control panel. Select the Connection Pooling tab. Find the driver that you are using in the list and double-click on it. Choose the option Pool connections to this driver and enter a timeout value.

Note This only applies to the ODBC Administrator version 3.5 or later. If you are using an earlier version of the Administrator, then you need to find the CPTimeout value for your driver in the registry under the following registry key and set the value:
HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBCINST.INI/Driver_Name
For more information on setting this value in the registry, please see the following document:
http://msdn.microsoft.com/library/techart/pooling2.htm (http://msdn.microsoft.com/library/techart/pooling2.htm)
The second step is to add an ODBC API function call to SQLSetEnvAttr in your application with the appropriate options to enable ODBC connection pooling for the process. This function should only be called once per process and must be called prior to executing any ADO code. Below are the steps necessary to create a complete Visual Basic code sample demonstrating this:
1.Create a new Visual Basic Standard EXE project. Form1 is created by default.
2.From the Project menu, choose References and add a reference to Microsoft ActiveX Data Objects.
3.On the default form, add a CommandButton.
4.Cut and paste the following code into the form. You need to modify the connection string so that it connects to your database:

Note You must change User ID= and password= to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database.
Option Explicit
Dim rc As Long

Const dbconnstring = "DSN=;uid=;pwd=;OLE DB Services=-2"

Const SQL_ATTR_CONNECTION_POOLING = 201
Const SQL_CP_ONE_PER_DRIVER = 1
Const SQL_IS_INTEGER = -6
Const SQL_CP_OFF = 0

Private Declare Function SQLSetEnvAttr Lib "odbc32.dll" ( _
ByVal EnvironmentHandle As Long, _
ByVal EnvAttribute As Long, _
ByVal ValuePtr As Long, _
ByVal StringLength As Long) As Integer

Private Sub Command1_Click()

Dim SQL As String

'Test connection pooling
Dim i As Long
For i = 1 To 10
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Open dbconnstring
cn.Close
Set cn = Nothing
Next

MsgBox "Connection finished"

End Sub

Private Sub Form_Load()

'Enable connection pooling .. this must be done before any ADO calls
'are made. Only needs to occur one time per process
rc = SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_ONE_PER_DRIVER, _
SQL_IS_INTEGER)
If rc <> 0 Then
Debug.Print "SQLSetEnvAttr Error " & rc
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

Call SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_OFF, _
SQL_IS_INTEGER)

End Sub
5.Compile the project into an EXE. Before running the compiled EXE, you might want to use some utility to monitor the connections being made to the database. With SQL Server 7.0, you can use Profiler (SQL Trace with SQL Server 6.5). Run this program and you should see only one connection made to the database. Each subsequent connection utilizes the existing connection in the pool.

How To Enable ODBC Connection Pooling in a Visual Basic ADO Application:

How To Enable ODBC Connection Pooling in a Visual Basic ADO Application

This article was previously published under Q237844

SUMMARY

By default, ADO uses OLEDB session pooling to maintain a pool of connections to the database. In some cases, you might want to use ODBC connection pooling instead of OLEDB session pooling. This article describes what is necessary to enable ODBC connection pooling from a Visual Basic/ADO application.

Note The following only applies if you are using an ODBC driver to establish the connection to your database.

MORE INFORMATION

To enable ODBC connection pooling from a Visual Basic/ADO application, there are two necessary steps:
1.Open the ODBC Data Source Administrator from the control panel. Select the Connection Pooling tab. Find the driver that you are using in the list and double-click on it. Choose the option Pool connections to this driver and enter a timeout value.

Note This only applies to the ODBC Administrator version 3.5 or later. If you are using an earlier version of the Administrator, then you need to find the CPTimeout value for your driver in the registry under the following registry key and set the value:
HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBCINST.INI/Driver_Name
For more information on setting this value in the registry, please see the following document:
http://msdn.microsoft.com/library/techart/pooling2.htm (http://msdn.microsoft.com/library/techart/pooling2.htm)
The second step is to add an ODBC API function call to SQLSetEnvAttr in your application with the appropriate options to enable ODBC connection pooling for the process. This function should only be called once per process and must be called prior to executing any ADO code. Below are the steps necessary to create a complete Visual Basic code sample demonstrating this:
1.Create a new Visual Basic Standard EXE project. Form1 is created by default.
2.From the Project menu, choose References and add a reference to Microsoft ActiveX Data Objects.
3.On the default form, add a CommandButton.
4.Cut and paste the following code into the form. You need to modify the connection string so that it connects to your database:

Note You must change User ID= and password= to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database.
Option Explicit
Dim rc As Long

Const dbconnstring = "DSN=;uid=;pwd=;OLE DB Services=-2"

Const SQL_ATTR_CONNECTION_POOLING = 201
Const SQL_CP_ONE_PER_DRIVER = 1
Const SQL_IS_INTEGER = -6
Const SQL_CP_OFF = 0

Private Declare Function SQLSetEnvAttr Lib "odbc32.dll" ( _
ByVal EnvironmentHandle As Long, _
ByVal EnvAttribute As Long, _
ByVal ValuePtr As Long, _
ByVal StringLength As Long) As Integer

Private Sub Command1_Click()

Dim SQL As String

'Test connection pooling
Dim i As Long
For i = 1 To 10
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Open dbconnstring
cn.Close
Set cn = Nothing
Next

MsgBox "Connection finished"

End Sub

Private Sub Form_Load()

'Enable connection pooling .. this must be done before any ADO calls
'are made. Only needs to occur one time per process
rc = SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_ONE_PER_DRIVER, _
SQL_IS_INTEGER)
If rc <> 0 Then
Debug.Print "SQLSetEnvAttr Error " & rc
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

Call SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_OFF, _
SQL_IS_INTEGER)

End Sub
5.Compile the project into an EXE. Before running the compiled EXE, you might want to use some utility to monitor the connections being made to the database. With SQL Server 7.0, you can use Profiler (SQL Trace with SQL Server 6.5). Run this program and you should see only one connection made to the database. Each subsequent connection utilizes the existing connection in the pool.

How To Enable ODBC Connection Pooling in a Visual Basic ADO Application:

How To Enable ODBC Connection Pooling in a Visual Basic ADO Application


This article was previously published under Q237844

SUMMARY

By default, ADO uses OLEDB session pooling to maintain a pool of connections to the database. In some cases, you might want to use ODBC connection pooling instead of OLEDB session pooling. This article describes what is necessary to enable ODBC connection pooling from a Visual Basic/ADO application.

Note The following only applies if you are using an ODBC driver to establish the connection to your database.

MORE INFORMATION

To enable ODBC connection pooling from a Visual Basic/ADO application, there are two necessary steps:
1.Open the ODBC Data Source Administrator from the control panel. Select the Connection Pooling tab. Find the driver that you are using in the list and double-click on it. Choose the option Pool connections to this driver and enter a timeout value.

Note This only applies to the ODBC Administrator version 3.5 or later. If you are using an earlier version of the Administrator, then you need to find the CPTimeout value for your driver in the registry under the following registry key and set the value:
HKEY_LOCAL_MACHINE/SOFTWARE/ODBC/ODBCINST.INI/Driver_Name
For more information on setting this value in the registry, please see the following document:
http://msdn.microsoft.com/library/techart/pooling2.htm (http://msdn.microsoft.com/library/techart/pooling2.htm)
The second step is to add an ODBC API function call to SQLSetEnvAttr in your application with the appropriate options to enable ODBC connection pooling for the process. This function should only be called once per process and must be called prior to executing any ADO code. Below are the steps necessary to create a complete Visual Basic code sample demonstrating this:
1.Create a new Visual Basic Standard EXE project. Form1 is created by default.
2.From the Project menu, choose References and add a reference to Microsoft ActiveX Data Objects.
3.On the default form, add a CommandButton.
4.Cut and paste the following code into the form. You need to modify the connection string so that it connects to your database:

Note You must change User ID= and password= to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database.
Option Explicit
Dim rc As Long

Const dbconnstring = "DSN=;uid=;pwd=;OLE DB Services=-2"

Const SQL_ATTR_CONNECTION_POOLING = 201
Const SQL_CP_ONE_PER_DRIVER = 1
Const SQL_IS_INTEGER = -6
Const SQL_CP_OFF = 0

Private Declare Function SQLSetEnvAttr Lib "odbc32.dll" ( _
ByVal EnvironmentHandle As Long, _
ByVal EnvAttribute As Long, _
ByVal ValuePtr As Long, _
ByVal StringLength As Long) As Integer

Private Sub Command1_Click()

Dim SQL As String

'Test connection pooling
Dim i As Long
For i = 1 To 10
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
cn.Open dbconnstring
cn.Close
Set cn = Nothing
Next

MsgBox "Connection finished"

End Sub

Private Sub Form_Load()

'Enable connection pooling .. this must be done before any ADO calls
'are made. Only needs to occur one time per process
rc = SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_ONE_PER_DRIVER, _
SQL_IS_INTEGER)
If rc <> 0 Then
Debug.Print "SQLSetEnvAttr Error " & rc
End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

Call SQLSetEnvAttr(0&, _
SQL_ATTR_CONNECTION_POOLING, _
SQL_CP_OFF, _
SQL_IS_INTEGER)

End Sub
5.Compile the project into an EXE. Before running the compiled EXE, you might want to use some utility to monitor the connections being made to the database. With SQL Server 7.0, you can use Profiler (SQL Trace with SQL Server 6.5). Run this program and you should see only one connection made to the database. Each subsequent connection utilizes the existing connection in the pool.

INFO: Frequently Asked Questions About ODBC Connection Pooling:


INFO: Frequently Asked Questions About ODBC Connection Pooling

This article was previously published under Q169470

SUMMARY

This article covers some of the most frequently asked questions about ODBC connection pooling.

MORE INFORMATION

1.Q. What is ODBC connection pooling?

A. Connection pooling is one the new features introduced in ODBC 3.0. Connection pooling enables an ODBC application to reuse a connection from a pool of connections. Once a connection has been created and placed in the pool, an ODBC application can reuse the same driver and the connection within the same shared environment (henv) without performing the complete connection process. However, a connection can never be reused between different henv or different drivers.
2.Q. Can I use connection pooling with 2.x ODBC drivers?

A. Connection pooling is implemented in the ODBC driver manager version 3.0 or later. The driver version does not matter.
3.Q. Can I enable connection pooling with the Microsoft Access driver because the connection pooling is implemented in the driver manager?

A. You can enable connection pooling for Microsoft Access driver. Microsoft Access uses Jet, and Jet is thread safe starting from Jet 4.0. From MDAC 2.1 and later, you can have connection pooling for Access ODBC driver.
4.Q. How do I enable connection pooling in an ODBC application?

A. An ODBC application can call SQLSetEnvAttr with the SQL_ATTR_CONNECTION_POOLING attribute to enable connection pooling. For more information about how to enable connection pooling in an ODBC application, please see the following article in the Microsoft Knowledge Base:
164221 (http://support.microsoft.com/kb/164221/EN-US/) How to Enable Connection Pooling in an ODBC Application
5.Q. How do I enable connection pooling if the application is written in Visual Basic?

A. A Visual Basic or ODBC application can call the SQLSetEnvAttr function to enable connection pooling. Connection pooling is a process-level attribute, so any subsequent connection made through the ODBC driver manager in the Visual Basic application will use connection pooling. A Visual Basic application can use the function declaration and code to enable connection pooling.
      Declare Function SQLSetEnvAttr Lib "odbc32.dll" (ByVal henv As Long,
ByVal Attribute As Long, ByVal Value As Long, ByVal StringLength As
Long) As Integer

' env attribute
Public Const SQL_ATTR_CONNECTION_POOLING = 201
Public Const SQL_ATTR_CP_MATCH = 202

' values for SQL_ATTR_CONNECTION_POOLING
Public Const SQL_CP_ONE_PER_DRIVER = 1
Public Const SQL_IS_UINTEGER = -5

nstatus = SQLSetEnvAttr(0, SQL_ATTR_CONNECTION_POOLING,
SQL_CP_ONE_PER_DRIVER, SQL_IS_UINTEGER)
SQLAllocEnv...
SQLAllocConnect...
SQLConnect...
SQLDisConnect...
SQLFreeConnect...
SQLFreeEnv...
For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
237844 (http://support.microsoft.com/kb/237844/EN-US/) HOWTO: Enable ODBC Connection Pooling in VB ADO Application
228843 (http://support.microsoft.com/kb/228843/EN-US/) HOWTO: Implement Session Pooling from Visual Basic ADO Program

Thursday, January 26, 2006

format function for Arithmetic Rounding(Non-Banker's Rounding)

April 2005

The Lesser Known Format Function

Rick Rothstein

VB's Format function doesn't tend to elicit images of speed, but it is a capable workhorse–and a surprisingly flexible one at that. In this article, Rick Rothstein explores some of the Format function's nooks and crannies.

Did you know that the Format function is capable of performing "normal" rounding? No, this isn't a trick question. VB6 uses something known as "Banker's Rounding" both in its Round function and in its various conversion routines. Banker's Rounding rounds numbers ending in five to the nearest even number when rounding to the previous decimal position. For example, 1.2345 rounded to three decimal places is 1.234 according to VB. Back in school, however, most of us learned that 1.2345 should round up to 1.235. I won't go into the theory behind Banker's Rounding; you can read all about it and the other rounding methods employed by Microsoft in its various products in Q196652. (You may be surprised at the lack of consistency.)

Suffice it to say that VB uses Banker's Rounding not only in the Round function itself, but also in the CLng function, CInt function, Mod operator, and just about any other function that handles automatic or coerced rounding. Any other function, that is, except the Format function. Simply feed the Format function your value to be rounded along with the desired format specification string and it will perform normal rounding for you. For example, if you execute the following code:

Value = 1.2345
Print Format(Value, "0.000")

the value 1.235 will print out. The generalized statement for this would be:

Print Format(Value, "0." & String$(Places, "0"))

where Places is the number of decimal places you want to round to. If you want to generalize this all the way, you'll need to add logic to handle the dangling decimal point that occurs when Places equals zero.

Conditionally formatted output

So what else can the Format function do for us? Well, how about returning conditionally formatted values when the first argument is numeric? Most programmers don't realize that they can specify up to four separate sections in the format specification string for numerical value formatting. Let's examine an example with all four sections specified (section delimiters are semicolons) and discuss what's happening. Consider this statement:
Print Format(Value, "+0.00;(0.00);<0>;\N\A\D\A")

If Value is NULL, then the fourth section will be used to format the result; in this case, the string NADA will be printed out. If Value equals zero, then the third section will be used to format the result and, in this case, a zero encased in angle brackets will be printed out. If Value is negative, then the second section's format will be used to format the result and, for this case, the value surrounded by parentheses will be printed out. And, finally, if Value is positive, then the first section will be used to format the result and, in this case, the value will be printed with a leading plus sign.

Table 1 illustrates how VB's Help files document the sections.

Table 1. Deciphering the Format function's sections.

If you use

The result is

One section

The format expression applies to all values.

Two sections

The first section applies to positive values and zeros, the second to negative values.

Three sections

The first section applies to positive values, the second to negative values, and the third to zeros.

Four sections

The first section applies to positive values, the second to negative values, the third to zeros, and the fourth to Null values.

Notice the syntax: Semicolons are used to separate the various sections, and quote marks go around the four sections as a single entity. You shouldn't skip any internal sections, nor should you use spaces to "tidy up" the look of the format specification string, such as around those semicolons. Indeed, if you put a space in the format specification string, it will show up in the resulting return value. A bit of "been there, done that" advice about the "no internal sections should be skipped" rule: If you skip a section (by using two adjacent semicolons), then the above rules will be applied only for that missing section as if no other sections followed it. For example, if we modify our earlier example statement to remove section two:

Print Format(Value, "+0.00;;<0>;\N\U\L\L")

all output will be the same as previously discussed–except if Value is negative. In that case, the first section will be used to format it. That means the numerical value will be printed out with, as it turns out, a -+ in front of it (the plus sign from the formatting of the governing first section with a minus sign placed in front of that because the value is negative). So, be aware of possible side-effects like this when choosing to omit sections.

There's a parallel functionality for String arguments, but it's more limited. A maximum of only two sections can be specified; the first is the format specification string to apply to non-NULL string values and the second is, of course, the return value to use if the value to be formatted is NULL (for example, a non-initialized Variant or a NULL field from a database). "I know, I know," I hear some of you muttering. "String argument, what's he talking about?" Well, that's another little-known functionality of the Format function–it can perform limited string formatting, too.

Two of the formats it can perform have been "replaced" (maybe "complemented" is a better term) by past function additions to the VB language, but, for the sake of completeness, I'll mention them anyway. The Format function can change all characters in a text string to either uppercase or lowercase (this is, of course, what the UCase and LCase functions do for us now) by using either the "greater than" or "less than" symbol as the format specification string. For example, this:

TextString = "abc"
Print Format(TextString, ">")

will print out ABC as its output; and, in a similar fashion, this:

TextString = "ABC"
Print Format(TextString, "<")

will print abc as its output.

Fixed-size fields

The Format function can also return fixed-size fields of data–well, sort of. The implementation of this feature seems somewhat screwy to me under certain circumstances, but if used correctly, it can be useful. Let's take a look at what I'm talking about here. Consider the following piece of code:
TextString = "ABCD"
Print "<" & Right$(Space$(10) & TextString, 10) & ">"

It will output the following:

<>

In other words, it's a method of printing out a right-justified field of data that is, in this example, 10 characters wide (the angle brackets have been included so that you can see the limits of the printed field). Well, as it turns out, Format can (actually, has always been able to) perform this same functionality:

TextString = "ABCD"
Print "<" & Format(TextString, "@@@@@@@@@@") & ">"

The "at" sign (@), when included in a format specification string, supplies positional spaces in the output in the same way the 0 supplies positional zeros in the output for numeric values. So, you might be asking, is there a way to left justify the output in the same way the following code does?

TextString = "ABCD"
Print "<" & Left$(TextString & Space$(10), 10) & ">"

Of course there is; we just need to place an exclamation mark (!) at the beginning of the format specification string in order to produce left-justified text.

TextString = "ABCD"
Print "<" & Format(TextString, "!@@@@@@@@@@") & ">"

If we do this, the following will be printed out:


We can use the String function to generalize this as follows:

TextString = "ABCD"
Places = 10
Print "<" & Format(TextString, _
String$(Places, "@")) & ">"
Print "<" & Format(TextString, "!" & _
String$(Places, "@")) & ">"

"Okay," you might be saying to yourself, "this all looks normal enough. Where does the screwiness come in?" If the string to be formatted is longer than the field allocated for it, the two forms of this format specification string (with and without the exclamation mark) act differently. For example, this:

TextString = "ABCDEFGHIJ"
Print "<" & Format(TextString, "@@@@") & ">"

prints out:


as if no format function were being used; that is, the original string of text is returned untouched. However, this example code:

TextString = "ABCDEFGHIJ"
Print "<" & Format(TextString, "!@@@@") & ">"

will truncate the string argument from the right side and print out the following instead!


The lesson to be taken away from this is that if you use this form of the string formatting capabilities of the Format function, make sure your field size is large enough to contain the text you wish to place in it.

Ah, yes

One last item: You can use ampersand characters (&) in place of the "at" signs, but if you do, positional spaces won't be returned. That means the field size will only be preserved when the string argument is longer than the number of ampersand characters and the format specification string contains the exclamation mark at the beginning (which is identical to this same case when "at" signs are used); otherwise, the entire string will be returned untouched. I'm not sure I see a lot of usefulness for this particular option, so I'll place it in the "somewhat screwy" category that I mentioned earlier.

Here are some additional resources that you may find useful:

  • Q196652 How To Implement Custom Rounding Procedures
  • Q170550 INFO: Format Function and International Settings
  • Q217012 How To Format Strings to Right-Justify When Printing
  • Q279755 INFO: Visual Basic and Arithmetic Precision
  • Q189847 describes new VB6 formatting functions FormatCurrency, FormatDateTime, FormatNumber, and FormatPercent, and also describes the "new" Round function as using "business" rather than arithmetic rounding rules.
  • Q28855 CINT/CLNG Integer Assignment Round x.5 to Nearest Even Integer
  • Formatting in VB.NET–http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctformat.as

Wednesday, January 25, 2006

optimized index

Compound Index:
DatePaid
ReceivedAtBranch




SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

alter PROCEDURE FinancingDrrAllBranch
@D DATETIME
AS

SELECT P.ReceivedAtBranch, B.BranchName, DailyCollection = SUM(P.Payment)
FROM AccountInstallmentFinancingDetailFinal AS P
INNER JOIN Branch AS B ON P.ReceivedAtBranch = B.BranchCode
WHERE P.DatePaid = @D
AND P.OrNo <> '' AND P.OrNo <> 'ADJ'
GROUP BY P.ReceivedAtBranch, B.BranchName


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

Ubuntu Blog:

Multiple Graphical Users Logged in at the Same Time January 23, 2006

There are several ways to share the same desktop between family members. But it gets tricky when you have, say a graphical program running that has to keep running, and your sister wants to use the computer. In this situation, it is useful to have more than one graphical session running. Your work will continue uniterrupted even as your sister can use the desktop.

The simplest way of doing this is by starting gdmflexiserver
$gdmflexiserver

This will start a new graphical server which you can switch to by using Ctrl+Alt+F8. You can return to your own graphical session using Ctrl+Alt+F7. You can create more such sessions - you get the idea.

Ideally, FUSA should be in Ubuntu already - but since it is not, you can install it and use it. Being beta software, it might be buggy, and I’d rather just do this using gdmflexiserver - but if you are adventurous, please do try out FUSA — it is a lot easier to use, as the website will tell you.

Network janitor's log:

Thursday, December 22, 2005

CLI shortcuts, 5

To get error code of last executed command:

echo $?

Simple script to switch IPs

#!/bin/bash
# Switch IP script, v.1 - iandexter@philrice.gov.ph

CONFIG_DIR=/etc/sysconfig/network-scripts
ROOT_UID=0
ERRROR_XCD=66
ERROR_NOTROOT=67

# Run as root
if [ "$UID" -ne "$ROOT_UID" ]
then
echo "Must be root to run this script."
exit $ERROR_NOTROOT
fi

cd $CONFIG_DIR || {
echo "Cannot change to config dir."
exit $ERROR_XCD
}

if [ -z "$1" ]
then
echo "Usage: `basename $0` [afrdis|preginet]"
exit 1
else
if grep -q $1 ifcfg-eth0
then
echo "Already linked. Not switching anymore."
exit 0
else
echo "Switching to $1 link..."
cp ifcfg-eth0.$1 ifcfg-eth0
ifdown eth0
ifup eth0
ifconfig eth0
exit 0
fi
fi

Hotspot hunting: Robinson’s Galleria (Ortigas) -- Pinoy Tech Blog - The Philippines’ Premier Technology Blog: "Laptop thefts have already occured in the WiFi hotspots of Galleria and Cyberzone Megamall. Just be careful you’re not in a position to let anyone put their arms around you and poke a knife at the side of your belly. Be wary of anyone following you."

Tuesday, January 24, 2006

ExpectoRants:

dedicated to former Martial Law victims

It’s no secret. The only way to survive this cruel world is to forgive. Even Beyonce Knowles, one third of the group formerly known as Destiny’s Child (wrong grammar) knows that. Forgive and forgive and forgive and forgive. Easier said than done, of course. But if you can do that, you will no doubt survive. Trouble is, forgiving may be easy; it is forgetting that is kinda hard and complicated. Have you forgiven the sins committed against you? You ought to have, if only for your own sake or your heartbeat and your blood pressure. But it doesn’t mean you ought to really forget. Forgiving is so short, forgetting even shorter (and stupid.) It is repairing wrong that is so long. Bad intertextuality perhaps, but of course I stole that from Neruda.

***

Homegrown dictatorship has been replaced by an even more merciless enemy – subhuman poverty due to decades of patronage politics and its monstrous twin spawns, institutional graft and corruption and gross social injustice. To all decision-makers, all high-ranking government officials, taste a real-life game of Survivor (episode title: Unbelievable Insensitivity) with the ff. exercises:

1. Find scraps to sell from the garbage dump.
2. Take the PNR train.
3. Eat sardines everyday. Try noodles for variety and soy sauce for some flavor.
4. Live along the railroad tracks.
5. Commute using the jeepney (don’t take the FX/shuttle pls.!) in these areas:

From Pasay Taft and through the labyrinth of Pasay Rotunda, try making it to Magallanes Village alive.
From Ayala Alabang, try making it unscathed to Better Living by way of the hellish Bicutan, Taguig Interchange.
From any point, go to Deparo in Novaliches without going crazy. Go through the wringer that is the public market (which, come to think of it, occupied the entire road before the advent of Bayani Fernando!).
Use the overpass under the Magallanes Cloverleaf any time of the day. Weave your way to the Magallanes MRT station without pissing off speeding motorists and without getting yourself almost killed either by being sideswiped by a truck or being run over by an oncoming train.
(SnNEPs, help me here with more examples. Baclaran has improved. Anything else?)

Billy Preston Portfolio: "At the time, the Beatles were heavily into the making of Let It Be, which was becoming a very unhappy chore because of tensions in the group. George brought Billy in to play keyboards on some of the tracks, as the orginal idea of Let It Be was to be a 'live' recording with no overdubbing, which left none of them to add things like a keyboard part. But, George also hoped that bringing in an outsider would make the others behave nicer and make the Let It Be set a happier place to be, and it worked, albeit temporarily. The Get Back single was credited as 'The Beatles with Billy Preston', the first time another artist was credited on a Beatles record, gaining him the title in some circles as 'the fifth Beatle'. In addition, although you can barely see it in the Let It Be movie, Billy played with the group on the famous 'Rooftop Concert', the Beatles last live appearance together."

Moving On - Children of the Children of God: "Give me your ideas!

I want to see your views on the proliferation of religion. Take the group we all came from. It started by one man who couldn’t fit into society, couldn’t make a living. He saw an opportunity & took it. He proclaimed himself to be a prophet. A whole new group was born. Today at large, there are so many similar groups, all saying that they are the only true ones & everyone else is going to hell unless they are saved by either adhering to their beliefs or getting saved by them. Face it; it’s not just the new groups that say it.
A group is born, they grow a bit; they need powerful & influential people to back them. The more power they have the more of a chance that they will become a recognized religion. Look at all the big religions in the World. They all started off small. If it wasn’t for the zeal of their followers & the time in history when killing was more accepted, they probably would have fizzled out. I do believe if the Family was in the 6-14 century & they had big backing, there would probably be big crusades with swords in order to force people to believe their way.
They (unfortunately for them) live in an era when they have to abide by the rules of a more civilized society. Good for us, in that we weren’t subject to more abuse & forced to expand their beliefs even more viciously.
I don’t expect others to share my views. I’m just a bit pissed off on how so many different groups believe they are the right ones & will cram down your throat (if you let them) all sorts of shit. Why don’t people see how much society has suffered through history at the hands of religious bigots. Whole civilizations have been wiped out. The Family is just another group trying to influence as many people as they can & get as much power as they can for their own ends."

Monday, January 23, 2006

.:Knowledge Power:.

.:Knowledge Power:.: "Health Tips ni Ka Ernie: Ubas
Ang ubas ay mainam kainin o gawing juice ng mga nais magbawas ng timbang dahil mababa ang calories na makukuha dito.

Natuklasan sa pagsusuri sa laboratoryo na ang ubas ay may biochemical na quercetin, isang uri ng plant pigment na nakatutulong magregularisa ng lebel ng cholesterol at makabawas sa peligro ng atake sa puso.

Mainam din ang pag-inom ng grape juice para sa may alta-presyon dahil nililinis nito ang mga bara sa ugat at puso.

Ang ubas ay diuretic o pampaihi kaya mainam ito sa alta-presyon at sa mga minamanas.

Makatutulong din ito sa mga may mahinang katawan at anemic.

Rekomendado din ito sa may mga bulutong, neuralgia at insomnia. Natuklasan din na mayaman ang ubas sa bioflavonoids na tumutulong upang maiwasan ang cancer."

Laoanganon.Com :: View topic - can we compete with them?: Never try to be better than someone else, learn from others and never cease trying to be the best you can be.
- John R. Wooden
The secret of success is constancy of purpose.
- Benjamin Disraeli
I can give you a six-word formula for success: "Think things through—then follow through."
- Edward Vernon (Eddie) Rickenbacker
I believe the true road to preeminent success in any line is to make yourself master of that line.
- Andrew Carnegie
What is success? I think it is a mixture of having a flair for the thing that you are doing; knowing that is not enough, that you have got to have hard work and a certain sense of purpose.
- Margaret Thatcher

The person determined to achieve maximum success learns the principle that progress is made one step at a time. A house is built a brick at a time. Football games are won a play at a time. A department store grows bigger one customer at a time. Every big accomplishment is a series of little accomplishments.
- David Joseph Schwartz, writer

.:Knowledge Power:.: "Health Tips ni Ka Ernie: Banaba
Ang diabetes ay sakit na namamana. Ito ay isa sa mga pangunahing sakit ng mga Pilipino.

Ngunit ang hindi alam ng karamihan, maaaring malunasan ang diabetes sa pamamagitan ng puno ng banaba.

Upang magamot ang diabetes, kumuha lang ng dahon at balat ng puno ng banaba. Pakuluan ito at inumin ang pinaglagaan.

Ang madalas na pag-inom nito ay makapagpapababa ng blood sugar.

Madali rin itong makapagpababa ng presyon ng dugo.

Hindi lang diabetes ang kayang gamutin ng banaba. Mabisa rin ito sa lagnat at diarrhea.

Ihalo lang sa tubig ang pinulbos na balat ng puno nito at inumin.

Mabisa rin ang banaba na panlunas sa namamagang mucus membrane ng bibig.

Mainam ring uminom ng pinaglagaan ng dahon ng banaba kung may sakit sa kidney at konstipasyon."

Sunday, January 22, 2006

Pacland's Philippine Boxing Forum :: View topic - LET'S NOT FORGET JIMREX JACA! HE TOO IS A WINNER!: "'If you pay peanuts, you get monkeys. That's why there are so many monkeys there in IT land!'-Old proverb"

Pacland's Philippine Boxing Forum :: View topic - My father-in-law currently at coma because of Pacman's fight: "'All good things in life come to those of whom patiently wait their turn' on the flip side 'seize the moment of triumph when its upon you.'"

Pacland's Philippine Boxing Forum :: View topic - WAIT LANG KAYO, APLOWD KO UN PAC-MORALES LABAN: "Happiness is when what you think, what you say, and what you do are in harmony. - 'Mahatma Gandhi'"

Ajax for Java developers: Build dynamic Java applications:

/*
* Returns a new XMLHttpRequest object, or false if this browser
* doesn't support it
*/
function newXMLHttpRequest() {

var xmlreq = false;

if (window.XMLHttpRequest) {

// Create XMLHttpRequest object in non-Microsoft browsers
xmlreq = new XMLHttpRequest();

} else if (window.ActiveXObject) {

// Create XMLHttpRequest via MS ActiveX
try {
// Try to create XMLHttpRequest in later versions
// of Internet Explorer

xmlreq = new ActiveXObject("Msxml2.XMLHTTP");

} catch (e1) {

// Failed to create required ActiveXObject

try {
// Try version supported by older versions
// of Internet Explorer

xmlreq = new ActiveXObject("Microsoft.XMLHTTP");

} catch (e2) {

// Unable to create an XMLHttpRequest with ActiveX
}
}
}

return xmlreq;
}

The Cost of GUIDs as Primary Keys:

Pros and Cons of GUIDs as Primary Keys

Let's say that we plan to use GUIDs for the primary keys. What are the advantages and disadvantages when compared to INTEGERs? We should always start with the positive, so here goes:

  • We get a more object ID–like datatype because each primary key typically will be unique for the complete database. This gives good effects, for example, when designing a custom solution for pessimistic locking (but that's another long story).

  • @@IDENTITY has been a source of problems when INSERT triggers have INSERTed rows into other tables with IDENTITYs. (You can use SCOPE_IDENTITY() in SQL Server 2000 to avoid this problem.)

  • You can move the creation processing of the values from the data tier to the business or consumer tiers. For example, the consumer can create complete structures of orders and details that can be sent all the way through the business tier to the data tier in one go, which can reduce the number of round trips. A more basic way of saying this is that you can get the ID value before you use it, not just afterward, as is the case with IDENTITYs.

  • NOTE

    In the case of .NET and ADO.NET, it's a big advantage to know the ID value at the time rows are added to the DataSet. Otherwise, for example, autogenerated INSERTs can't be used for master-detail relationships within the DataSet.

  • The span of values for GUIDs is enough for most scenarios. INTEGERs are not big enough for some scenarios. (By the way, with INTEGERs, you don't have to start the seed on 1. You can just as easily start it on the smallest negative INTEGER and thereby double the span of values.)

  • You can prepare for merge replication. When merge replication is to be used, each table to be replicated must have a GUID column (called ROWGUID in SQL Server). You also don't have to give each server in a merge replication scenario a unique set of values to use for the keys. The risk of duplicate GUIDs is so small that this shouldn't be a problem.

  • IDENTITY can't be used for tables in distributed partitioned views.

  • A GUID will not mean anything to the users. An INTEGER can be read, understood, and remembered. It's common to see INTEGER keys in the UI, and that might cause problems later.

  • You know what a nightmare it can be when doing a manual merge between two tables with INTEGERs as primary keys. Not only do you have to create a new sequence for the union of both tables, but you also must change all the foreign keys for all the dependent tables. If GUIDs are used, this sort of problem does not arise.

    NOTE

    The algorithm for generating GUIDs doesn't use the MAC address of the network cards in recent Windows versions anymore. Instead, it just creates a random value. In theory, this presents a risk of getting duplicate GUIDs, but, in practice, it shouldn't be a problem.

    The reason for excluding the use of the MAC address is that it not only couples users to GUIDs, but some network cards don't use unique MAC addresses.

    I will discuss this further when we reach the section about the COMBs. Stay tuned.

I'm not a salesman, so here are a few drawbacks:

  • There is a huge overhead in size. As I said, a GUID is four times larger than an INT. This is very important when it comes to indexes.

  • Portability can be a problem because not every database has GUID as a native datatype.

  • You can't use GUIDs with aggregates such as MIN. This is unfortunate when it comes to using WHILE plus an aggregate function, such as MIN or MAX for looping instead of a CURSOR. (Well, a workaround is to use a CONVERT or a CAST to CHAR(36) or BINARY(16) of the GUID before it's used in the aggregate, but watch out for performance problems with large tables.)

  • It's detrimental to developer-friendliness because it's really hard to edit GUIDs manually, to remember them when you browse the database, and so on. You have to get used to navigating the database by using SQL scripts, but this is not usually that much of a problem.

So, the overhead related to size is the main problem. Most developers seem to have an idea of how big the overhead is, but few have tested it. It's time that this was changed, so let's take a look at a few performance tests and get an idea of how large the overhead is.

bikoy.net » Home & Family: "Grocers
Posted on 12.22.05 by Victor @ 7:39 am

I miss simply bumming at home. For the past few days of my Christmas break, I’ve been helping out in our grocery store in Sta. Maria by manning the cash register, wiping shelves, and the most tedious job of all, encoding all the store’s merchandise in a barcode database manually. When I say manually, I mean manually encoding each merchandise’s 13-digit bar code by copying the digits from every item’s packaging then entering it (together with the item’s description and its price) into a computer program barcode system thingum. I’m doing it manually because we don’t have a USB-serial connector yet so I can’t use the barcode sensor gun thing for now. Gaad, I’m not even halfway through. I can’t even import the Excel worsheet of the inventory I encoded a few days ago, so I started doing this barcode database from scratch. My brother and I are taking shifts encoding though.

Oh well, I’ll ask for a day off one day. I still have some school work, internet surfing and DVD watching to catch up on. Hehe.
"

bikoy.net » Home & Family: "Manood ng balita mamaya
Posted on 07.21.05 by Victor @ 3:06 pm

In-interview ako kanina ni Iris Cruz ng GMA 7 tungkol sa blog ko. After almost five years of keeping my blog a secret from my parents and relatives, I have to admit to having one. Better that than bigla na lang nila akong makikita sa 24 Oras nang walang abiso. Hehe. Ang tangi ko lang namang ipinapangamba ngayon ay baka mapahamak ako o ang pamilya ko nang dahil sa mga pinagsusulat kong opinyon laban kay Gloria Arroyo. Baka bigla na lang i-hack ng gobyerno website ko o kaya ipa-kidnap ako o kaya tangglin sa trabaho si Papa. Ngek, it’s not as if I’m that influential. Pero ‘yon… nakakakaba rin. Sana walang ganong mangyari.

[Post-Scipt, 19:18] Haha. Ang OA ko naman. ‘Kala ko kung anong mainly-Gloriagate related ‘yung story ni Ms. Iris. At least, hindi na ‘ko masyadong kakabahan?

Filed under: Social Babble and College and Home & Family
Comments: 15 Comments"

bikoy.net » Home & Family: "May nag-iwan ng lalagyan ng langka sa ref nang walang takip. Ngayon, lahat ng pagkain sa ref lasang langka. Puto lasang langka, bibingka lasang langka, hotdog lasang langka, gatas lasang langka, pati tubig lasang langka. Sus.

May nagbigay ng tuta kay Mama dalawang linggo na ang nakakaraan. Hindi ko kinagawiang mag-alaga ng hayop. Ayaw na ayaw kasi ni Papa ng hayop. Kaya hindi ko naranasang magkaroon ng alagang hayop buong buhay ko. (Hm, sa totoo nagkaroon rin ako pero mga isda sa aquarium lang na kinasawaan ko rin nang kainin ng janitor fish lahat ng maliliit na isda). Nakakagigil man ang kakyutan ng tuta, ni hindi ko ‘to mahawakan nang higit sa paghaplos sa likod nito. Takot ako eh. Haha."

Saturday, January 21, 2006

Fresh-from-the-printer : Sushi, Gaming, and Sql Server..:

Sushi, Gaming, and Sql Server..

Tuesday rocked! Full day of development, night full of Sushi Japan and gaming. Working all day on an asp.net application with utterly no success could only be topped off with excessive eating and gaming. After work, I headed out with the wife for some food and drinks. Those of you who know me know I do not eat sushi, but I love the chicken and steak combo. After the meal and some much needed drinks, it was off to the local game store to pick up Mercenaries, a Lucas Arts (Xbox) game that was released yesterday. While I was there, I figured I would also jump into the 20th century an purchase a couple of Wavebirds for the GameCube (another one of the best ideas I have ever had). Anyway, long story short, I spent the rest of the night enjoying the new Lord of the Rings: Battle for Middle Earth PC Game, Metriod Echoes on the Gamecube, and Mercenaries. What a brilliant Tuesday night. It was reminiscent of the days of lore when I was single and full of dead time. I will most likely have to stay up later than normal tonight and make up for my fun, but what the hell right?

Anyway, now for the technical stuff. I have an interesting question which I am sure will spur some sort of debate, but here goes.. Guids or Identity fields in SQL Server? What's your poison? Personally I am a fan of Guids when needed, which is logically most of the time. Unfortunately we are all bound to get into positions where we are debating the solution with ex-access people who are less concerned with the correct way and the more comfortable way. Anyway, I wanted to give some of the developers out there some ammunition, so here goes:

Joe's top 5 reasons that Guids are better identifiers than integers:

  1. You will never run out of Guids, Identity has a limit of (2,147,483,647) and if you run out the query crashes

  2. Replication is much harder to perform using Identity fields than Guids. When using a guid, you know there will not be any servers with the same value.'

  3. There is a problem on tables with identities if the db server crashes. If it crashes while writing inserts, when the server is restarted, SQL Server will reset the next identity to a very large number/ For instance, if the current Identity is 50k when the server crashes, it will go up to 100,000,000. This is most likely a design feature, as the rollback does not know how many records are about to be written, so it bumps up the next identity to something it cannot hit. Since it does not reset the next Identity back down, a few of server crashes can easily put you over the 2 billion number pretty quick.

  4. Developers can create Guids on the fly allowing them to save a server trip to the database after an insert.

  5. Guids are far more secure and allow important id's to be use din a more general sense due to the lack of protection needed.

Having said that, the only downside to Guids is that they are a bit slower than and int (usually in the milo or pico seconds), but then again so is everything else. Having the guarantee and security of Guids far outweigh the minuscule hit in performance. Identifier is merely an adaptation of Access's "auto number" feature. It's really outdated and not preferred any more. Additionally, after 100,000 rows. guids actually perform better than numeric types on modern hardware due to the indexing optimizations (cascading of the Guid blocks) that MS has implemented.

What is your implementation of choice? Anyone out there know I am an idiot and want to tell me why. Let me know!

Patrick Wellink : GUID is not Always GOOD !!!!!!! (a true RTFM story): "No CITY and Country would neve be good clustered indexes.

As a rule of thumb, every table should have a clustered index. Generally, but not always, the clustered index should be on a column that monotonically increases--such as an identity column, or some other column where the value is increasing--and is unique. In many cases, the primary key is the ideal column for a clustered index.


City and country both share the same caracteristics. 'They don't Increase monotonically' and 'are not unique' that is why I would never create a clustered index on them.

Second....

I have seen the performance hit on a logging table. The logging table would grow to over 1.5 million records. The last insert took over 30 seconds and caused a Timeout.

So you really have to know hat you are doing if you are playing around with guids. If you do, it is ok to use them.
"

Google Groups : microsoft.public.sqlserver.programming: "When picking up the newly inserted row make sure you use SCOPE_IDENTITY()"

Google Groups : microsoft.public.sqlserver.programming: "I've only encountered one scenario where using a GUID made sense.
Especially when you consider their massive storage size.

If you think about it COM objects use GUID's and the reason is, when a COM
object is registered in the registry which is a crude database, different
developers have to make sure their GUID's don't collide. In other words,
records created in a other locations could be combined and possibly collide.
The random nature of a GUID protects against that.

The only time in my database work that I felt a GUID was justified as a PK
was a CRM application. Sales agents on the road and office staff would
create records which could be combined in the future. We needed to ensure
that new records created in any location could be combined without PK
collisions.

However, that doesn't mean I always use IDENTITY columns. Sometimes the
table itself has a unique field that will not change and that is sometimes a
good choice. "

Google Groups : microsoft.public.sqlserver.programming: "The beauty of the GUIDS is that databases can be completely independant
for as long as you want, and then merged into one single database
without colliding primary keys.

This makes them ideal for offline work where users get an independant
copy of the main database, are free to make changes and additions, and
subsequently synchronize with the main database. "

Google Groups : microsoft.public.sqlserver.programming: "Hi J.R.

You've given great, in-depth answer that covers a number of the important
differences between GUID / Integer.

One thing I want to address in your post though is: 'I feared the counter
could exceed 2 billion.'. Perhaps you've worked this out since, but just so
all is clear to whoever reads your post, identity is not limited to 2
billion in SQL 2K as columns with the integer type BIGINT (8 byte) can also
be used for identity which allow for values from -9,223,372,036,854,775,808
through 9,223,372,036,854,775,807.

Another classic scenario where GUIDs can be advantageous over IDENTITY is
where there the application design needs to know the key between master /
detail records at the application layer, BEFORE insertion into the database.
This can eliminate a network round trip between the application layer and
the DB just to generate a key in such a scenario. This is often presented in
argument about the advantages / disadvantages of IDENTITY / GUID as an
advantage for GUID, especially where the benefit of the application layer
knowing the ID before insertion into the DB out-weighs the draw-back of the
extra storage size footprint of a GUID. "

Google Groups : microsoft.public.sqlserver.programming: "I've only encountered one scenario where using a GUID made sense.
Especially when you consider their massive storage size.

If you think about it COM objects use GUID's and the reason is, when a COM
object is registered in the registry which is a crude database, different
developers have to make sure their GUID's don't collide. In other words,
records created in a other locations could be combined and possibly collide.
The random nature of a GUID protects against that.

The only time in my database work that I felt a GUID was justified as a PK
was a CRM application. Sales agents on the road and office staff would
create records which could be combined in the future. We needed to ensure
that new records created in any location could be combined without PK
collisions.

However, that doesn't mean I always use IDENTITY columns. Sometimes the
table itself has a unique field that will not change and that is sometimes a
good choice. "

Use Globally Unique Identifiers in Access and SQL Server: "You can also use GUID values to randomly select rows from a table or view, and you don't have to create a uniqueidentifier column to take advantage of this technique. You can use the NEWID() function to generate GUID values in a query. To illustrate this unique use, execute the following query in SQL Server Desktop or SQL Server:


SELECT TOP 10 dbo.Products.ProductID, dbo.Products.ProductName,
dbo.Products.UnitPrice
FROM dbo.Products
ORDER BY NEWID()

The resultset contains 10 seemingly random product records (see Figure 2). This technique is beneficial when featuring random products on a Web site or selecting random records for an audit."

heheh anong ginagawa ng boxing sa tech blog ko :D

THE PACMAN HYPE:


PhilBoxing.com


LAS VEGAS -- When he arrived last Monday at the Wynn Resort for his epic rematch with Erik Morales, Manny Pacquiao brought with him the plangent sounds of hype.

Ever flamboyant, PacMan stepped out of a fancy $65,000 Porsche Cayene which he recently bought in Hollywood. Manny was accompanied by an entourage the size of a Sinulog contingent.

Morales' arrival, meanwhile, was quiet as a sleeping brook. He descended from a gleaming SUV, followed only by another SUV. A head count of the Morales group did not exceed six, and they all shut their mouth.

When Manny Pacquiao entered the Mouton Ballroom for the final pre-fight press conference the other day, the GenSan brawler was decked in a Team Pacquiao outfit of sweat pants and windbreaker. He wore a Tar Heel cap and as he took over the microphone for a short speech, Manny was funny and amusingly loquacious.

Erik Morales, meanwhile, was all business.

He was attired like someone who was about to attend Sunday morning mass. He wore a pair of brown suede pants and a white long-sleeve shirt was tucked neatly beneath his brown sweater. Erik didn't say much, but he silenced the pro-Filipino crowd when he told a transltor: "I'm in the best shape of my life."

The contrast between Pacquiao and Morales is as discernible as night and day.

Manny is engaging, Erik is impossibly shy. Manny likes to gamble, Erik would rather tickle the strings of a guitar. Manny is comfortable with his celebrity, Erik burns under the spotlight.

Yes, even in boxing, opposites do attract. And that is why Pacquiao versus Morales is an easy sell. It bleeds with so many storylines its a pay-per-view bargain at $44.95.

At the end of the day, however, the only difference that will matter is this: Manny likes to brawl, Erik loves to stay from a distance and win a tactical fight. Whoever gets his way this Sunday wins this fight.

Manny Pacquiao has more titles than the Queen of England. He is an actor, rapper, sex symbol, pool shark, cockfighting afficionado, product endorser, and philantrophist.

His warts and all, Manny is genuinely a good kid. And so like the millions of other Pinoys I hope he beats the bejeebies out of Morales, makes more money than the Sultan of Brunei, and live happily ever after.

But life isn't that easy. In Manny's case, there us a huge roadblock named Erik Morales. And it smells with a lot of dnager.

Morales is likeable, too. He does a lot of the charity work that Manny is famous for, but shy as a shrinking violet, Erik's generosity isn't as well-chronicled as PacMan's.

Inside the ropes, Erik's greatest asset against Pacquiao is the Mexican's length. At 5-foot-8, Morales stands an inch and a half taller than Manny. Erik has a reach of 72," a five-inch advantage over PacMan.

It's not the length per se that frightens me about this fight. It's the fact that Morales knows how to use that advantage. In their intial slugfest last March 19 at the MGM Grand Garden for instance, Erik nailed Manny with 98 of 307 jabs, a mind-bending 31.9 percent accuracy clip.

Will Manny finally have an answer to Morales' dreaded weapon? Can he bypass that jab as he seeks to engage? Will he have enough gas to last 12 rounds?

I wish I knew the answers. But we're gonna find out this Sunday. Together. And with our fingers crossed.

Online Data Backup | value of business data, cost of data loss.

Online Data Backup | value of business data, cost of data loss.: "Value of Business Data

contd..

As a business leader you value your business and the business data at its heart: client records, proposals, invoices, production, lists, presentations. Loss of data can disrupt business life and destroy business value. Be it human error, theft flood or virus attack.

Your two most important assets are data & time. Lose access to data and you’ve lost time. On average 20Mb of data takes 30 hours to build and is worth £50 000.

Most businesses backup data using tape backup; but is it done daily? Who in the company is responsible for making sure it happens? Are they qualified and is it what they're paid for? Are tapes stored securely off-site? Will the restore actually work when it's needed?

Here are some sobering statistics: 99% of all business do not do a daily backup, 60% of backups are incomplete, 50% of restores fail, only 25% of tapes stored off-site and end user compliance with backups is only 8%.

And the consequences of this can be severe:

'On average, by the 6th day of a major data loss, companies experience a 25% loss in daily revenue. By day 25 it is 40%.'

'43% of companies that experience a severe data loss disaster, and that have no recovery plan in place, never re-open.'

'The average cost to a UK SME of a virus attack is £843 with an average downtime of 7.2 hours.'

'43% of companies that experience a severe data loss disaster, and that have no recovery plan in place, never re-open.'

What is more, the law insists that businesses take care:

'You must safeguard your own or anyone else's data, by appropriate precautions against loss, corruption or unauthorized disclosure' - Data Protection Act, 1998"

PC virus celebrates 20th birthday | The Register:
PC virus celebrates 20th birthday
Many unhappy returns
By John Leyden
Published Thursday 19th January 2006 20:52 GMT

Analysis Today, 19 January is the 20th anniversary for the appearance of the first PC virus. Brain, a boot sector virus, was let loose in January 1986. Brain spread via infected floppy disks and was a relatively innocuous nuisance in contrast with modern Trojan, rootkits and other malware. The appearance of the first Windows malware nonetheless set in train a chain of events that led up to today's computer virus landscape.

Boot sector viruses ceased to appear when floppy discs went out of fashion but they continued to be a nuisance between 1986 to 1995, when internet technology started to penetrate the consumer market. These types of viruses relied on people to exchange infected discs and virus outbreaks often took months to spread.
Click Here

The creation of macro viruses, which exploited security weaknesses in Microsoft word and other applications, meant that malware outbreaks peaked after days instead of weeks and months. Macro viruses ruled the roost for around four years between 1995 and 1999 before email became the main vector for viral distribution.

Harnessing the internet meant that the time it took the first email worms, such as the Love Bug, to spread dropped from days to hours. Email worms such as the Love Bug and Melissa caused widespread disruption and confusion in 1999 before they were brought to heel.

By 2001, network worms such as Blaster were created that automatically and indiscriminately infected Windows PCs without adequate protection. Email and network worms remain a problem today but the greatest problem these days is posed by key-logging Trojans designed to snoop on user's private information, such as online account details, and the many strains of malware that turn infected PCs into zombie drones under the control of hackers.

The biggest change over the last 20 years has been in the motives of virus writers rather than in the types of malware they've cooked up, according to anti-virus firm F-Secure.

"The most significant change has been the evolution of virus writing hobbyists into criminally operated gangs bent on financial gain," said F-Secure's chief research officer Mikko Hypponen. “This trend is showing no signs of stopping."

"There are already indications that malware authors will target laptop WLANs as the next vector for automatically spreading worms," he added. ®

PC virus celebrates 20th birthday | The Register:

PC virus celebrates 20th birthday

Many unhappy returns

Published Thursday 19th January 2006 20:52 GMT

Analysis Today, 19 January is the 20th anniversary for the appearance of the first PC virus. Brain, a boot sector virus, was let loose in January 1986. Brain spread via infected floppy disks and was a relatively innocuous nuisance in contrast with modern Trojan, rootkits and other malware. The appearance of the first Windows malware nonetheless set in train a chain of events that led up to today's computer virus landscape.

Boot sector viruses ceased to appear when floppy discs went out of fashion but they continued to be a nuisance between 1986 to 1995, when internet technology started to penetrate the consumer market. These types of viruses relied on people to exchange infected discs and virus outbreaks often took months to spread.

The creation of macro viruses, which exploited security weaknesses in Microsoft word and other applications, meant that malware outbreaks peaked after days instead of weeks and months. Macro viruses ruled the roost for around four years between 1995 and 1999 before email became the main vector for viral distribution.

Harnessing the internet meant that the time it took the first email worms, such as the Love Bug, to spread dropped from days to hours. Email worms such as the Love Bug and Melissa caused widespread disruption and confusion in 1999 before they were brought to heel.

By 2001, network worms such as Blaster were created that automatically and indiscriminately infected Windows PCs without adequate protection. Email and network worms remain a problem today but the greatest problem these days is posed by key-logging Trojans designed to snoop on user's private information, such as online account details, and the many strains of malware that turn infected PCs into zombie drones under the control of hackers.

The biggest change over the last 20 years has been in the motives of virus writers rather than in the types of malware they've cooked up, according to anti-virus firm F-Secure.

"The most significant change has been the evolution of virus writing hobbyists into criminally operated gangs bent on financial gain," said F-Secure's chief research officer Mikko Hypponen. “This trend is showing no signs of stopping."

"There are already indications that malware authors will target laptop WLANs as the next vector for automatically spreading worms," he added. ®