tag:blogger.com,1999:blog-50460534946524280772024-03-12T20:11:23.144-07:00Technology TalkEktahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.comBlogger45125tag:blogger.com,1999:blog-5046053494652428077.post-40549406812332363632014-02-11T11:12:00.000-08:002014-02-11T12:27:09.065-08:00How to check if at least one field is set in a form before submiting using JQuery<div dir="ltr" style="text-align: left;" trbidi="on">
I have a form with many fields (Textbox, Listbox, Checkbox, Radio Button, File box, Text Area) in my PHP page. When submitting the form, I need to check at least one field must be set. If it’s not I don’t want to submit the form. The form is having lots of control, so it’s not a good idea to go through each control to check if a value is set. So here is a JavaScript function which will make the job very easy.<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-M6xWwNQj_rg/UvqHdq3tQEI/AAAAAAAABpI/l3Kw_H8nGVo/s1600/valid2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-M6xWwNQj_rg/UvqHdq3tQEI/AAAAAAAABpI/l3Kw_H8nGVo/s1600/valid2.png" height="308" width="577" /></a></div>
<br />
<br /></div>
Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com2tag:blogger.com,1999:blog-5046053494652428077.post-61140174037029725062012-01-27T12:47:00.001-08:002012-01-27T14:10:34.849-08:00Query to find missing Id's in MySQL<div dir="ltr" style="text-align: left;" trbidi="on"><span style="font-family: inherit;"><br />
</span><br />
<pre><span style="font-family: inherit; font-size: medium;"><span style="color: #993333; font-weight: bold;">SELECT</span> a<span style="color: #66cc66;">.</span>id<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">AS</span> start<span style="color: #66cc66;">,</span> MIN<span style="color: #66cc66;">(</span>b<span style="color: #66cc66;">.</span>id<span style="color: #66cc66;">)</span> <span style="color: #66cc66;">-</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">AS</span> end
<span style="color: #993333; font-weight: bold;">FROM</span> testtable <span style="color: #993333; font-weight: bold;">AS</span> a<span style="color: #66cc66;">,</span> testtable <span style="color: #993333; font-weight: bold;">AS</span> b
<span style="color: #993333; font-weight: bold;">WHERE</span> a<span style="color: #66cc66;">.</span>id <span style="color: #66cc66;"><</span> b<span style="color: #66cc66;">.</span>id
<span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> a<span style="color: #66cc66;">.</span>id
<span style="color: #993333; font-weight: bold;">HAVING</span> start <span style="color: #66cc66;"><</span> MIN<span style="color: #66cc66;">(</span>b<span style="color: #66cc66;">.</span>id<span style="color: #66cc66;">)</span></span></pre></div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-58306598214210093862011-09-09T13:09:00.000-07:002011-09-09T13:23:52.519-07:00Calling Javascript when JQuery UI Tab is selected or clicked<div dir="ltr" style="text-align: left;" trbidi="on"> Recently I had a requirement in one of my project. I am using JQuery UI Tabed view and what I required was to send an Ajax call when a tab is selected. At the start I find it tough to capture onClick or onSelect event of tabs. But later on I got the solution, I would like to share it with all of you. In below given example I put both solutions that I found to capture if a tab is clicked or selected.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-aQMOhBhRo0w/Tmp1z0M_1-I/AAAAAAAABVc/C9RRg9GBba8/s1600/img3.GIF" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://4.bp.blogspot.com/-aQMOhBhRo0w/Tmp1z0M_1-I/AAAAAAAABVc/C9RRg9GBba8/s1600/img3.GIF" /></a></div><br />
</div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com1tag:blogger.com,1999:blog-5046053494652428077.post-15699573036989351962011-05-26T19:17:00.000-07:002011-05-26T19:17:07.238-07:00Creating a scrollable table with fixed row and column<div dir="ltr" style="text-align: left;" trbidi="on">To create a Scrollable Table you will need to download JQuery library and jquery.fixer plugging from <a href="http://plugins.jquery.com/project/fixer">http://plugins.jquery.com/project/fixer</a><br />
<br />
On this page when you click on download link, a zipped folder will get downloaded. Unzip that folder and then copy "jquery.js" and "jquery.fixer.js" files into the folder where your webpage exist.<br />
<br />
To create a scrollable table into your webpage, all you need to do is include "jquery.js" and "jquery.fixer.js" files in your webpage and then on document.ready event, for the table on which you want to enable scrolling call fixer function from "jquery.fixer.js" file. For more detail, see the demo code given below.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-X_7AHmnmTLA/Td8JPdEz_mI/AAAAAAAABT8/2t7IduI-Cdo/s1600/img1.gif" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-X_7AHmnmTLA/Td8JPdEz_mI/AAAAAAAABT8/2t7IduI-Cdo/s1600/img1.gif" t8="true" /></a></div><br />
</div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com7tag:blogger.com,1999:blog-5046053494652428077.post-56549825416387631182011-05-16T17:18:00.000-07:002011-05-19T07:39:06.411-07:00How to set the focus to a child window without refreshing it?<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"></div>Recently I had a requirement, in my web page which contain four links, each link open a popup window. I am using a common JavaScript function to open popup window as given below,<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-4BazGe5yhOI/TdRdAeOnEdI/AAAAAAAABTg/KIuB8G-qZwo/s1600/img2.gif" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" j8="true" src="http://4.bp.blogspot.com/-4BazGe5yhOI/TdRdAeOnEdI/AAAAAAAABTg/KIuB8G-qZwo/s1600/img2.gif" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Now when click on a link, it opens a popup window, which contain a data entry form, I entered some information into that form. Then I need to review other information, from other popup window, so I go back to the main window, click on another link, a new popup window get open which contain the information I need to review. I get the information and close this popup window, so now I am on the main window, then again I click on the link for that data entry form, so the popup window comes up but I lost the information that I have entered, that's because I am relodiing the popup window once again. So here the question arise,<br />
<ol><li>Is their any way, I can check out the if popup window is already open from parent window, without having the object of popup window just by the name?</li>
<li>If the popup window is already open how can I just set the focus to it, rather then reloading it?</li>
<li>Can I refer a popup window from a parent window, even after refreshing the parent window? </li>
</ol>And finally I got the solution for all the questions. Make some changes in the function as given below and it start working the way I want it,<br />
<a href="http://2.bp.blogspot.com/-sh7d54l7Sow/TdRhBFXrlBI/AAAAAAAABTk/XbSE1VOxdeE/s1600/img3.gif" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" j8="true" src="http://2.bp.blogspot.com/-sh7d54l7Sow/TdRhBFXrlBI/AAAAAAAABTk/XbSE1VOxdeE/s1600/img3.gif" /></a><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b>Let us see how it works,</b><br />
<ul style="text-align: left;"><li>When attempt to open the window again with the same name in the second parameter of the windows open method, you will to get the windows handle. If the window is already open, it will return the handle of the opened window or it will open a new window and return it's handle</li>
<li>The first parameter (the url) is passed as an empty string, so the page will not get redirected which will result in the contents of the window remaining unchanged.</li>
</ul><div style="text-align: left;"><b>Note</b> : You cannot get the handle if the page is not on the same host as its opener</div></div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com13tag:blogger.com,1999:blog-5046053494652428077.post-3270550734210525442011-03-13T15:22:00.000-07:002011-03-13T15:22:39.729-07:00Add & Remove values to a Multi Select list box using JQuery<div dir="ltr" style="text-align: left;" trbidi="on">This control is used to add value to a multiselect list box. And to remove multiple values fron this list box.<br />
<br />
<br />
<strong>Where this control can be useful? </strong><br />
Consider the requirement for adding attributes along with it values (eg. attribute colour with values like red, green, blue... where the number of attribute values are not fixed). Is's good to use this control for adding multiple attribute value, rather then having a seperate screen to add the values.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://lh3.googleusercontent.com/-08w5oSm1itw/TX1DiLXVBiI/AAAAAAAABRk/UQzRlzUtbAI/s1600/exa3.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" q6="true" src="https://lh3.googleusercontent.com/-08w5oSm1itw/TX1DiLXVBiI/AAAAAAAABRk/UQzRlzUtbAI/s1600/exa3.png" /></a></div></div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-87242335817857659082011-03-13T14:52:00.000-07:002011-03-13T15:20:13.630-07:00JQuery Script to add table row and column dynemically<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://lh6.googleusercontent.com/-ngwYqoz3Ve4/TX1AyBy4EtI/AAAAAAAABRg/c7vyEnlQby0/s1600/exa2.png" imageanchor="1" style="clear: left; cssfloat: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" q6="true" src="https://lh6.googleusercontent.com/-ngwYqoz3Ve4/TX1AyBy4EtI/AAAAAAAABRg/c7vyEnlQby0/s1600/exa2.png" /></a></div><div class="separator" style="clear: both; text-align: center;"></div></div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-53620980703767703562011-02-24T17:55:00.000-08:002011-02-24T18:02:01.568-08:00New to Jquery?<pre>First step to learn JQuery is, quickly go through following simple JQuery Tutorial
<a href="http://www.w3schools.com/jquery/">http://www.w3schools.com/jquery/</a>
Here are few other really good resources to learn JQuery,
<a href="http://net.tutsplus.com/articles/web-roundups/jquery-for-absolute-beginners-video-series/">http://net.tutsplus.com/articles/web-roundups/jquery-for-absolute-beginners-video-series/</a>
<a href="http://www.bennadel.com/resources/presentations/jquery/video/index.htm">http://www.bennadel.com/resources/presentations/jquery/video/index.htm</a>
Here are some really good JQuery plugins
<a href="http://plugins.jquery.com/">http://plugins.jquery.com/</a>
<a href="http://jursza.net/dev/jjmenu/#">http://jursza.net/dev/jjmenu/#</a>
<a href="http://datatables.net/examples/basic_init/scroll_y_theme.html">http://datatables.net/examples/basic_init/scroll_y_theme.html</a>
<a href="http://plugins.jquery.com/project/fixer">http://plugins.jquery.com/project/fixer</a></pre>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com3tag:blogger.com,1999:blog-5046053494652428077.post-42836150350000913652011-02-13T11:14:00.000-08:002011-02-13T11:14:18.065-08:00What is a temporary table?<div dir="ltr" style="text-align: left;" trbidi="on">A temporary table is an object that is created and stored temporarily by SQL Server in the tempdb database. The table can be created by any user by using either the CREATE TABLE statement or SELECT…INTO statement. Temporary tables are of the following two types:<br />
<br />
<br />
1. Local: A local temporary table is created by prefixing the table name with a single hash(#) sign. The table is visible only to the user who created it. <br />
<br />
2. Global: A global temporary table is created by prefixing the table name with a double hash(##) sign. The table is visible to all the users who are connected to the database engine. <br />
<br />
The syntax of creating a temporary table is as follows:<br />
To create a local temporary table.<br />
<br />
<ul style="text-align: left;"><li> CREATE TABLE #temporary_table ( column1 datatype, column2 datatype)</li>
<li> SELECT * INTO #temporary_table FROM original_table</li>
</ul>To create a global temporary table.<br />
<div></div><div></div><ul style="text-align: left;"><li>CREATE TABLE ##temporary_table (column1 datatype, column2 datatype)</li>
<li>SELECT * INTO ##temporary_table FROM original_table</li>
</ul></div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-85119714880196787662011-02-06T09:43:00.000-08:002011-02-06T09:43:01.176-08:00What is an endpoint?<div dir="ltr" style="text-align: left;" trbidi="on">In SQL Server 2005, a connection between servers is managed through an endpoint. The endpoint is an object in SQL Server 2005 through which SQL Server computers communicate with each other over the network. For database mirroring, a SQL Server computer requires a dedicated database mirroring endpoint. The database mirroring endpoint is used to communicate between the servers. It uses the TCP protocol to send and receive messages between the servers in the database mirroring sessions. Each endpoint listens on a unique TCP port number. Clients do not use the database mirroring endpoint to connect to the principal server. </div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-15776703050175371232011-02-01T21:23:00.000-08:002011-02-01T21:31:08.331-08:00What is synonym in SQL Server?<div dir="ltr" style="text-align: left;" trbidi="on">A synonym is a database object used to create aliases for database objects. It is used to hide the actual name of an object from an application connected to the database. If the object is moved to another schema or server, it does not affect the application. After the object is moved, the path of the synonym should be changed according to the path of the object to which the synonym is associated.<br />
<br />
Syntex to create and use synonym:<br />
<ul style="text-align: left;"><li>CREATE SYNONYM synonym_name FOR object name</li>
<li>SELECT * FROM synonym_name</li>
</ul></div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-27774214766629467522011-01-20T21:23:00.000-08:002011-01-23T10:06:32.550-08:00Data Migration from MS-Access to PostgreSQL - Problems and Solution<div dir="ltr" style="text-align: left;" trbidi="on">I faced tons of problems while migrating my database from Access-97 to PostgreSQL. After trying with few data migration tools, I found that it's good to use PostgreSQL and Access ODBC driver for data migration. <br />
<br />
To check with how to setup and use this ODBC driver please go through,<br />
<a href="http://ektaraval.blogspot.com/2011/01/setup-access-odbc-driver.html">Setup Access ODBC Driver</a><br />
<a href="http://ektaraval.blogspot.com/2010/12/install-setup-postgresql-odbc-driver.html">Install & Setup PostgreSQL ODBC Driver </a><br />
<a href="http://ektaraval.blogspot.com/2010/12/migrate-data-from-access-97-to.html">Migrate Data from Access 97 to PostgreSQL </a><br />
<br />
Using the steps mentioned in <a href="http://ektaraval.blogspot.com/2010/12/migrate-data-from-access-97-to.html">Migrate Data from Access 97 to PostgreSQL</a><a href="http://ektaraval.blogspot.com/2010/12/install-setup-postgresql-odbc-driver.html"></a> post, I was able to migrate almost all the tables, still with few tables PostgreSQL ODBC driver fails to transfer the data. Here are some of those errors, which makes PostgreSQL ODBC driver fail,<br />
<ul><li>"ERROR : character 0x9d of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"</li>
<li>"ERROR : character 0xb7 of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"</li>
<li>"ERROR : character 0xbc of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"</li>
<li>"ERROR : character 0x92 of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"</li>
<li>"ERROR : character 0x96 of encoding "WIN1252" has no equivalent in "UTF8"; Error while executing the query(#7)"</li>
<li>"ERROR: syntax error at or near :,";<br />
Error while execution the query (#7)</li>
<li>The Microsoft Jet engine stopped the process because you and another user are attempting to change the same data at the same time.</li>
</ul>So to get rid of all this error, I developed a PHP script, which will read data from Access table using Access-ODBC driver, and insert it into PostgreSQL server using connection string.This script will solve all character encoding related issue. But for the error like "The Microsoft Jet engine stopped the process because you and another user are attempting to change the same data at the same time." which means the database is corrupted or having some bad sector, it will not allow to copy those records, but for that you can use some debug variable in this script to find out id of those record, then open your access database table, and go to that particular record, move your cursor to each column of that record, and you will come to know which field is creating problem. Once you know the corrupted data, you can move all the data except those problem data<br />
____________________________________________________<br />
<?php<br />
set_time_limit (0); <br />
$conn=odbc_connect("AccessCon", "" , ""); <br />
$pgConn = @pg_connect("host=localhost user=ekta password=ekta dbname=Test");<br />
$rslt = pg_query($pgConn, 'SET CLIENT_ENCODING TO \'WIN1252\';');<br />
if($conn){<br />
$sql="SELECT * FROM myAccessTable";<br />
$row=odbc_exec($conn, $sql);<br />
while(odbc_fetch_row($row)) {<br />
$field1 = odbc_result($row,1);<br />
$field2 = odbc_result($row,2);<br />
$field3 = odbc_result($row,3);<br />
$strQry = "INSERT INTO myPostgresTable (field1, field2, field3) <br />
VALUES('" . addslashes($field1) . "',<br />
'" . addslashes($field2) . "',<br />
'" . addslashes($field3) . "')";<br />
$rslt1 = pg_query($pgConn, $strQry);<br />
}<br />
}<br />
$rslt2 = pg_query($pgConn, 'RESET CLIENT_ENCODING;');<br />
odbc_close_all();<br />
pg_close($pgConn);<br />
?><br />
____________________________________________________</div>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com1tag:blogger.com,1999:blog-5046053494652428077.post-88217029630356257812011-01-19T20:33:00.000-08:002011-01-19T20:33:50.265-08:00Setup Access ODBC Driver<p>Perform following steps to setup Access ODBC Driver</p><ul> <li>Click Start, Settings, Control Panel</li>
<li>Switch the control panel to "Classical View", if it's already not in classical view</li>
<li>In Windows 2000, XP, Vista ODBC located inside Administrative Tools folder. Double click Data Sources (ODBC)</li>
<li>ODBC Data Source Administrator window displays</li>
<li> Select System DSN tab and click Add button</li>
<li>Select "Driver do Microsoft Access (*.mdb)" from the popup opened. </li>
<li>Then "ODBC Microsoft Access Setup" window displays. </li>
<li>Type name (We will enter name AccessCon) for Data Source Name and click Select button.</li>
<li> Select Database window displays. Find your database and click OK button. </li>
<li>Click OK on Microsoft Access Setup window and OK on ODBC Data Source Administrator window.</li>
</ul>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-36473460450121472472010-12-30T17:10:00.000-08:002010-12-30T17:10:05.373-08:00How to check if a javascript global variable is defined or not in a javascript function?We can do it with following code,<br />
<br />
if (variablename == undefined){ <br />
variablename = 'XYZ';<br />
}<br />
<br />
But for some reason, firefox will throws error with above code. So the solution to that problem is,<br />
if(window.variablename == undefined){<br />
window.variablename = 'XYZ';<br />
}Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-18208088375845102702010-12-29T16:19:00.001-08:002010-12-29T16:25:57.904-08:00How to insert NULL value in PostgreSQL date column?The simple query is like,<br />
INSERT INTO table (date_field) VALUES (NULL);<br />
<br />
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,<br />
<br />
<?<br />
if(empty($dbDate)) $dbDate = '0000-00-00';<br />
$myQry = "INSERT INTO table (date_field) VALUES (CASE $dbDate WHEN 0 THEN NULL ELSE TO_DATE('{$dbDate}', 'YYYY-MM-DD') END)";<br />
<br />
/*Remaining code comes here */<br />
?>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-52184047646100639512010-12-28T14:21:00.000-08:002010-12-28T14:46:38.812-08:00How to Enable Macro in Microsoft Office Excel 2007?<ul><li>Open Microsoft Office Excel 2007 Click on Office logo at the very Left hand Top</li>
<li>Then select "Excel Options", select "Trust Centre" on left hand side and click on "Trust Centre Settings"</li>
<li>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"</li>
</ul>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-80426994006412966142010-12-26T11:32:00.000-08:002010-12-26T11:44:10.860-08:00How 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, <br />
<ol><li>Start > cmd </li>
<li>C:\Users\XYZ > wmic csproduct get identifyingnumber,vendor,name</li>
</ol>It will give you the output like<br />
IdentifyingNumber Name Vendor<br />
L3ZZ896 5897X7Y LENOVO<br />
<br />
Where IdentifyingNumber is Serial number of machine, Name is Productid and Vendor is the name of manufacturerEktahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-55575014951555819222010-12-22T20:17:00.000-08:002010-12-23T19:54:11.326-08:00CONCAT_WS for PostgreSQLPostgreSQL do not have function like CONCAT_WS of MySQL, but writing the query as given below we can do much more...<br />
<br />
<br />
SELECT ARRAY_TO_STRING(ARRAY[initial, firstname, lastname] , ' ') AS user<br />
FROM users<br />
<br />
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<br />
<br />
SELECT ARRAY_TO_STRING(ARRAY[<br />
CASE title WHEN '' THEN NULL ELSE title END,<br />
CASE firstname WHEN '' THEN NULL ELSE firstname END, <br />
CASE lastname WHEN '' THEN NULL ELSE lastname END], ' ') AS user<br />
FROM usersEktahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-81721499322655033232010-12-18T10:55:00.000-08:002010-12-18T10:59:30.450-08:00Migrate Data from Access 97 to PostgreSQLTo 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.<br />
<br />
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 <a href="http://ektaraval.blogspot.com/2010/12/install-setup-postgresql-odbc-driver.html">Install & Setup PostgreSQL ODBC Driver </a>. Once finished with installation and setup of PostgreSQL ODBC driver, you are ready to migrate the data. <br />
<br />
How to migrate data from Access to PostgreSQL using PostgreSQL ODBC?<br />
<ul><li>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. </li>
<li>Then in the new popup for “Save as type” select “ODBC database”. </li>
<li>An Export window will appear, change the table name if required, or just click ok. </li>
<li>“Select Data Source” window will appear, select your PostgreSQL DSN, that you have created as mentioned above. And click ok. </li>
<li>Selected table will get exported to your postgres database. </li>
</ul>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com1tag:blogger.com,1999:blog-5046053494652428077.post-61107259043336231802010-12-15T20:32:00.001-08:002010-12-15T20:33:46.324-08:00Install & Setup PostgreSQL ODBC Driver<strong>Install PostgreSQL ODBC Driver </strong><br />
<ul><li>Download the latest PostgreSQL 32-bit ODBC Driver by choosing a mirror from <a href="http://wwwmaster.postgresql.org/download/mirrors-ftp">http://wwwmaster.postgresql.org/download/mirrors-ftp</a>and then navigating to the odbc/versions/msi/ folder. The current version is psqlodbc_08_03_0100.zip which was released Jan-22-2008.</li>
<li>Unzip psqlodbc_08_03_0100.zip </li>
<li>Run the psqlodbc.msi file </li>
</ul><strong>Setup PostgreSQL ODBC Driver</strong><br />
<ul><li>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.</li>
<li>ODBC located inside Administrative Tools folder. Double click ODBC Data Sources. ODBC Data Source Administrator window displays. </li>
<li>Select File DSN tab and click Add button, select “PostgreSQL Unicode” from the popup opened. </li>
<li>Type in a name “pgCon” for "Create New Data Source” and Click Next </li>
<li>Then Click Finish and fill in relevant server, db, username and password. </li>
<li>Click the Connection button and uncheck Bools as char as shown in Manager Connection Page 1 </li>
<li>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 </li>
<li>A DSN (Data Source) with name “ pgCon ” is created and ready to use... </li>
</ul>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-64413262849670369892010-12-12T12:02:00.000-08:002010-12-12T12:03:02.972-08:00How to Fix Corrupted Vista Profile?Follow the following steps in order to recreate a user’s Vista profile when it gets corrupted.<br />
<ol><li>log into user’s workstation with your admin account </li>
<li>Delete user’s local profile on C: drive under users folder</li>
<li>Click on Start and run and type “Regedit”</li>
<li>This will open Registry Editor Window</li>
<li>Click on + sign besides HKEY_LOCAL_MACHINE</li>
<li>Click on + sign besides SOFTWARE</li>
<li>Click on + sign besides MICROSOFT</li>
<li>Click on + sign besides WINDOWS NT</li>
<li>Click on + sign besides CURRENT VERSION</li>
<li>Click on + sign besides PROFILELIST and delete the SID number points to user name in Right side Pane</li>
<li>Close Registry Editor window.</li>
<li>Now RDP into the Server hosting that user’s profile.</li>
<li>Go to Profiles folder and locate the user’s windows vista profile </li>
<li>Rename this profile folder</li>
<li>Ask the user to login and then logoff</li>
<li>Now copy the user’s favorites and Desktop icons from the renamed profile folder to the new profile folder</li>
<li>Ask user to login again and this will create a new profile for the user successfully.</li>
</ol>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-68231996110545050162010-12-11T11:34:00.000-08:002010-12-11T11:34:39.476-08:00How to fix network printer dirver error for HP printers<ol><li>Delete the printer having printing problem from the printer window.</li>
<li>Click on Start and Run and type in Regedit.</li>
<li>This will open Registry editor window.</li>
<li>Click on + sign besides HKEY_LOCAL_MACHINE</li>
<li>Click on + sign besides SYSTEM</li>
<li>Click on + sign besides CurrentControlSet</li>
<li>Click on + sign besides Control</li>
<li>Click on + sign besides Print</li>
<li>Click on + sign besides Environments </li>
<li>Click on + sign besides Windows NT x86</li>
<li>Click on + sign besides Drivers</li>
<li>Click on + sign besides Version-3</li>
<li>Right click on the printer name and delete it</li>
<li>Click on + sign besides Monitors and delete the folder for that printer </li>
<li>Close the Registry Editor</li>
<li>Go to System32 folder under C:\Windows\System32</li>
<li>Click to open spool folder and click to open drivers folder</li>
<li>Click to open w32x86 folder and click on 3 folder</li>
<li>Under 3 folder delete all the instances for the printer giving problems</li>
<li>Reboot computer and install the printer again</li>
<li>It should work fine now.</li>
</ol>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com0tag:blogger.com,1999:blog-5046053494652428077.post-55403089062352235422010-11-29T20:25:00.000-08:002010-11-29T20:27:29.093-08:00Important PSql commands1. Command to connect to postgres<br />
<ul><li>psql -h localhost -U postgres</li>
</ul>2. Few general command that required when connected to Postges though shell<br />
<ul><li>\h for help with SQL commands</li>
<li>\? for help on internal slash commands</li>
<li>\g or terminate with semicolon to execute query</li>
<li>\q to quit</li>
</ul>3. Command to view the database assign to this user<br />
<ul><li>\l to List databases</li>
<li>SELECT datname FROM pg_database;</li>
</ul>4. Command to connect to a database<br />
<ul><li>\c database-name </li>
</ul>5. Command to list tables in current database<br />
<ul><li>\d to List tables in database</li>
<li>SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'</li>
</ul>6. Command to describe a table structure<br />
<ul><li>\d table-name </li>
</ul>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com1tag:blogger.com,1999:blog-5046053494652428077.post-17501154087092878402010-11-29T20:03:00.000-08:002010-11-29T20:14:28.881-08:00Important Linux commands for PostgreSQL<ul><li><strong>createdb <br />
createdb tmpdb -h localhost -U postgres</strong><br />
Create a new PostgreSQL database </li>
<li><strong>createuser <br />
createuser ekta –s -h localhost -U postgres –P</strong><br />
Create a new PostgreSQL user. Above command will create a new user ekta with the permission of superuser (-s) . And –P will prompt you for the password for new user. If we write this command without –P, it will create used which will not require password authentication<br />
</li>
<li><strong>dropdb <br />
dropdb tmpdb -h localhost -U postgres</strong><br />
Remove an existing PostgreSQL database<br />
</li>
<li><strong>dropuser <br />
dropuser ekta -h localhost -U postgres</strong><br />
Drops (removes) a PostgreSQL user<br />
</li>
<li><strong>pg_dump <br />
pg_dump -h localhost -U postgres tmpdb > tmpdb.sql<br />
pg_dump --insert -h localhost -U postgres tmpdb > tmpdb.sql</strong><br />
All above command are used to take database dump. It will extract a PostgreSQL database into a script file. --insert option is used to dump data as insert command.<br />
</li>
<li><strong>pg_dumpall <br />
pg_ dumpall -h localhost -U postgres > tmpdb.sql</strong><br />
Extract all PostgreSQL databases into a script file<br />
</li>
<li><strong>psql <br />
psql -h localhost -U postgres</strong><br />
Open PostgreSQL interactive terminal<br />
</li>
<li><strong>vacuumdb <br />
vacuumdb tmpdb -h localhost -U postgres </strong><br />
Clean and analyze a PostgreSQL database </li>
</ul><b>Note </b>: For information on above command check Linux help using man command, for example man pg_dumpEktahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com1tag:blogger.com,1999:blog-5046053494652428077.post-62778744317835139442010-11-17T19:54:00.000-08:002010-11-17T20:04:21.798-08:00Windows Apache PHP and Postgres (WAPP Server)BitNami WAPPStack includes Apache 2.2.16, PostgreSQL 9.0.0-1, PHP 5.2.14 and phpPgAdmin 4.2.2. phpPgAdmin is a web interface for administration of PostgreSQL. Steps to install and configure WAPP Server are given below,<br />
<br />
<strong><u>Installation</u></strong><br />
<ul><li> Download free copy of WAPP Server from <a href="http://bitnami.org/stack/wappstack">http://bitnami.org/stack/wappstack</a> </li>
<li> Locate the downloaded file and double click the file to launch the installation. </li>
<li>The WAPP Setup Wizard will appear. Click Next. </li>
<li>At the Select Destination Location you can change the install directory. The default is C:\Program Files\BitNami WAPPStack. We will use the default directory. Click Next. </li>
<li>Then you will be asked for PostgreSQL postgres user password. Enter the Password. A Postgres user account will be created with user name “postgres” and the password you have entered. This information will be then used to connect with PostgreSQL server, through command prompt or through phpPgAdmin. Click Next</li>
<li>The default listening port for Apache is 80 and for PostgreSQL is 5432. If those ports are already in use by other applications, you will be prompted for alternate ports to use. Enter the alternate port if prompted. Click next</li>
<li>You are now ready to begin the installation, screen will appear. Click next</li>
<li>When installation is complete, “Completing the BitNami WAPP Stack Setup Wizard” page will appear. Click on Finish </li>
<li>You can now launch your browser with <a href="http://localhost/">http://localhost/</a></li>
</ul><u><strong>Folder to create PHP files</strong></u><br />
<ul><li>The installation process will create several subfolders under the main installation directory i.e. C:\Program Files\BitNami WAPPStack</li>
<li>Create your PHP files in C:\Program Files\BitNami WAPPStack\apache2\htdocs</li>
</ul><u><strong>How to access phpPgAdmin</strong></u><br />
<ul><li>You can access your phpPgAdmin by opening a browser and typing http://127.0.0.1/phppgadmin. You will be asked for a username and password. As user name, use "administrator" and as password use the value specified during installation</li>
<li>Once you are connected with phpPgAdmin, to connect with default Postgres database, click on the Postgres on left bar, it will again ask for database user name and password. As the user name, use “postgres” and as password use the value specified during installation</li>
</ul>Ektahttp://www.blogger.com/profile/15751029105627415298noreply@blogger.com3