SQL – Find all tables in the MS SQL Server DataBase that are missing specific column

06.08.2009 at 9:08 (MS SQL Server, SQL) (, , , , , , , )

select t.TABLE_CATALOG, t.TABLE_NAME, c.COLUMN_NAME from INFORMATION_SCHEMA.TABLES  t
left outer  join INFORMATION_SCHEMA.COLUMNS c on t.TABLE_NAME = c.TABLE_NAME and c.COLUMN_NAME = ‘myColumn’
and c.COLUMN_NAME is null

Example SQL select, that lists all tables in the database, which are missing some specific column ( in this example – column named ‘myColumn’.

select t.TABLE_CATALOG, t.TABLE_NAME, c.COLUMN_NAME from INFORMATION_SCHEMA.TABLES  t

left outer  join INFORMATION_SCHEMA.COLUMNS c on t.TABLE_NAME = c.TABLE_NAME and c.COLUMN_NAME = ‘myColumn’

and c.COLUMN_NAME is null

Постоянна връзка Вашият коментар

SQL – Find all tables in the MS SQL Server DataBase with searched column

06.08.2009 at 9:03 (MS SQL Server, SQL) (, , , , , , )

select t.TABLE_CATALOG, t.TABLE_NAME, c.COLUMN_NAME, c.IS_NULLABLE, c.DATA_TYPE from INFORMATION_SCHEMA.TABLES  t

inner  join INFORMATION_SCHEMA.COLUMNS c on t.TABLE_NAME = c.TABLE_NAME and c.COLUMN_NAME = ‘SearchedColumnName’
and c.COLUMN_NAME is not null

Simple sql select, which result contains all tables in the database, that have specific, searched column.

This example lists all tables that have column named ‘myColumn’.

select t.TABLE_CATALOG, t.TABLE_NAME, c.COLUMN_NAME, c.IS_NULLABLE, c.DATA_TYPE from INFORMATION_SCHEMA.TABLES  t

inner  join INFORMATION_SCHEMA.COLUMNS c on t.TABLE_NAME = c.TABLE_NAME and c.COLUMN_NAME = ‘myColumn’

Постоянна връзка Вашият коментар

SQL – Find list of all tables in MS SQL Server Database

06.08.2009 at 8:57 (MS SQL Server, SQL) (, , , , , )

select distinct t.TABLE_CATALOG, t.TABLE_NAME from INFORMATION_SCHEMA.TABLES  t
left outer  join INFORMATION_SCHEMA.COLUMNS c on t.TABLE_NAME = c.TABLE_NAME

select distinct TABLE_CATALOG, TABLE_NAME from INFORMATION_SCHEMA.TABLES

Постоянна връзка Вашият коментар

JSF – Simple Progress Bar Example

30.07.2009 at 8:43 (IBM JWL, JSF, Web programming) (, , , )

JavaScript function:

function startProgressBar(progBarId, progBarMsg){

hX.getComponentById(progBarId).start(progBarMsg);

}

JSP Code Snippet:

<%–The progress bar –%>

<hx:progressBar id=“pBQueue“ auto=“true“ styleClass=“progressBar“
title=“Прогрес“ message=“Прогрес:“ ></hx:progressBar>

<hx:progressBar id=“pBar“ auto=“true“ styleClass=“progressBar“

title=“Show Progress“ message=“Progress:“ ></hx:progressBar>

<%–Button –%>

<hx:commandExButton type=“submit“ value=“Filter“

action=“#{mBQueue.filterByCriteria}“ styleClass=“commandExButton“

id=“btnSearchByCriteria“ onclick=“startProgressBar(‘pBar’,'Please wait…’);“>

<hx:behavior event=“onclick“ behaviorAction=“get;get“

targetAction=“boxPQCriteria;boxPQResults_rfsh“>

</hx:behavior>

</hx:commandExButton>
USEFUL LINK

Постоянна връзка Вашият коментар

JavaScript – compare two dates, validate date range

29.07.2009 at 11:32 (JavaScript, Web programming) (, , , , , )

function validateDateRange(date1Id, date2tId, errMsg){

date1 = document.getElementById(date1Id).value;
date2 = document.getElementById(date2Id).value;
//alert(date1 + ‘<>’ + date2);

if(date1 != null && date2 != null){

if (Date.parse(date1) > Date.parse(date2)) {

document.getElementById(date2Id).value = date1;
alert(errMsg);
return false;

}

}

return true;

}

Постоянна връзка Вашият коментар

Get values using parameter passing with JSF and AJAX

15.07.2009 at 13:22 (AJAX, IBM JSF, JSF, Java) (, , , , , , , , , , )

EXAMPLE JSP:

JSP File:
<!DOCTYPE html PUBLIC „-//W3C//DTD HTML 4.01 Transitional//EN“ „http://www.w3.org/TR/html4/loose.dtd“>
<%– jsf:pagecode language=“java“ location=“/src/pagecode/cpc/jsf/bp/contextFilters/CtxFilterDocuments.java“ –%><%– /jsf:pagecode –%><%@ page
language=“java“ contentType=“text/html; charset=UTF-8″
pageEncoding=“UTF-8″%><%@ taglib prefix=“f“
uri=“http://java.sun.com/jsf/core“%>
<%@ taglib prefix=“h“ uri=“http://java.sun.com/jsf/html“%>
<%@taglib uri=“http://www.ibm.com/jsf/html_extended“ prefix=“hx“%><html>
<head>
<meta http-equiv=“Content-Type“ content=“text/html; charset=UTF-8″>
<title>Insert title here</title>
</head>
<hx:scriptCollector id=“scCtxFDocs“>
<f:subview id=“svCtxFDocs“>
<hx:panelBox styleClass=“panelBox“ id=“boxCtxFilterDocs“
layout=“pageDirection“ border=“0″ cellpadding=“0″ cellspacing=“0″>
<hx:panelBox styleClass=“panelBox“ id=“boxDocCriteria“
layout=“lineDirection“ align=“left“ valign=“top“ cellpadding=“0″
cellspacing=“0″>
<h:panelGrid columns=“1″>
<h:outputText styleClass=“outputText“ value=“Reg. ID“></h:outputText>
<h:inputText styleClass=“inputText“ id=“prmDocsRegId“></h:inputText>
</h:panelGrid>
<h:panelGrid columns=“1″>
<h:outputText styleClass=“outputText“ value=“Reg. Num“></h:outputText>
<h:inputText styleClass=“inputText“ id=“prmDocsRegNum“></h:inputText>
</h:panelGrid>
</hx:panelBox>
<hx:ajaxRefreshRequest target=“boxDocsResults“ id=“arrboxDocsResults“
params=“prmDocsRegId;prmDocsRegNum“></hx:ajaxRefreshRequest>
<hx:panelBox styleClass=“panelBox“ id=“boxDocsButtons“
layout=“lineDirection“ cellpadding=“0″ cellspacing=“0″>
<hx:commandExButton type=“button“ value=“Търси“
styleClass=“commandExButton“ id=“btnSearchDocsDialog“>
<hx:behavior event=“onclick“ behaviorAction=“get“
id=“bhv_btnSearchDocsDialog“ targetAction=“boxDocsResults“></hx:behavior>
</hx:commandExButton>
</hx:panelBox>
<hx:panelBox styleClass=“panelBox“ id=“boxDocsResults“ border=“0″
layout=“pageDirection“ cellpadding=“0″ cellspacing=“0″>
<h:outputText id=“prm1Label“ value=“prmDocsRegId value“ />
<h:outputText id=“prm1″ value=“#{mBResults.prm1}“ />
<h:outputText id=“prm1Label“ value=“prmDocsRegNum value“ />
<h:outputText id=“prm2″ value=“#{mBResults.prm2}“ />
</hx:panelBox>
</hx:panelBox>
</f:subview>
</hx:scriptCollector>
</html>

<!DOCTYPE html PUBLIC „-//W3C//DTD HTML 4.01 Transitional//EN“ „http://www.w3.org/TR/html4/loose.dtd“>

<%– jsf:pagecode language=“java“ location=“/src/pagecode/cpc/jsf/bp/contextFilters/CtxFilterDocuments.java“ –%><%– /jsf:pagecode –%><%@ page

language=“java“ contentType=“text/html; charset=UTF-8″

pageEncoding=“UTF-8″%><%@ taglib prefix=“f“

uri=“http://java.sun.com/jsf/core“%>

<%@ taglib prefix=“h“ uri=“http://java.sun.com/jsf/html“%>

<%@taglib uri=“http://www.ibm.com/jsf/html_extended“ prefix=“hx“%><html>

<head>

<meta http-equiv=“Content-Type“ content=“text/html; charset=UTF-8″>

<title>Insert title here</title>

</head>

<hx:scriptCollector id=“scCtxFDocs“>

<f:subview id=“svCtxFDocs“>

<hx:panelBox styleClass=“panelBox“ id=“boxCtxFilterDocs“

layout=“pageDirection“ border=“0″ cellpadding=“0″ cellspacing=“0″>

<hx:panelBox styleClass=“panelBox“ id=“boxDocCriteria“

layout=“lineDirection“ align=“left“ valign=“top“ cellpadding=“0″

cellspacing=“0″>

<h:panelGrid columns=“1″>

<h:outputText styleClass=“outputText“ value=“Reg. ID“></h:outputText>

<h:inputText styleClass=“inputText“ id=“prmDocsRegId“></h:inputText>

</h:panelGrid>

<h:panelGrid columns=“1″>

<h:outputText styleClass=“outputText“ value=“Reg. Num“></h:outputText>

<h:inputText styleClass=“inputText“ id=“prmDocsRegNum“></h:inputText>

</h:panelGrid>

</hx:panelBox>

<hx:ajaxRefreshRequest target=“boxDocsResults“ id=“arrboxDocsResults“

params=“prmDocsRegId;prmDocsRegNum“></hx:ajaxRefreshRequest>

<hx:panelBox styleClass=“panelBox“ id=“boxDocsButtons“

layout=“lineDirection“ cellpadding=“0″ cellspacing=“0″>

<hx:commandExButton type=“button“ value=“Търси“

styleClass=“commandExButton“ id=“btnSearchDocsDialog“>

<hx:behavior event=“onclick“ behaviorAction=“get“

id=“bhv_btnSearchDocsDialog“ targetAction=“boxDocsResults“></hx:behavior>

</hx:commandExButton>

</hx:panelBox>

<hx:panelBox styleClass=“panelBox“ id=“boxDocsResults“ border=“0″

layout=“pageDirection“ cellpadding=“0″ cellspacing=“0″>

<h:outputText id=“prm1Label“ value=“prmDocsRegId value“ />

<h:outputText id=“prm1″ value=“#{mBResults.prm1}“ />

<h:outputText id=“prm1Label“ value=“prmDocsRegNum value“ />

<h:outputText id=“prm2″ value=“#{mBResults.prm2}“ />

</hx:panelBox>

</hx:panelBox>

</f:subview>

</hx:scriptCollector>

</html>

JAVA CLASS:

public class MBSearchedResults{

Map<String, String> ctxMap;

private String prm1;

private String prm2;

public MBSearchedResults() {

super();

this.ctxMap = FacesContext.getCurrentInstance().getExternalContext()

.getRequestParameterMap();

}

public String getPrm1(){

// Взимаме си параметрите

String pprmDocsRegId = this.ctxMap.get(„prmDocsRegId“);

if (pprmDocsRegId != null) {

this.prm1 =  pprmDocsRegId;

}

return this.prm1;

}

public String getPrm2(){

String pprmDocsRegNum = this.ctxMap.get(„prmDocsRegNum“);

if (pprmDocsRegNum != null) {

this.prm2 =  pprmDocsRegNum;

}

return this.prm2;

}

}

Постоянна връзка 4 Коментара

Java – Another enumeration example

15.07.2009 at 12:18 (Java) (, , , , , )

public enum EnumRefValues {

ref_type_1(„sysNameRefType1″, „name1″),
ref_type_2(„sysNameRefType2″, „name2″),
ref_type_3(„sysNameRefType3″, „name3″);

private String sysName;

private String name;

private MapNomValues(String sysName, String name) {

this.sysName = sysName;
this.name = name;

}

private MapNomValues(String value) {

this.sysName = value;

}

public String getSysName() {

return this.sysName;

}

public String getName() {

return this.name;

}

}

Results:
ref_type_1.getName(); returns -> name1
ref_type_1.getSysName(); returns -> sysNameRefType1

Постоянна връзка Вашият коментар

Java – Clone objects – example

15.07.2009 at 9:55 (Clone, Java) (, , , , , )

For objects cloning, you can use java.lang.Cloneable. It is not applicable for deep cloning (for deep cloning use Serialization), because you should control the overall clone process, but it works for simple cloning in most cases.
To use clone() method, you should implement java.lang.Cloneable and override clone(), because it is not visible. There is an example:

public abstract class Criteria implements Cloneable {

Criteria() {

super();

}

@Override
public Object clone() {

try {

return super.clone();

} catch (CloneNotSupportedException e) {

e.printStackTrace();
return null;

}

}

}

Постоянна връзка Вашият коментар

Java – Scanner example

08.07.2009 at 15:42 (Java) (, , )

package com.xxxxx.tests;

import java.util.Scanner;

public class ScannerExample{

/**

* @param args

*/

public static void main(String[] args){

Scanner scan = new Scanner(System.in);

System.out.println(„Write smthng: „);

String a = scan.next();

System.out.println(„Smthng: “ + a);

}

}

Постоянна връзка Вашият коментар

JSF – IBM DatePicker, choose first day of the week – example

08.07.2009 at 15:16 (IBM JWL, JSF, Web programming) (, , , , , , , , , )

Ако искате първият ден от седмицата в календара ви да е понеделник просто трябва да добавите /firstDay=“1″/.

<h:inputText id=“calExample“

styleClass=“inputText“

value=“#{mBean.dateRealBegin}“>

<hx:convertDateTime pattern=“#{mBean.dateFormat}“ />

<hx:inputHelperDatePicker id=“calExampleDatePicker“ firstDay=“1″ />

</h:inputText>

Постоянна връзка Вашият коментар

Next page »