If your sql query is something like
$sqlQuery = “select * from test for xml raw('MyItem'), elements, root('MyRoot')”;
As a work around you can wrap it inside another select statement.
$sqlQuery = "select (" . $sqlQuery . ")";
This query will return the record set containing only one row and one column and which will be your xml. You can get the xml by using odbc_result($queryResult,1);
If the xml is too big you may need to configure max_execution_time, memory_limit and odbc.defaultlrl in the php.ini file according to your requirement.
Here I am describing some technical issues which I faced and how I fixed them. I hope this will be helpful for those who may face the same.
Friday, May 29, 2009
Tuesday, May 19, 2009
How to print out a variable’s value/message from a MySQL stored procedure?
You can use a simple select inside the stored procedure.
Example:
DELIMITER //
DROP PROCEDURE IF EXISTS printTest//
CREATE PROCEDURE printTest(myVar int)
BEGIN
IF myVar <> 0 THEN
SELECT myVar;
ELSE
SELECT 'Got 0';
END IF;
END//
DELIMITER ;
Example:
DELIMITER //
DROP PROCEDURE IF EXISTS printTest//
CREATE PROCEDURE printTest(myVar int)
BEGIN
IF myVar <> 0 THEN
SELECT myVar;
ELSE
SELECT 'Got 0';
END IF;
END//
DELIMITER ;
Monday, May 11, 2009
MySQL – Create Table – Difference between TYPE and ENGINE
The syntax 'TYPE' is deprecated and will be removed in MySQL 5.2. Please use 'ENGINE' instead.
Eg:
CREATE TABLE my_table
(
my_key INTEGER NOT NULL,
my_data VARCHAR(20) NOT NULL
PRIMARY KEY (my_key)
) ENGINE = INNODB;
Eg:
CREATE TABLE my_table
(
my_key INTEGER NOT NULL,
my_data VARCHAR(20) NOT NULL
PRIMARY KEY (my_key)
) ENGINE = INNODB;
Subscribe to:
Posts (Atom)