We can do it with following code,
if (variablename == undefined){
variablename = 'XYZ';
}
But for some reason, firefox will throws error with above code. So the solution to that problem is,
if(window.variablename == undefined){
window.variablename = 'XYZ';
}
Search This Blog
30 December 2010
29 December 2010
How to insert NULL value in PostgreSQL date column?
The simple query is like,
INSERT INTO table (date_field) VALUES (NULL);
But when we try to run this insert query through PHP application, where we don't know whether the variable is NULL or contain some value, it starts giving error. Here we need to do some programming and query manipulation as shown below,
<?
if(empty($dbDate)) $dbDate = '0000-00-00';
$myQry = "INSERT INTO table (date_field) VALUES (CASE $dbDate WHEN 0 THEN NULL ELSE TO_DATE('{$dbDate}', 'YYYY-MM-DD') END)";
/*Remaining code comes here */
?>
INSERT INTO table (date_field) VALUES (NULL);
But when we try to run this insert query through PHP application, where we don't know whether the variable is NULL or contain some value, it starts giving error. Here we need to do some programming and query manipulation as shown below,
<?
if(empty($dbDate)) $dbDate = '0000-00-00';
$myQry = "INSERT INTO table (date_field) VALUES (CASE $dbDate WHEN 0 THEN NULL ELSE TO_DATE('{$dbDate}', 'YYYY-MM-DD') END)";
/*Remaining code comes here */
?>
Labels:
PHP,
PostgreSQL
28 December 2010
How to Enable Macro in Microsoft Office Excel 2007?
- Open Microsoft Office Excel 2007 Click on Office logo at the very Left hand Top
- Then select "Excel Options", select "Trust Centre" on left hand side and click on "Trust Centre Settings"
- Select "Macro Settings" and then select "Enable all Macros", if Macros are also written in Visual Basics programming, put check before "Trust access to the VBA project object model"
Labels:
Windows Trouble Shooting
26 December 2010
How to find Serial number of machine?
To find out the serial number of the machine, go to windows command prompt and type following command on the command prompt,
IdentifyingNumber Name Vendor
L3ZZ896 5897X7Y LENOVO
Where IdentifyingNumber is Serial number of machine, Name is Productid and Vendor is the name of manufacturer
- Start > cmd
- C:\Users\XYZ > wmic csproduct get identifyingnumber,vendor,name
IdentifyingNumber Name Vendor
L3ZZ896 5897X7Y LENOVO
Where IdentifyingNumber is Serial number of machine, Name is Productid and Vendor is the name of manufacturer
Labels:
Windows Trouble Shooting
22 December 2010
CONCAT_WS for PostgreSQL
PostgreSQL do not have function like CONCAT_WS of MySQL, but writing the query as given below we can do much more...
SELECT ARRAY_TO_STRING(ARRAY[initial, firstname, lastname] , ' ') AS user
FROM users
Same as CONCAT_WS function, the above query will ignore fields which are having NULL values, and return the concatenation of remaining fields. But if your fields contains blank value, modify the above query as given below, to get the proper result
SELECT ARRAY_TO_STRING(ARRAY[
CASE title WHEN '' THEN NULL ELSE title END,
CASE firstname WHEN '' THEN NULL ELSE firstname END,
CASE lastname WHEN '' THEN NULL ELSE lastname END], ' ') AS user
FROM users
SELECT ARRAY_TO_STRING(ARRAY[initial, firstname, lastname] , ' ') AS user
FROM users
Same as CONCAT_WS function, the above query will ignore fields which are having NULL values, and return the concatenation of remaining fields. But if your fields contains blank value, modify the above query as given below, to get the proper result
SELECT ARRAY_TO_STRING(ARRAY[
CASE title WHEN '' THEN NULL ELSE title END,
CASE firstname WHEN '' THEN NULL ELSE firstname END,
CASE lastname WHEN '' THEN NULL ELSE lastname END], ' ') AS user
FROM users
Labels:
PostgreSQL
18 December 2010
Migrate Data from Access 97 to PostgreSQL
To migrate data from Access to PostgreSQL, so many tools are available online. I did try to migrate data with few tools, but no success. I encounter issues with the tables which has boolean fields and with the tables in which access date() and time() function are being used to set default value of a column.
The best way to migrate data from Access to PostgreSQL database, I found is through PostgreSQL ODBC driver. To check how to install and setup PostgreSQL ODBC driver go to Install & Setup PostgreSQL ODBC Driver . Once finished with installation and setup of PostgreSQL ODBC driver, you are ready to migrate the data.
How to migrate data from Access to PostgreSQL using PostgreSQL ODBC?
The best way to migrate data from Access to PostgreSQL database, I found is through PostgreSQL ODBC driver. To check how to install and setup PostgreSQL ODBC driver go to Install & Setup PostgreSQL ODBC Driver . Once finished with installation and setup of PostgreSQL ODBC driver, you are ready to migrate the data.
How to migrate data from Access to PostgreSQL using PostgreSQL ODBC?
- Open the access database, select the table, then click on file, Save As/Export, a “Save As” popup will appear, select “To an external file or database” radio button and click ok.
- Then in the new popup for “Save as type” select “ODBC database”.
- An Export window will appear, change the table name if required, or just click ok.
- “Select Data Source” window will appear, select your PostgreSQL DSN, that you have created as mentioned above. And click ok.
- Selected table will get exported to your postgres database.
Labels:
PostgreSQL
15 December 2010
Install & Setup PostgreSQL ODBC Driver
Install PostgreSQL ODBC Driver
- Download the latest PostgreSQL 32-bit ODBC Driver by choosing a mirror from http://wwwmaster.postgresql.org/download/mirrors-ftpand then navigating to the odbc/versions/msi/ folder. The current version is psqlodbc_08_03_0100.zip which was released Jan-22-2008.
- Unzip psqlodbc_08_03_0100.zip
- Run the psqlodbc.msi file
- Click Start, Control Panel, then switch the control panel to “Classical View”, if it's already not in classical view or select "System and Security" category.
- ODBC located inside Administrative Tools folder. Double click ODBC Data Sources. ODBC Data Source Administrator window displays.
- Select File DSN tab and click Add button, select “PostgreSQL Unicode” from the popup opened.
- Type in a name “pgCon” for "Create New Data Source” and Click Next
- Then Click Finish and fill in relevant server, db, username and password.
- Click the Connection button and uncheck Bools as char as shown in Manager Connection Page 1
- Click the Page 2 button and check True is -1, and uncheck updateable cursors as shown ODBC Manager Connection Pg 2 and then click OK
- A DSN (Data Source) with name “ pgCon ” is created and ready to use...
Labels:
PostgreSQL
12 December 2010
How to Fix Corrupted Vista Profile?
Follow the following steps in order to recreate a user’s Vista profile when it gets corrupted.
- log into user’s workstation with your admin account
- Delete user’s local profile on C: drive under users folder
- Click on Start and run and type “Regedit”
- This will open Registry Editor Window
- Click on + sign besides HKEY_LOCAL_MACHINE
- Click on + sign besides SOFTWARE
- Click on + sign besides MICROSOFT
- Click on + sign besides WINDOWS NT
- Click on + sign besides CURRENT VERSION
- Click on + sign besides PROFILELIST and delete the SID number points to user name in Right side Pane
- Close Registry Editor window.
- Now RDP into the Server hosting that user’s profile.
- Go to Profiles folder and locate the user’s windows vista profile
- Rename this profile folder
- Ask the user to login and then logoff
- Now copy the user’s favorites and Desktop icons from the renamed profile folder to the new profile folder
- Ask user to login again and this will create a new profile for the user successfully.
Labels:
Windows Trouble Shooting
11 December 2010
How to fix network printer dirver error for HP printers
- Delete the printer having printing problem from the printer window.
- Click on Start and Run and type in Regedit.
- This will open Registry editor window.
- Click on + sign besides HKEY_LOCAL_MACHINE
- Click on + sign besides SYSTEM
- Click on + sign besides CurrentControlSet
- Click on + sign besides Control
- Click on + sign besides Print
- Click on + sign besides Environments
- Click on + sign besides Windows NT x86
- Click on + sign besides Drivers
- Click on + sign besides Version-3
- Right click on the printer name and delete it
- Click on + sign besides Monitors and delete the folder for that printer
- Close the Registry Editor
- Go to System32 folder under C:\Windows\System32
- Click to open spool folder and click to open drivers folder
- Click to open w32x86 folder and click on 3 folder
- Under 3 folder delete all the instances for the printer giving problems
- Reboot computer and install the printer again
- It should work fine now.
Labels:
Windows Trouble Shooting
Subscribe to:
Posts (Atom)