Archive for the ‘MySQL’ Category

Crystal Reports Patch to Handle NULL Dates

Tuesday, April 30th, 2013

Background

The Mertech Flex2SQL GUI migration tool and Mertech drivers use 01/01/0001 as the default NULL value for DataFlex DF_DATE and DF_DATETIME fields to be consistent with the DataFlex dummy zero date setting.

Note: The MSSQL drivers use 01/01/1753 as the default null value.
Note: The MySQL drivers (Windows versions 12.0.6020.0 and 12.1.6020.0 and SCO version 11.0.5702.1) were modified in March of 2012 to use 00/00/0000 as the default NULL value
.

Problem

Crystal Reports versions 9.0 and above have a lower date bound of 01/01/0100.

Solution

A solution is provided by Crystal Reports and described in ADAPT00175452 Patch ID: 36375929:
(more…)

Assigning RECNUM values in MySQL tables

Tuesday, April 30th, 2013

Problem

A customer reported a problem synchronizing two MySQL databases. One database resides on the Web and the other database resides on a PC. The databases are updated independently and each uses the auto increment RECNUM column as a unique index. When a two-way synch is performed between the databases, duplicate records are flagged because records in each database were assigned the same RECNUM value.

Solution

Eliminate the auto increment option for RECNUM and assign odd RECNUM values for one environment and even for the other.

(more…)

Multiple embedded SQL statements

Tuesday, June 30th, 2009

While complex embedded SQL statements will let you do a lot of work in one statement, it is sometimes necessary to nest SQL statements to get the job done.

Using cursor handling lets you easily nest multiple embedded SQL statements.

Consider the scenario where we want to iterate through all orders with a specific status, and for each order we want to calculate the total of that order.

Of course, in this case it would be pretty easy to write one SQL statement that returns everything, but for the example we will use two nesting calls:


// Example
Use Mertech.inc
Integer iCursor1 iCursor2
Integer iCustomer
String sName
Number nOrder nTotal

login 'Server' 'User' 'Passwd' 'Driver'

set_database_name to 'DataBase'
sql_use_database 'DataBase'

Sql_Open_Cursor_Stmt to iCursor1
Sql_Set_Stmt to "select customer_number,name from customer order where status = 'Y' by customer_number"
Sql_Prepare_Stmt
Sql_Execute_Stmt

Repeat
// Back to the main cursor
Sql_Set_Current_Cursor_Stmt to iCursor1
Sql_Fetch_Next_Row into iCustomer sName
If (Found) Begin
// Open a new cursor to the new stmt
Sql_Open_Cursor_Stmt to iCursor2

Sql_Set_Stmt To ("Select sum(order_total) from Orderhea where customer_number = " + trim(iCustomer))
Sql_Prepare_Stmt
Sql_Execute_Stmt
Sql_Fetch_Next_Row into nOrder
If (Not(Found)) Move 0 to nTotal

Sql_Close_Cursor_Stmt iCursor2

// nTotal has the Order total for this current customer
// Your code here
Indicate Found True
End
Until (Not(Found))
// End Example

The keys in the example are the calls to Sql_Open_Cursor_Stmt and Sql_Set_Current_Cursor_Stmt which allows you to switch between two open recordsets.

Using Auto-Reconnect in a Cluster Situation

Tuesday, February 24th, 2009

For customers who have a full blown cluster just as in database mirroring, typically when testing a failover, there is a hiccup of a few seconds. Our auto-reconnect feature has been able to detect the failover and continue working without problems.

(more…)

New Command: SQL_ENABLE_RECONNECT

Monday, February 16th, 2009

SQL_ENABLE_RECONNECT allows the MySQL Driver to automatically reconnect to the server after the connection has been closed by a time-out. In the MySQL my.ini file you can set a system variable called wait_timeout to set the number of seconds that the server will wait on a non-interactive connection before it closes the connection. The default value for this variable is 28800 (8 hours). See also the MySQL manual under Server System Variables and more specifically the variables wait_timeout and interactive_timeout. (more…)