DECLARE c_rno INT;
DECLARE c_name VARCHAR(100);
DECLARE cursor_var CURSOR FOR SELECT rno,name FROM students;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;

OPEN cursor_var;

cursor_var_loop: LOOP
FETCH cursor_var INTO c_rno,c_name;

— cursor loop statements
INNER_BLOCK: BEGIN
DECLARE inner_cursor_var CURSOR FOR SELECT id,name FROM teachers;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET inner_done = TRUE;

OPEN inner_cursor_var;

inner_cursor_var_loop: LOOP
FETCH inner_ cursor_var INTO c_inner_id,c_inner_name;

— inner cursor statements

IF inner_done THEN
LEAVE inner_cursor_var_loop;
END IF;
END LOOP inner_cursor_var_loop;

CLOSE inner_ cursor_var;
END INNER_BLOCK;

IF done THEN
LEAVE cursor_var_loop;
END IF;
END LOOP;

CLOSE cursor_var;

function isValid(str){
return !/[&\[\]\\’/()\\””]/g.test(str);
}

function ValidateSpecialChar()
{
var ErrorMsg = “Special Charectors & [ ] ‘ / ( ) \\ \” are not allowed in”;
var IsValid=1;

var PrenomTxt = $(‘#Prenom’).val();
var NomDeFamilleTXT = $(‘#NomDeFamille’).val();

if(isValid(PrenomTxt) == false)
{
ErrorMsg = ErrorMsg +”\n -First name”;
IsValid =0;

}
if(isValid(NomDeFamilleTXT) == false)
{

ErrorMsg = ErrorMsg +”\n -Last name”;
IsValid =0;
}

if(IsValid ==0)
{
alert(ErrorMsg);
return false;
}
return true;
}

Use the below query to find all tables containing column with specified name.

SELECT c.name AS ColName, t.name AS TableName
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE ‘%ColumnName%’

CF AJAXPROXY

Posted: May 10, 2016 in ColdFusion

Here is the example code for populating two dropdowns based on another dropdown.

var UserLangue=”#session.Langue#”;
function GetAllPakages(plateforme) {

GetAllPackagesEn(plateforme);
GetAllPackagesFr(plateforme);

}

function GetAllPackagesEn(plateforme) {
opEn = new ObjProgrammationJs();
opEn.setCallbackHandler(Callback_getPackagesEn);
opEn.setQueryFormat(‘column’);
opEn.getPackages(“#application.dsLocal#”, plateforme,’En’);
}

function GetAllPackagesFr(plateforme) {
opFr = new ObjProgrammationJs();
opFr.setCallbackHandler(Callback_getPackagesFr);
opFr.setQueryFormat(‘column’);
opFr.getPackages(“#application.dsLocal#”, plateforme,’Fr’);
}

function Callback_getPackagesEn(response) {
$(“##FamilleIDEn”).empty();

var opt = document.createElement(“option”);

var select = document.getElementById(‘Plateforme’);
var options = select.options;
var selected = select.options[0].text;
//alert(selected)

if(UserLangue == ‘en’)
opt.text = “Make a selection”;
else
opt.text = selected;

opt.value = “-1”;
opt.selected=true;
document.getElementById(‘FamilleIDEn’).options.add(opt);

for(i=0; i<response.DATA.length; i++) {
var opt = document.createElement("option");

// Assign text and value to Option object
opt.text = response.DATA[i][1];
opt.value = response.DATA[i][0];

// Add an Option object to Drop Down List Box
document.getElementById('FamilleIDEn').options.add(opt);
}

}

Breadcrumb using jquery

Posted: February 11, 2016 in JQuery

http://code.jquery.com/jquery-1.12.0.js

a + a:before {
content: ” >”;
/* content: ” \0020 \f105″; */
color: #D2322D;
}

a:link {
textcoration: none;
}

/*a:visited {
textcoration: underline;
}*/

a: hover {
color: red;
cursor: pointer;
}

.LastElement{
color:red;
cursor:text;

}

$(‘.items a’).on(‘click’, function() {
var $this = $(this),
$bc = $(‘

‘);
$this.parents(‘li’).each(function(n, li) {
$a = $(li).children(‘a’).clone();
$bc.prepend(‘ ‘,$a);
console.log($a);
});

$(‘.breadcrumb’).html( $bc );
$(‘.breadcrumb a’).attr(‘onclick’, ‘testfn(this); return false;’);
$(‘.breadcrumb a’).css(“text-decoration”, “none”);
$( “.breadcrumb a:last-child” ).removeAttr(‘href’);
$( “.breadcrumb a:last-child” ).addClass(“LastElement”);

return false;
});

function testfn(th)
{

var LevelName=$(th).text();
var lenLevel=LevelName.length;

if($(‘.breadcrumb’)){
var EntireHTML = $(‘.breadcrumb’).html();
EntireHTML = EntireHTML.substring(0, EntireHTML.indexOf(LevelName)+lenLevel);
$(‘.breadcrumb’).html(EntireHTML);
$( “.breadcrumb a:last-child” ).removeAttr(‘href’);
$( “.breadcrumb a:last-child” ).addClass(“LastElement”);

}
}

Breadcrumb using jquery

Posted: February 11, 2016 in JQuery

Insert title here
http://code.jquery.com/jquery-1.12.0.js
<!— http://code.jquery.com/jquery-migrate-1.3.0.js —>

a + a:before {
content: ” >”;
/* content: ” \0020 \f105″; */
color: #D2322D;
}

a:link {
textcoration: none;
}

/*a:visited {
textcoration: underline;
}*/

a: hover {
color: red;
cursor: pointer;
}

.LastElement{
color:red;
cursor:text;

}

$(‘.items a’).on(‘click’, function() {
var $this = $(this),
$bc = $(‘

‘);
$this.parents(‘li’).each(function(n, li) {
$a = $(li).children(‘a’).clone();
$bc.prepend(‘ ‘,$a);
console.log($a);
});

$(‘.breadcrumb’).html( $bc );
$(‘.breadcrumb a’).attr(‘onclick’, ‘testfn(this); return false;’);
$(‘.breadcrumb a’).css(“text-decoration”, “none”);
$( “.breadcrumb a:last-child” ).removeAttr(‘href’);
$( “.breadcrumb a:last-child” ).addClass(“LastElement”);

return false;
});

function testfn(th)
{

var LevelName=$(th).text();
var lenLevel=LevelName.length;

if($(‘.breadcrumb’)){
var EntireHTML = $(‘.breadcrumb’).html();
EntireHTML = EntireHTML.substring(0, EntireHTML.indexOf(LevelName)+lenLevel);
$(‘.breadcrumb’).html(EntireHTML);
$( “.breadcrumb a:last-child” ).removeAttr(‘href’);
$( “.breadcrumb a:last-child” ).addClass(“LastElement”);
//return false;
}
}

Set URL dynamically for JQgrid

Posted: January 20, 2016 in JavaScript, JQuery

We can use the setGridParam method for setting the URL dynamically. Below is the syntax and example for this.

Syntax:

$(“#gridname”).setGridParam(
{
url:”new url”,
page:1
}
).trigger(“reloadGrid”);//Reload grid trigger

Example:

$(“#list”).setGridParam(
{
url:”RelatedPublication.cfc?method=GetUnrelatedPublications&PublicationID=”+pubid,
page:1
}
).trigger(“reloadGrid”);//Reload grid trigger

The below code works with and without the loadOnce option set to true. Note that you have to set the rowNum option to 0 first, if you leave out this option it’ll still default to the 20 records to show. Also, I’m assuming you’re returning the total rows from the server in the documented JSON reader format.

$(‘#bla’).jqGrid({

  ‘rowNum’      : 0,
‘loadOnce’    : true,
loadComplete:function(){
  $(this).jqGrid(‘setGridParam’, ‘rowNum’, ‘records‘);
},

//The JSON reader. This defines what the JSON data returned from the CFC should look like
jsonReader: {
root: “ROWS”, //our data
page: “PAGE”, //current page
total: “TOTAL”, //total pages
records:”RECORDS”, //total records
userdata:”USERDATA”, //Userdata we will pass back for feedback
cell: “”, //Not Used
id: “0” //Will default to frist column
}

});

 

 

Altrow is not working in JQgrid

Posted: January 13, 2016 in JavaScript, JQuery

There are many methods to set alternate row color for jqgrid.

We can use altRow and altClass property in jqgrid for achieving this. Following is my code:

altRows:true,
altclass:’myAltRowClass’

and CSS is

.myAltRowClass
{
background-color: Fuchsia;
background-image:none;
}

2. By adding a new CSS class to jqgrid.css we can achieve this. Below is the steps to do this

1. Set grid property altRows:true,
2. Add the below CSS class to end of grid.css
.ui-jqgrid tr.ui-priority-secondary td { background-color: #DDDDDD; }

3. Without using altRows and altClass property.

loadComplete: function() {
$(“tr.jqgrow:odd”).css(“background”, “#DDDDDC”);


Use the recordtext property wit value like below.

recordtext:'{0} – {1} of {2} records’

For example,

var grid = $(“#list1″)
grid.jqGrid({
url:”RelatedPublication.cfc, //CFC that will return the users
datatype: ‘json’, //We specify that the datatype we will be using will be JSON
colNames:[‘UPID’,’PUBNUMBER’,’VOL”], //Column Names

colModel :[
{name:’UPID’,index:’UPID’, width:50,resizable:false,sortable:true,sorttype:”int”,resizable:false,editrules:{readonly:true}},
{name:’PUBNUMBER’,index:’PUBNUMBER’, width:130,resizable:false, sorttype:”text”,editable:true,edittype:”text”,editoptions:{size:30,maxlength:50},editrules:{required:true}},
{name:’VOL’,index:’VOL’, width:150,resizable:false, align:”left”,sorttype:”text”,editable:true,edittype:”text”,editoptions:{size:30,maxlength:50},editrules:{required:true}},
],

pager: $(‘#pager1’), //The div we have specified, tells jqGrid where to put the pager
rowNum:25, //Number of records we want to show per page
rowList:[25,50,100,500,1000,5000,10000,15000,20000,50000], //Row List, to allow user to select how many rows they want to see per page
sortorder: “asc”, //Default sort order
sortname: “ID”, //Default sort column
viewrecords: true, //Shows the nice message on the pager
imgpath: ‘/themes/jqgrid/css/images’, //Image path for prev/next etc images
caption: ‘Related Publications’, //Grid Name
mtype:’GET’,
recordtext:'{0} – {1} of {2} records’,
scrollerbar:true