Insert Query Giving Missing Expression Error - oracle
Below I have 2 exact same queries
1st one is generated via python code
2nd is export data as insert from oracle sqldeveloper
While second query inserts data properly ,first query is giving missing expression error
Queries
INSERT INTO NCSUSR.COLL_CLIENT_SUBMISSION_DTLS (ccsd_id, ccsd_file_id, ccsd_batch_dt, ccsd_cm_id, ccsd_cm_pan_no, ccsd_tm_id, ccsd_tm_pan_no,ccsd_cp_code, ccsd_cp_pan_no, ccsd_cli_cd, ccsd_cli_pan_no, ccsd_account_type, ccsd_segment_indicator, ccsd_ucc, ccsd_cp_fin_ledger_bal_a, ccsd_cp_fin_ledger_bal_b, ccsd_cp_fin_peak_ledger_bal_c, ccsd_cp_bg, ccsd_cp_fdr, ccsd_cp_apr_sec_cash_com, ccsd_cp_apr_sec_non_cash_com, ccsd_cp_non_apr_sec, ccsd_cp_cc_apr_comm, ccsd_cp_othr_coll, ccsd_tm_cred_enty_ledger_epi, ccsd_tm_pool_account, ccsd_tm_cash_retained, ccsd_tm_bg, ccsd_tm_fdr, ccsd_tm_apr_sec_cash_com, ccsd_tm_apr_sec_non_cash_com, ccsd_tm_non_apr_sec, ccsd_tm_cc_apr_comm, ccsd_tm_othr_coll, ccsd_cm_cash_placed, ccsd_cm_bg, ccsd_cm_fdr, ccsd_cm_apr_sec_cash_com, ccsd_cm_apr_sec_non_cash_com, ccsd_cm_non_apr_sec, ccsd_cm_cc_apr_comm, ccsd_cm_othr_coll, ccsd_cm_cash_retained, ccsd_cm_rtd_bg, ccsd_cm_rtd_fdr, ccsd_cm_rtd_apr_sec_cash_com, ccsd_cm_rtd_apr_sec_n_cash_com, ccsd_cm_rtd_non_apr_sec, ccsd_cm_rtd_cc_apr_comm, ccsd_cm_rtd_othr_coll, ccsd_nccl_cash_placed, ccsd_nccl_bg, ccsd_nccl_fdr, ccsd_nccl_apr_sec_cash_com, ccsd_nccl_aprv_sec_non_cash_com, ccsd_nccl_cc_apr_comm, ccsd_email_flag, ccsd_sms_flag, ccsd_status, ccsd_created_dt, ccsd_created_by, ccsd_modified_dt, ccsd_modified_by) VALUES {3,12345678,to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'A1017','BCIPB1234B','01266','BCIPB1234T','NCDXPRE01',null,null,'BCIPB1234M','P','CM',null,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,'N','N','Y',to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'SYSTEM',null,null};
INSERT INTO NCSUSR.COLL_CLIENT_SUBMISSION_DTLS (ccsd_id, ccsd_file_id, ccsd_batch_dt, ccsd_cm_id, ccsd_cm_pan_no, ccsd_tm_id, ccsd_tm_pan_no,ccsd_cp_code, ccsd_cp_pan_no, ccsd_cli_cd, ccsd_cli_pan_no, ccsd_account_type, ccsd_segment_indicator, ccsd_ucc, ccsd_cp_fin_ledger_bal_a, ccsd_cp_fin_ledger_bal_b, ccsd_cp_fin_peak_ledger_bal_c, ccsd_cp_bg, ccsd_cp_fdr, ccsd_cp_apr_sec_cash_com, ccsd_cp_apr_sec_non_cash_com, ccsd_cp_non_apr_sec, ccsd_cp_cc_apr_comm, ccsd_cp_othr_coll, ccsd_tm_cred_enty_ledger_epi, ccsd_tm_pool_account, ccsd_tm_cash_retained, ccsd_tm_bg, ccsd_tm_fdr, ccsd_tm_apr_sec_cash_com, ccsd_tm_apr_sec_non_cash_com, ccsd_tm_non_apr_sec, ccsd_tm_cc_apr_comm, ccsd_tm_othr_coll, ccsd_cm_cash_placed, ccsd_cm_bg, ccsd_cm_fdr, ccsd_cm_apr_sec_cash_com, ccsd_cm_apr_sec_non_cash_com, ccsd_cm_non_apr_sec, ccsd_cm_cc_apr_comm, ccsd_cm_othr_coll, ccsd_cm_cash_retained, ccsd_cm_rtd_bg, ccsd_cm_rtd_fdr, ccsd_cm_rtd_apr_sec_cash_com, ccsd_cm_rtd_apr_sec_n_cash_com, ccsd_cm_rtd_non_apr_sec, ccsd_cm_rtd_cc_apr_comm, ccsd_cm_rtd_othr_coll, ccsd_nccl_cash_placed, ccsd_nccl_bg, ccsd_nccl_fdr, ccsd_nccl_apr_sec_cash_com, ccsd_nccl_aprv_sec_non_cash_com, ccsd_nccl_cc_apr_comm, ccsd_email_flag, ccsd_sms_flag, ccsd_status, ccsd_created_dt, ccsd_created_by, ccsd_modified_dt, ccsd_modified_by) VALUES (3,12345678,to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'A1017','BCIPB1234B','01266','BCIPB1234T','NCDXPRE01',null,null,'BCIPB1234M','P','CM',null,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,'N','N','Y',to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'SYSTEM',null,null);
Error Getting for 1st Query :
Error starting at line 1 in command:
INSERT INTO NCSUSR.COLL_CLIENT_SUBMISSION_DTLS (ccsd_id, ccsd_file_id, ccsd_batch_dt, ccsd_cm_id, ccsd_cm_pan_no, ccsd_tm_id, ccsd_tm_pan_no,ccsd_cp_code, ccsd_cp_pan_no, ccsd_cli_cd, ccsd_cli_pan_no, ccsd_account_type, ccsd_segment_indicator, ccsd_ucc, ccsd_cp_fin_ledger_bal_a, ccsd_cp_fin_ledger_bal_b, ccsd_cp_fin_peak_ledger_bal_c, ccsd_cp_bg, ccsd_cp_fdr, ccsd_cp_apr_sec_cash_com, ccsd_cp_apr_sec_non_cash_com, ccsd_cp_non_apr_sec, ccsd_cp_cc_apr_comm, ccsd_cp_othr_coll, ccsd_tm_cred_enty_ledger_epi, ccsd_tm_pool_account, ccsd_tm_cash_retained, ccsd_tm_bg, ccsd_tm_fdr, ccsd_tm_apr_sec_cash_com, ccsd_tm_apr_sec_non_cash_com, ccsd_tm_non_apr_sec, ccsd_tm_cc_apr_comm, ccsd_tm_othr_coll, ccsd_cm_cash_placed, ccsd_cm_bg, ccsd_cm_fdr, ccsd_cm_apr_sec_cash_com, ccsd_cm_apr_sec_non_cash_com, ccsd_cm_non_apr_sec, ccsd_cm_cc_apr_comm, ccsd_cm_othr_coll, ccsd_cm_cash_retained, ccsd_cm_rtd_bg, ccsd_cm_rtd_fdr, ccsd_cm_rtd_apr_sec_cash_com, ccsd_cm_rtd_apr_sec_n_cash_com, ccsd_cm_rtd_non_apr_sec, ccsd_cm_rtd_cc_apr_comm, ccsd_cm_rtd_othr_coll, ccsd_nccl_cash_placed, ccsd_nccl_bg, ccsd_nccl_fdr, ccsd_nccl_apr_sec_cash_com, ccsd_nccl_aprv_sec_non_cash_com, ccsd_nccl_cc_apr_comm, ccsd_email_flag, ccsd_sms_flag, ccsd_status, ccsd_created_dt, ccsd_created_by, ccsd_modified_dt, ccsd_modified_by) VALUES {3,12345678,to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'A1017','BCIPB1234B','01266','BCIPB1234T','NCDXPRE01',null,null,'BCIPB1234M','P','CM',null,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,'N','N','Y',to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'SYSTEM',null,null}
Error at Command Line:1 Column:1,308
Error report:
SQL Error: ORA-00936: missing expression
00936. 00000 - "missing expression"
*Cause:
*Action:
There is a } at the end of the first insert, instead of )
It should be
INSERT INTO NCSUSR.COLL_CLIENT_SUBMISSION_DTLS (ccsd_id, ccsd_file_id, ccsd_batch_dt, ccsd_cm_id, ccsd_cm_pan_no, ccsd_tm_id, ccsd_tm_pan_no,ccsd_cp_code, ccsd_cp_pan_no, ccsd_cli_cd, ccsd_cli_pan_no, ccsd_account_type, ccsd_segment_indicator, ccsd_ucc, ccsd_cp_fin_ledger_bal_a, ccsd_cp_fin_ledger_bal_b, ccsd_cp_fin_peak_ledger_bal_c, ccsd_cp_bg, ccsd_cp_fdr, ccsd_cp_apr_sec_cash_com, ccsd_cp_apr_sec_non_cash_com, ccsd_cp_non_apr_sec, ccsd_cp_cc_apr_comm, ccsd_cp_othr_coll, ccsd_tm_cred_enty_ledger_epi, ccsd_tm_pool_account, ccsd_tm_cash_retained, ccsd_tm_bg, ccsd_tm_fdr, ccsd_tm_apr_sec_cash_com, ccsd_tm_apr_sec_non_cash_com, ccsd_tm_non_apr_sec, ccsd_tm_cc_apr_comm, ccsd_tm_othr_coll, ccsd_cm_cash_placed, ccsd_cm_bg, ccsd_cm_fdr, ccsd_cm_apr_sec_cash_com, ccsd_cm_apr_sec_non_cash_com, ccsd_cm_non_apr_sec, ccsd_cm_cc_apr_comm, ccsd_cm_othr_coll, ccsd_cm_cash_retained, ccsd_cm_rtd_bg, ccsd_cm_rtd_fdr, ccsd_cm_rtd_apr_sec_cash_com, ccsd_cm_rtd_apr_sec_n_cash_com, ccsd_cm_rtd_non_apr_sec, ccsd_cm_rtd_cc_apr_comm, ccsd_cm_rtd_othr_coll, ccsd_nccl_cash_placed, ccsd_nccl_bg, ccsd_nccl_fdr, ccsd_nccl_apr_sec_cash_com, ccsd_nccl_aprv_sec_non_cash_com, ccsd_nccl_cc_apr_comm, ccsd_email_flag, ccsd_sms_flag, ccsd_status, ccsd_created_dt, ccsd_created_by, ccsd_modified_dt, ccsd_modified_by) VALUES {3,12345678,to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'A1017','BCIPB1234B','01266','BCIPB1234T','NCDXPRE01',null,null,'BCIPB1234M','P','CM',null,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,'N','N','Y',to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'SYSTEM',null,null);
INSERT INTO NCSUSR.COLL_CLIENT_SUBMISSION_DTLS (ccsd_id, ccsd_file_id, ccsd_batch_dt, ccsd_cm_id, ccsd_cm_pan_no, ccsd_tm_id, ccsd_tm_pan_no,ccsd_cp_code, ccsd_cp_pan_no, ccsd_cli_cd, ccsd_cli_pan_no, ccsd_account_type, ccsd_segment_indicator, ccsd_ucc, ccsd_cp_fin_ledger_bal_a, ccsd_cp_fin_ledger_bal_b, ccsd_cp_fin_peak_ledger_bal_c, ccsd_cp_bg, ccsd_cp_fdr, ccsd_cp_apr_sec_cash_com, ccsd_cp_apr_sec_non_cash_com, ccsd_cp_non_apr_sec, ccsd_cp_cc_apr_comm, ccsd_cp_othr_coll, ccsd_tm_cred_enty_ledger_epi, ccsd_tm_pool_account, ccsd_tm_cash_retained, ccsd_tm_bg, ccsd_tm_fdr, ccsd_tm_apr_sec_cash_com, ccsd_tm_apr_sec_non_cash_com, ccsd_tm_non_apr_sec, ccsd_tm_cc_apr_comm, ccsd_tm_othr_coll, ccsd_cm_cash_placed, ccsd_cm_bg, ccsd_cm_fdr, ccsd_cm_apr_sec_cash_com, ccsd_cm_apr_sec_non_cash_com, ccsd_cm_non_apr_sec, ccsd_cm_cc_apr_comm, ccsd_cm_othr_coll, ccsd_cm_cash_retained, ccsd_cm_rtd_bg, ccsd_cm_rtd_fdr, ccsd_cm_rtd_apr_sec_cash_com, ccsd_cm_rtd_apr_sec_n_cash_com, ccsd_cm_rtd_non_apr_sec, ccsd_cm_rtd_cc_apr_comm, ccsd_cm_rtd_othr_coll, ccsd_nccl_cash_placed, ccsd_nccl_bg, ccsd_nccl_fdr, ccsd_nccl_apr_sec_cash_com, ccsd_nccl_aprv_sec_non_cash_com, ccsd_nccl_cc_apr_comm, ccsd_email_flag, ccsd_sms_flag, ccsd_status, ccsd_created_dt, ccsd_created_by, ccsd_modified_dt, ccsd_modified_by) VALUES (3,12345678,to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'A1017','BCIPB1234B','01266','BCIPB1234T','NCDXPRE01',null,null,'BCIPB1234M','P','CM',null,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,2000.0,'N','N','Y',to_timestamp('16-SEP-21','DD-MON-RR HH.MI.SSXFF AM'),'SYSTEM',null,null);
Related
How to change my language of DataTable?
I have below Function that my Table information change to an DataTable. <script type="text/javascript"> $(document).ready(function () { $('#myTable').DataTable( { "sProcessing": "درحال پردازش...", "sLengthMenu": "نمایش محتویات _MENU_", "sZeroRecords": "موردی یافت نشد", "sInfo": "نمایش _START_ تا _END_ از مجموع _TOTAL_ مورد", "sInfoEmpty": "تهی", "sInfoFiltered": "(فیلتر شده از مجموع _MAX_ مورد)", "sInfoPostFix": "", "sSearch": "جستجو:", "sUrl": "", "oPaginate": { "sFirst": "ابتدا", "sPrevious": "قبلی", "sNext": "بعدی", "sLast": "انتها" } } ); }); </script> I want change my language of DataTable to Persian But not working.
Related select in Magento how I do
It's possibile, in Magento, create two or more related select? For example Country / Region I try with jQuery but seem doesn't work. Best Regards I try with this code: in Mymodule output app/design/frontend/base/default/template/mymodule/mymodule.phtml <div id="continenti"> <?php include_once 'option.class.php'; $obj = new Option(); $obj->ShowContinenti(); ?> </div> <div id="nazioni"> Seleziona una nazione:<br> <select id="sel_nazioni" name="sel_nazioni"><option value="no">Scegli...</option> </select> </div> <div id="result"></div> In my app/design/frontend/base/default/template/page/html/head.phtml <script type="text/javascript" src="./jquery/jquery-1.3.2.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#sel_continenti').change(function(){ var cont = $('#sel_continenti').attr('value'); $.post("selection.php", {id_cont:cont}, function(data){ $("#sel_nazioni").empty(); $("div#result").empty(); $("#sel_nazioni").prepend(data); }); }); $('#sel_nazioni').change(function(){ var id_naz = $('#sel_nazioni').attr('value'); $.post("result.php", {id:id_naz}, function(data){ $("div#result").empty(); $("div#result").prepend(data); }); }); }); </script> In my app/code/local/frontname/mymodule/sql/mysql4-install-0.1.0 <?php $installer = $this; $installer->startSetup(); $installer->run(" -- DROP TABLE IF EXISTS {$this->getTable('continenti')}; CREATE TABLE {$this->getTable('continenti')} `id` INT(2) UNSIGNED NOT NULL AUTO_INCREMENT, `continente` VARCHAR(40) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; INSERT INTO `continenti` (`id`, `continente`) VALUES (1, 'Europa'), (2, 'Africa'), (3, 'Sud America'); -- DROP TABLE IF EXISTS {$this->getTable('nazioni')}; CREATE TABLE {$this->getTable('nazioni')} `id` INT(3) UNSIGNED NOT NULL AUTO_INCREMENT, `id_cont` INT(2) UNSIGNED NOT NULL, `nazione` VARCHAR(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=14 ; INSERT INTO {$this->getTable('nazioni')} (`id`, `id_cont`, `nazione`) VALUES (1, 1, 'Spagna'), (2, 1, 'Francia'), (3, 1, 'Italia'), (4, 1, 'Germania'), (5, 1, 'Belgio'), (6, 2, 'Egitto'), (7, 2, 'Marocco'), (8, 2, 'Tunisia'), (9, 2, 'Uganda'), (10, 3, 'Argentina'), (11, 3, 'Cile'), (13, 3, 'Brasile'); ") ; $installer->endSetup(); File result.php <?php include_once 'option.class.php'; $obj = new Option(); $obj->ShowResult(); ?> File selection.php <?php include_once 'option.class.php'; $obj = new Option(); $obj->ShowNazioni(); ?> The first select appear with the content of Region Table but, if I click and choise one region, the second select doesn't load data inside itself. EDIT: resolved! I change my head.phtml in <script type="text/javascript" src="./jquery/jquery-1.3.2.js"></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#sel_continenti').change(function(){ var cont = jQuery('#sel_continenti').attr('value'); jQuery.post("selection.php", {id_cont:cont}, function(data){ jQuery("#sel_nazioni").empty(); jQuery("div#result").empty(); jQuery("#sel_nazioni").prepend(data); }); }); jQuery('#sel_nazioni').change(function(){ var id_naz = jQuery('#sel_nazioni').attr('value'); jQuery.post("result.php", {id:id_naz}, function(data){ jQuery("div#result").empty(); jQuery("div#result").prepend(data); }); }); }); </script> I change $ with jQuery word!
Magento already has this kind of selects in checkout addresses phtmls, just that it uses Prototype. <div class="field"> <label for="billing:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label> <div class="input-box"> <select id="billing:region_id" name="billing[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;"> <option value=""><?php echo $this->__('Please select region, state or province') ?></option> </select> <script type="text/javascript"> //<![CDATA[ $('billing:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>"); //]]> </script> <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" /> </div> <div class="field"> <label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label> <div class="input-box"> <?php echo $this->getCountryHtmlSelect('billing') ?> </div> var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
get to all attribute value using xpath
this is my xml file:- <results value="1"> <result value="111"> <Country_Code value="IN"/> <Country_Name value="India"/> <Region_Name value="Gujarat"/> <City value="Rajkot"/> <loction lat="13.060422" lng="80.24958300000003"/> </result> <result value="222"> <Country_Code value="KE"/> <Country_Name value="Kenya"/> <Region_Name value="Vihiga"/> <City value="Kakamega"/> <loction lat="0.1182473" lng="34.7334515999997"/> </result> </results> this is my code:- <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script> var xml; $.get( "sea.xml", null, function (data) { xml = data; }, "xml" ); function get_list(ls) { var elName = $('#select').val(); var value = $('#value').val(); if(elName == "" || value == "") { } else if (elName != "" || value != "") { var xPath = '//*[ #lat '+ ls +' "'+elName+'" and #lng '+ ls +' "'+value+'"]'+'/../City/#*'; var iterator = xml.evaluate(xPath, xml.documentElement, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null); var thisNode = iterator.iterateNext(); var str = ''; while (thisNode) { if (str) { str += ', '; } str += thisNode.textContent; thisNode = iterator.iterateNext(); } $("#result").text(str); } else {} } </script> </head> <body> <input type="text" id="select"> <input type="text" id="value"> <input type="button" name="button" value="Search" onclick="get_list('=')"> <div id="result"> </div> </body> </html> with this code xpath return attribute value Rajkot but i want to change in Xpath to get all the attribute with help of xPath if value match on xml file return only city attribute value. but i want to all attribute value like:- IN,Inida,Gujarat,Rajkot,13.060422,80.24958300000003
The following XPath: //loction[#lat='13.060422' and #lng='80.24958300000003'][1]/preceding-sibling::City/#value Outputs: value="Rajkot" And the following XPath: //loction[#lat='13.060422' and #lng='80.24958300000003'][1]/preceding-sibling::*/#* Outputs: value="IN" ----------------------- value="India" ----------------------- value="Gujarat" ----------------------- value="Rajkot"
How to filtering gridview in MVC3?
I have gridview in Data and dropdownlist data whenever i select the Resourcename only filter that name .......... how to write code in controller? My contollercode public List<BugTracker_DataHelper> GeGridView() { var modelList = new List<BugTracker_DataHelper>(); using (SqlConnection conn = new SqlConnection(#"Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MvcBugTracker;Data Source=SSDEV6\SQLEXPRESS")) { conn.Open(); SqlCommand dCmd = new SqlCommand("Select * from Resources", conn); SqlDataAdapter da = new SqlDataAdapter(dCmd); DataSet ds = new DataSet(); da.Fill(ds); conn.Close(); for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++) { var model = new BugTracker_DataHelper(); model.ResourceID = Convert.ToInt16(ds.Tables[0].Rows[i]["ResourceID"]); model.ResourceName = ds.Tables[0].Rows[i]["ResourceName"].ToString(); model.EmployeEmailID = ds.Tables[0].Rows[i]["EmailID"].ToString(); //model.status = ds.Tables[0].Rows[i]["Status"].ToString(); modelList.Add(model); } } return modelList; } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Grids(FormCollection collection,string ResourceName,int ResourceId) { return View(); } My ModelCode <%# Page Language="C#" Inherits="System.Web.Mvc.ViewPage<IEnumerable<Gridview_BugTracker.Models.BugTracker_DataHelper>>" %> <!DOCTYPE html> <html> <head runat="server"> <link href="../../Content/GridStyle.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <title>Grids</title> </head> <body> <div> <%: Html.DropDownList("ResourceID", (SelectList)ViewBag.ResourceID, "--Select Project--")%> <%: Html.ValidationMessage("ResourceID")%> <%: Html.DropDownList("ResourceName", (SelectList)ViewBag.ResourceName, "--Select Project--")%> <%: Html.ValidationMessage("ResourceName")%> <% var grid = new WebGrid(source: Model, defaultSort: "ResourceName", rowsPerPage: 3); using (Html.BeginForm()) { %> <div id="grid"> <%:grid.GetHtml( tableStyle: "listing-border", headerStyle: "gridhead", footerStyle: "paging", rowStyle: "td-dark", alternatingRowStyle: "td-light", columns:grid.Columns( grid.Column("ResourceID"), grid.Column("ResourceName"), grid.Column("EmployeEmailID"), grid.Column( header: "", style: "text-align-center", format: (item) => Html.ActionLink("Edit", "Edit", new { ResourceID = item.ResourceID })) ))%> </div> <%} %> </div> </body> </html> how write in controller code.. please can any one help me
How to use AJAX to populate state list depending on Country list?
I have the code below that will change a state dropdown list when you change the country list. How can I make it change the state list ONLY when country ID number 234 and 224 are selected? If another country is selected it should be change into this text input box <input type="text" name="othstate" value="" class="textBox"> The form <form method="post" name="form1"> <select style="background-color: #ffffa0" name="country" onchange="getState(this.value)"> <option>Select Country</option> <option value="223">USA</option> <option value="224">Canada</option> <option value="225">England</option> <option value="226">Ireland</option> </select> <select style="background-color: #ffffa0" name="state"> <option>Select Country First</option> </select> The javascript <script> function getState(countryId) { var strURL="findState.php?country="+countryId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('statediv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script>
Just check the countryId value before you do the AJAX request and only perform the request if the countryId is in the allowable range. In the case where the countryId doesn't match, I would hide the select (probably clear it's value, too) and show an already existing input that was previously hidden. The reverse should be done if an allowable country is chosen. jQuery example below: <form method="post" name="form1"> <select style="background-color: #ffffa0" name="country" onchange="getState(this.value)"> <option>Select Country</option> <option value="223">USA</option> <option value="224">Canada</option> <option value="225">England</option> <option value="226">Ireland</option> </select> <select style="background-color: #ffffa0" name="state"> <option>Select Country First</option> </select> <input type="text" name="othstate" value="" class="textBox" style="display: none;"> </form> $(function() { $('#country').change( function() { var val = $(this).val(); if (val == 223 || val == 224) { $('#othstate').val('').hide(); $.ajax({ url: 'findState.php', dataType: 'html', data: { country : val }, success: function(data) { $('#state').html( data ); } }); } else { $('#state').val('').hide(); $('#othstate').show(); } }); });
I think the simple thing to do is to provide a state dropdown and a text entry box with different ids. Set the display of both to none and then you just need to surround your contents of getState() with if (countryId == 233 || countryId == 234) { /* Ajax state population here */ dropdownId.display = 'block'; textEntryId.display = 'none'; } else { textEntryId.display = 'block'; dropdownId.display = 'none'; } (where dropdownId and textEntryId are the ids of the relevant UI components) so you enable/display the display for the state dropdown or the text entry upon selection. JQuery is all well and good, but I wouldn't introduce it just to solve this problem.
EDIT: here is a solution that works quite well for the task, adapting the lines of Tvanfosson: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"> </script> <script> $(function() { $('#country').change( function() { var val = $(this).val(); if (val == 223 || val == 224) { $('#othstate').val('').hide(); $.ajax({ url: 'findState.php', dataType: 'html', data: { country : val }, success: function(data) { $('#state').html( data ); } }); } else { $('#state').val('').hide(); $('#othstate').show(); } }); }); </script> <select style="background-color: #ffffa0" name="country" id=country > <option>Select Country</option> <option value="223">USA</option> <option value="224">Canada</option> <option value="225">England</option> <option value="226">Ireland</option> </select> <select style="background-color: #ffffa0" name="state"> <option>Select Country First</option> </select> <input type="text" name="othstate" id=othstate value="" class="textBox" style="display: none;"> As you can see, I eliminated the <form> element which is not absolutely necessary but can be added (and then has to be used properly in case JS is deactivated at the users end. See here. I also eliminated the onchange event which is being replaced by the 'change()` jquery function.
**index.html** <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Populate City Dropdown Using jQuery Ajax</title> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("select.country").change(function(){ var selectedCountry = $(".country option:selected").val(); $.ajax({ type: "POST", url: "ajaxServer.jsp", data: { country : selectedCountry } }).done(function(data){ $("#response").html(data); }); }); }); </script> <style> select { width: 10em } </style> </head> <body> <form> <table> <tr> <td> <label>Country:</label></td> <td> <select class="country"> <option>Select</option> <option value="usa">United States</option> <option value="india">India</option> <option value="uk">United Kingdom</option> </select> </td> </tr> <tr><td > <label>States:</label></td> <td> <select id="response"> <option>Select State</option> </select> </td></tr> </table> </form> </body> </html> **ajaxServer.jsp** <option>Select State</option> <% String count=request.getParameter("country"); String india[]={"Mumbai", "New Delhi", "Bangalore"}; String usa[]={"New Yourk", "Los Angeles","California"}; String uk[]={"London", "Manchester", "Liverpool"}; String states[]; if(count.equals("india")) { for(int i=0;i<=2;i++) { out.print("<option>"+india[i]+"</option>"); } } else if(count.equals("usa")) { for(int i=0;i<usa.length;i++) { out.print("<option>"+usa[i]+"</option>"); } } else if(count.equals("uk")) { for(int i=0;i<=2;i++) { out.print("<option>"+uk[i]+"</option>"); } } %>
VK API just select country , get it id and select city from <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> var $j = jQuery.noConflict(); var _getCountry = function() { $j.ajax({ url: "http://api.vk.com/method/database.getCountries", data: { 'v': 5.5, 'need_all': 0, 'code' : 'RU,UA,BY,KZ,KG,LV,EE' // 'count': 10 }, dataType: 'jsonp', success: function(data, status) { if (status !== 'success') { return false; } console.log(data.response, status); $j.each(data.response.items, function(i, item) { console.log("each country"); var newOption = '<option id="' + item.id + '" value="' + item.title + '">' + item.title + '</option>'; country_options.push(newOption); }); document.getElementById('countrylist').innerHTML = country_options; } }); } var _getCity = function(country_id) { $j.ajax({ url: "http://api.vk.com/method/database.getCities", data: { 'v': 5.61, 'need_all': 0, 'country_id': country_id }, dataType: 'jsonp', success: function(data, status) { if (status !== 'success') { return false; } console.log(data.response, status); $j.each(data.response.items, function(i, item) { console.log("each city"); var newOption = '<option id="' + item.id + '" value="' + item.title + '">' + item.title + '</option>'; city_options.push(newOption); }); document.getElementById('citylist').innerHTML = city_options; } }); } var city_options = []; var country_options = []; $j(document).ready(function () { _getCountry(); $j('#country').on('input',function() { var opt = $j('option[value="'+$j(this).val()+'"]'); var countryid = opt.attr('id'); _getCity(countryid); }); }); </script> <div class="form-group"> <label class="col-lg-4 control-label">Страна:</label> <div class="col-lg-8"> <div class="controls"> <input name="country" list="countrylist" id="country" class="form-control" /> <datalist id="countrylist"> </datalist> </div> </div> </div> <div class="form-group"> <label class="col-lg-4 control-label">Город:</label> <div class="col-lg-8"> <input name="city" list="citylist" id="city" class="form-control"/> <datalist id="citylist"> </datalist> </div> </div>
////////////////// connection file con.php rishabh <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('Could not connect: ' . mysql_error()); } mysql_select_db( 'testajax' ); ?> /////////////////////////// index.php rishabh <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <?php include('con.php'); ?> <form> <div class="frmDronpDown"> <div class="row"> <table><tr><td><label>Country:</label><br/> <select name="country" id="country" data-name="country" class="demoInputBox" onChange="getCountry(this.value);"> <option value="">Select Country</option> <?php $sql = mysql_query("SELECT distinct country FROM statecont "); while($result=mysql_fetch_array($sql)){ ?> <option value="<?php echo $result['country']; ?>"><?php echo $result['country']; ?></option> <?php } ?> </select> </td> <td> <label>Phone:</label><br/> <select name="phone" id="phone" data-name="phone" class="demoInputBox" onChange="getPhone(this.value);"> <option value="">Select Country</option> <?php $sql = mysql_query("SELECT distinct phone FROM statecont "); while($result=mysql_fetch_array($sql)){ ?> <option value="<?php echo $result['phone']; ?>"><?php echo $result['phone']; ?></option> <?php } ?> </select> </td></tr></table> </div> <div id="state-list"></div> </div> </form> <script> function getCountry(val) { var dataname = $('#country').attr('data-name'); console.log(dataname); $.ajax({ type: "POST", url: "data.php", data: { value_name: val, colomn_name: dataname }, success: function (data){ $("#state-list").html(data); } }); } function getPhone(val) { var dataname = $('#phone').attr('data-name'); console.log(dataname); $.ajax({ type: "POST", url: "data.php", data: { value_name: val, colomn_name: dataname }, success: function (data){ $("#state-list").html(data); } }); } </script> // ////////////////////data file data.php rishabh <?php $val = $_POST["value_name"]; $colomn = $_POST["colomn_name"]; include('con.php'); $sql_aa = mysql_query("SELECT * FROM statecont where ".$colomn."='$val'"); ?> <table> <tr><td>State</td><td>Countery</td></tr> <?php while($result_aa=mysql_fetch_array($sql_aa)){ ?> <tr><td><?php echo $result_aa['state']; ?></td><td><?php echo $result_aa['country']; ?></td></tr> <?php } ?> </table>