Search Results

Search found 76977 results on 3080 pages for 'create function'.

Page 5/3080 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • "Decompile" Javascript function? *ADVANCED*

    - by caesar2k
    [1] Ok, I don't even know how to call this, to be honest. So let me get some semi-pseudo code, to show what I'm trying to do. I'm using jquery to get an already existing script declared inside the page, inside a createDocument() element, from an AJAX call. GM_xmlhttprequest({ ... load:function(r){ var doc = document_from_string(r.responseText); script_content = $('body script:regex(html, local_xw_sig)', doc).html(); var scriptEl = document.createElement('script'); scriptEl.type = 'text/javascript'; scriptEl.innerHTML = script_content; // good till here (function(sc){ eval(sc.innerHTML); // not exactly like this, but you get the idea, errors alert('wont get here ' + local_xw_sig); // local_xw_sig is a global "var" inside the source })(scriptEl); } }); so far so good, the script indeed contains the source from the entire script block. Now, inside this "script_content", there are auto executing functions, like $(document).ready(function(){...}) that, everything I "eval" the innerHTML, it executes this code, halting my encapsulated script. like variables that doesn't exist, etc removing certain parts of the script using regex isn't really an option... what I really wanted is to "walk" inside the function. like do a (completely fictional): script = eval("function(){" + script_content + "};"); alert(script['local_xw_sig']); // a03ucc34095cw3495 is there any way to 'disassemble' the function, and be able to reach the "var"s inside of it? like this function: function hello(){ var message = "hello"; } alert(hello.message); // message = var inside the function is it possible at all? or I will have to hack my way using regex? ;P [2] also, is there any way I can access javascript inside a document created with "createDocument"?

    Read the article

  • How can I invoke a function in bash shell script

    - by sufery
    !/bin/bash one_func(){ echo 'abcd' } echo $(one_func) echo one_func the end I just wonder the distinction calling the function between $(one_function) and one_function in bash shell script. When I set the variable "PS1" in ~/.bashrc, I can't invoke the function by one_func e: export PS1="\n[\e[31m]\$(one_func)" it work export PS1="\n[\e[31m]one_func" it doesn't work

    Read the article

  • Unable to create linen from mapped file console error

    - by TheLearner
    Does anyone know what the following logged error messages from console is all about - I am trying to track down the cause of a kernal panic I experienced yesterday: 13/01/2011 09:59:26 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:26 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:26 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:26 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:26 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:26 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:26 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file 13/01/2011 09:59:27 SpringBoard[2048] Unable to create linen from mapped file

    Read the article

  • mysql create table help with unique

    - by Matt
    I'm trying to create a table, and can't figure out how to assign two columns to be unique.. I know how to alter a table thats already created, but how do you do it in the create.. im after a create if not exist col1 TEXT, col2 TEXT, col3 TEXT unique(col1, col2) ^very rough basic but you get the idea

    Read the article

  • How to create multiple tables with the same schema using SQLite jdbc

    - by Space_C0wb0y
    I want to split a large table horizontally, and I would like to make sure that all three of them have the same schema. Currently I am using this piece of code to create the tables: statement .executeUpdate("CREATE TABLE AnnotationsMolecularFunction (Id INTEGER PRIMARY KEY ASC AUTOINCREMENT, " + "ProteinId NOT NULL, " + "GOId NOT NULL, " + "UNIQUE (ProteinId, GOId)" + "FOREIGN KEY(ProteinId) REFERENCES Protein(Id))"); There is one such statement for each table. This is bad, because if I decide to change the schema later (which will most certainly happen), I will have to change it three times, which begs for errors, so I would like a way to make sure that the other tables have the same schema without explicitly writing it again. I can use: statement .executeUpdate("CREATE TABLE AnnotationsBiologicalProcess AS SELECT * FROM AnnotationsMolecularFunction"); to create the other tables with the same columns, but the constraints are not aplied. I could of course just generate the same query-string three times with different table-names in Java, but I would like to know if there is an SQL-way of achieving this.

    Read the article

  • Using "Object.create" instead of "new"

    - by Graham King
    Javascript 1.9.3 / ECMAScript 5 introduces Object.create, which Douglas Crockford amongst others has been advocating for a long time. How do I replace new in the code below with Object.create? var UserA = function(nameParam) { this.id = MY_GLOBAL.nextId(); this.name = nameParam; } UserA.prototype.sayHello = function() { console.log('Hello '+ this.name); } var bob = new UserA('bob'); bob.sayHello(); (Assume MY_GLOBAL.nextId exists). The best I can come up with is: var userB = { init: function(nameParam) { this.id = MY_GLOBAL.nextId(); this.name = nameParam; }, sayHello: function() { console.log('Hello '+ this.name); } }; var bob = Object.create(userB); bob.init('Bob'); bob.sayHello(); There doesn't seem to be any advantage, so I think I'm not getting it. I'm probably being too neo-classical. How should I use Object.create to create user 'bob'?

    Read the article

  • Jquery callback function executes over and over again...

    - by Pandiya Chendur
    This my jquery function, function getRecordspage(curPage, pagSize) { // code here $(".pager").pagination(strarr[1], { callback: function() { getRecordspage(2, 5);},current_page: curPage - 1, items_per_page:'5', num_display_entries: '5', next_text: 'Next', prev_text: 'Prev', num_edge_entries: '1' }); } and i call this jquery function, <script type="text/javascript"> $(document).ready(function() { getRecordspage(1, 5); }); </script> As you see my It works fine for 1st time and my callback function is configured to the current function itself... when it gets called the callback gets executed over and over again.... How can i prevent this? Any suggestion....

    Read the article

  • jQuery plugin, return value from function

    - by Marius
    Hello there, Markup: <input type="text" name="email" /> Code: $(':text').focusout(function(){ $(this).validate(function(){ $(this).attr('name'); }); }); Plugin: (function($){ $.fn.validate = function(type) { return this.each(function(type) { if (type == 'email') { matches = this.val().match('/.+@.+\..{2,7}/'); (matches != null) ? alert('valid') : alert('invalid'); } /*else if (type == 'name') { } else if (type == 'age') { } else if (type == 'text') { }*/ else { alert('total failure'); } }); }; })(jQuery); The problem is that when I execute the code above, it runs the plugin as if type was a string: "function(){ $(this).attr('name'); });" instead of executing it as a function. How do I solve this? Thank you for your time. Kind regards, Marius

    Read the article

  • Need to call original function from detoured function

    - by peachykeen
    I'm using Detours to hook into an executable's message function, but I need to run my own code and then call the original code. From what I've seen in the Detours docs, it definitely sounds like that should happen automatically. The original function prints a message to the screen, but as soon as I attach a detour it starts running my code and stops printing. The original function code is roughly: void CGuiObject::AppendMsgToBuffer(classA, unsigned long, unsigned long, int, classB); My function is: void CGuiObject_AppendMsgToBuffer( [same params, with names] ); I know the memory position the original function resides in, so using: DWORD OrigPos = 0x0040592C; DetourAttach( (void*)OrigPos, CGuiObject_AppendMsgToBuffer); gets me into the function. This code works almost perfectly: my function is called with the proper parameters. However, execution leaves my function and the original code is not called. I've tried jmping back in, but that crashes the program (I'm assuming the code Detours moved to fit the hook is responsible for the crash). Edit: I've managed to fix the first issue, with no returning to program execution. By calling the OrigPos value as a function, I'm able to go to the "trampoline" function and from there on to the original code. However, somewhere along the lines the registers are changing and that is causing the program to crash with a segfault as soon as I get back into the original code.

    Read the article

  • How to fix MySQL CREATE FUNCTION query?

    - by Liutas
    I want to add mysql function: CREATE FUNCTION `chf_get_translation`(translation_id INT, site_lang INT) RETURNS text CHARSET utf8 BEGIN DECLARE translation TEXT; SELECT title INTO translation FROM chf_translations WHERE key_id = translation_id AND lang_id = site_lang; RETURN translation; END But get error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 What can be wrong with this function?

    Read the article

  • Using a Function returning apointer as LValue

    - by Amrish
    Why cant I used a function returning a pointer as a lvalue? For example this one works int* function() { int* x; return x; } int main() { int* x = function(); x = new int(9); } but not this int* function() { int* x; return x; } int main() { int* x; function() = x; } While I can use a pointer variable as a lvalue, why can't I use a function returning a pointer as a lvalue? Also, when the function returns a refernce, instead of a pointer, then it becomes a valid lvalue.

    Read the article

  • VBA-Excel return multidimensional array from a function

    - by alesdario
    I'm trying to write a function which returns a multidimensional array. The problem is that the size of the array isn't defined. My array is initialized in the function below my_list() Dim my_list() As String Public Sub Load_My_List() Dim last_column As Integer last_column = some_helper.Get_Last_Column(somw_worksheet) 'my array is resized in this point ReDim my_list(1 To last_column - 1, 1) Dim i As Integer i = 1 For index= 2 To ultima_colonna my_list(i, 0) = some_worksheet.Cells(2, index).value my_list(i, 1) = index i = i + 1 Next index End Sub So, how can i write a function which returns my_list ? Something like the function below generate a mismacthing type error Public function Get_My_List as String() Get_My_List = my_list End Function and how can i call this function properly? I think that something like Dim test() as String test = Get_My_List will doesn't work

    Read the article

  • calling and killing a parent function with onmouseover and onmouseout events

    - by Zoolu
    I want to call the function upon the onmouseover="ParentFunction();" then kill it onmouseout="killParent();". Note: in my code the parent function is called initiate(); and the killer function is called reset(); which lies outside the parent function at the bottom of the script. I don't know how to kill the intitiate() function my first guess was: var reset = function(){ return initiate(); }; here's my source code: any suggestions and help appreciated. <!doctype html> <html> <head> <title> function/event prototype </title> <link rel="stylesheet" type="text/css" href="styling.css" /> </head> <body> <h2> <em>Fantastical place<br/>prototype</em> </h2> <div id="button-container"> <div id="button-box"> <button id="activate" onmouseover="initiate()" onmouseout="reset();" width="50px" height="50px" title="Activate"> </button> </div> <div id="text-box"> </div> </div> <div id="container"> <canvas id="playground" width="200px" height="250px"> </canvas> <canvas id="face" width="400px" height="200px"> </canvas> <!-- <div id="clear"> </div> --> </div> <script> alert("Welcome, there are x entries as of" +""+new Date().getHours()); //global scope var i=0; var c1 = []; //c is short for collect var c2 = []; var c3 = []; var c4 = []; var c5 = []; var c6 = []; var initiate = function(){ //the button that triggers the program var timer = setInterval(function(){clock()},90); //copy this block for ref. function clock(){ i+=1; var a = Math.round(Math.random()*200); var b = Math.round(Math.random()*250); var c = Math.round(Math.random()*200); var d = Math.round(Math.random()*250); var e = Math.round(Math.random()*200); var f = Math.round(Math.random()*250); c1.push(a); c2.push(b); c3.push(c); c4.push(d); c5.push(e); c6.push(f); // document.write(i); var c = document.getElementById("playground"); var ctx = c.getContext("2d"); ctx.beginPath(); ctx.moveTo(c3[i-2], c4[i-2]); ctx.bezierCurveTo(c1[i-2],c2[i-2],c5[i-2],c6[i-2],c3[i-1], c4[i-1]); // ctx.lineTo(c3[i-1], c4[i-1]); if(a<200){ ctx.strokeStyle="#FF33CC"; } else if(a<400){ ctx.strokeStyle="#FF33aa"; } else{ ctx.strokeStyle="#FF3388"; } ctx.stroke(); document.getElementById("text-box").innerHTML=i+"<p>Thoughts.</p>"; if(i===20){ //alert("15 reached"); clearInterval(timer);//to clearInterval must be using a global scoped variable. return; } }; //end of clock //setInterval(clock,150); var targetFace = document.getElementById("face"); var face = targetFace.getContext("2d"); var faceTimer = setInterval(function(){faceAnim()},80); //copy this block for ref. global scoped. function faceAnim(){ face.beginPath(); face.strokeStyle="#FF33CC"; face.moveTo(100,104); //eye line face.bezierCurveTo(150,125,250,125,300,104); face.moveTo(200,1); //centre line face.lineTo(200,400); face.moveTo(125,111);//left eye lid face.bezierCurveTo(160,135,170,130,185,120); face.moveTo(150,116);//left eye face.bezierCurveTo(155,125,165,125,170,118); face.moveTo(275,111);//right eye lid face.bezierCurveTo(240,135,230,130,215,120); face.moveTo(250,116);//right eye face.bezierCurveTo(245,125,235,125,230,118); face.moveTo(195, 118); //left nose face.lineTo(190, 160); face.lineTo(200,170); face.moveTo(190,160); //left nostroll face.lineTo(180,160); face.lineTo(191,154); face.moveTo(180,160); //left lower nostrol face.lineTo(200,170); face.moveTo(205, 118); //right nose face.lineTo(210, 160); face.lineTo(200,170); face.moveTo(210,160); //right nostroll face.lineTo(220,160); face.lineTo(209,154); face.moveTo(220,160); //right lower nostrol face.lineTo(200,170); face.moveTo(200,140); //outer triad face.lineTo(170, 100); face.lineTo(230, 100); face.lineTo(200, 140); face.moveTo(200,145); //outer triad drop shadow face.lineTo(170, 100); face.lineTo(230, 100); face.lineTo(200, 145); face.moveTo(200,130); //inner triad face.lineTo(180, 105); face.lineTo(220, 105); face.lineTo(200, 130); //face.lineWidth =0.6; face.moveTo(280,111);//outer right eye lid face.bezierCurveTo(240,140,230,135,210,120); face.moveTo(120,111);//outer left eye lid face.bezierCurveTo(160,140,170,135,190,120); face.moveTo(162,174); //upper mouth line face.bezierCurveTo(170,180,230,180,238,174); face.moveTo(165,175); //mouth line bottom face.bezierCurveTo(190,Math.floor(Math.random()*25+180),210,Math.floor(Math.random()*25+180),235,175); face.moveTo(232,204); //head shape face.lineTo(340, 20); face.moveTo(168,204); //head shape face.lineTo(60, 20); face.stroke(); //exicute all co-ords. }; //end of face anim var clearFace = function(){ document.getElementById('face').getContext('2d').clearRect(0, 0, 700, 750); }; setInterval(clearFace,90); }; //end of parent function var reset = function(){ document.getElementById('playground').getContext('2d').clearRect(0, 0, 700, 750); //clearInterval(faceTimer); //delete initiate(); }; </script> </body> </html>

    Read the article

  • call user defined function in jquery

    - by pritisolanki
    Hi, I am trying to call user defined function in jquery. $(document).ready(function() { $('#btnSun').click(function(){ myFunction(); }); $.fn.myFunction = function() { alert('hi'); } }); I tried following as well function myFunction() { alert('hi'); } but it doesn't seems to work !! Any idea where I am wrong? Regards, Priti

    Read the article

  • Redefining PHP function?

    - by Michael
    If I have a function: function this($a){ return $a; } If I wanted to redefine the function, would it be as simple as rewriting it? function this($a, $b){ //New this function return $a * $b; }

    Read the article

  • Javascript AJAX function returns undefined instead of true / false

    - by Josh K
    I have a function that issues an AJAX call (via jQuery). In the complete section I have a function that says: complete: function(XMLHttpRequest, textStatus) { if(textStatus == "success") { return(true); } else { return(false); } } However, if I call this like so: if(callajax()) { // Do something } else { // Something else } The first is never called. If I put an alert(textStatus) in the complete function I get true, but not before that function returns undefined.

    Read the article

  • Inverted function keys (F1-F12) on HP Pavilion dv4t

    - by The Electric Muffin
    (I know there have already been a lot of questions about this, but none of them mentioned the dv4t specifically.) I'm thinking about getting an HP Pavilion dv4t-4200 or -5100, but something that's really irritating me is that by default the function keys (F1-F12) are "inverted"—without holding the Fn key, the function keys do things like change the brightness, change or mute the volume, and switch to an external display. Only if you hold Fn will they actually produce F1, F2, etc. This is not how keyboards are supposed to work. Is there any way to disable this "feature" that has been verified to work on the HP Pavilion dv4t-4200 or HP Pavilion dv4t-5100? I don't want to buy this computer unless this is possible.

    Read the article

  • How to change a function/formula in a whole column where I also have empty cells

    - by Zvi
    I have a column with a formula/function that has other cells as parameters. However in the column, every few rows I have a subtotal and blanks, for readability. Now I decided to change the formula/function but I can not do copy+paste on the whole column because of the subtotals/blank cells, and I can not do change+replace because there are parameters in the functions that uses other cells and thus it is different in each cell in the column. For example, if the formula is =if(A5>24,1,"") and I want to change it to =AA_userfn(A5,B5) Any idea how to change it easily? currently I copy+paste few rows at a time, but that is tedious. Maybe a Sub that will go all over the column (the column number as an input parameter) and looks for =if(, and then replaces it with =aa_userfn(Ax, By) where Ax and By are calculated based on the position of the cell currently changed in reference to the previous values in that cell. Any ideas will be welcomed

    Read the article

  • Special function keys are mixed up on my Macbook Pro

    - by seanieb
    I recently sent my Macbook Pro (late 2008 model) to get a replaced logic board and top cover. When I got it back the Special function keys are mixed up. F3 - mutes sound - it should do expose f4 - decreases volume - it should show the dashboard f5 - increases volume ....etc, ... F11 - expose - it should decrease volume f12 - dashboard - it should increase volume I have checked and made sure that System PreferencesKeyboard"use all F keys as standard function keys" is not selected. And that no accessibility options are switched on either. How do I fix this? or should I bring it back to the repair shop? Thanks

    Read the article

  • How to make this jquery function reusable?

    - by Pandiya Chendur
    Hai this is my jquery function, function getRecordspage(curPage, pagSize) { $.ajax({ type: "POST", url: "Default.aspx/GetRecords", data: "{'currentPage':" + curPage + ",'pagesize':" + pagSize + "}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(jsonObj) { var strarr = jsonObj.d.split('##'); var jsob = jQuery.parseJSON(strarr[0]); $.each(jsob.Table, function(i, employee) { $('<div class="resultsdiv"><br /><span class="resultName">' + employee.Emp_Name + '</span><span class="resultfields" style="padding-left:100px;">Category&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.Desig_Name + '</span><br /><br /><span id="SalaryBasis" class="resultfields">Salary Basis&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.SalaryBasis + '</span><span class="resultfields" style="padding-left:25px;">Salary&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.FixedSalary + '</span><span style="font-size:110%;font-weight:bolder;padding-left:25px;">Address&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.Address + '</span></div>').appendTo('#ResultsDiv'); }); $(".resultsdiv:even").addClass("resultseven"); $(".resultsdiv").hover(function() { $(this).addClass("resultshover"); }, function() { $(this).removeClass("resultshover"); }); } }); } In my page i have this jquery script, $("#lnkbtn0").click(function() { getRecordspage(1, 5) }); And my page has <a ID="lnkbtn0" class="page-numbers">1</a> <a ID="lnkbtn1" class="page-numbers">2</a> <a ID="lnkbtn2" class="page-numbers">3</a> <a ID="lnkbtn3" class="page-numbers">4</a> How to make other link buttons to call this function with diff curPage parameter...

    Read the article

  • Codeigniter: Library function--I'm stuck

    - by Kevin Brown
    I have a library function that sets up my forms, and submits data. They're long, and they work, so I'll spare you reading my code. :) I simply need a way for my functions to determine how to handle the data. Until now, the function did one thing: Submit a report for the current user. NOW, the client has requested that an administrator also be able to complete a form--this means that the form would be filled out, and it would CREATE a user at the same time, whereas the current function EDITS and is accessed by an EXISTING user. Do I need a separate function to do essentially the same thing? How do I make one function perform two tasks? One to update a user, and if there is no user, create one. Current controller: function survey() { $id = $this->session->userdata('id'); $data['member'] = $this->home_model->getUser($id); //Convert the db Object to a row array $data['manager'] = $data['member']->row(); $manager_id = $data['manager']->manager_id; $data['manager'] = $this->home_model->getUser($manager_id); $data['manager'] = $data['manager']->row(); $data['header'] = "Home"; $this->survey_form_processing->survey_form($this->_container,$data, $method); } Current Library: function survey_form($container) { //Lots of validation stuff $this->CI->validation->set_rules($rules); if ( $this->CI->validation->run() === FALSE ) { // Output any errors $this->CI->validation->output_errors(); } else { // Submit form $this->_submit(); } $this->CI->load->view($container,$data); The submit function is huge too. Basically says, "Update table with data where user_id=current user" I hope this wasn't too confusing. I'll create two functions if need be, but I'd like to keep redundancy down! }

    Read the article

  • WebRequest.Create problem

    - by Saurabh
    My requirement is downlaoding a HTTM page. Like and I am using WebRequest.Create. But the line HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://www.mayosoftware.com"); Is throwinh an exception {"Configuration system failed to initialize"}. I am working in a compmany. Does it due to proxy or anything? But it’s occurring while creation of the URL it self. Exception trace is: at System.Configuration.ConfigurationManager.PrepareConfigSystem() at System.Configuration.ConfigurationManager.GetSection(String sectionName) at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName) at System.Net.Configuration.WebRequestModulesSectionInternal.GetSection() at System.Net.WebRequest.get_PrefixList() at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) Code is like void GetHTTPReq() { Looking forward on it. The complete code is as follows but problem is in the starting itself : \ // used to build entire input StringBuilder sb = new StringBuilder(); // used on each read operation byte[] buf = new byte[8192]; // prepare the web page we will be asking for HttpWebRequest request = (HttpWebRequest) WebRequest.Create("http://www.mayosoftware.com"); // execute the request HttpWebResponse response = (HttpWebResponse) request.GetResponse(); // we will read data via the response stream Stream resStream = response.GetResponseStream(); string tempString = null; int count = 0; do { // fill the buffer with data count = resStream.Read(buf, 0, buf.Length); // make sure we read some data if (count != 0) { // translate from bytes to ASCII text tempString = Encoding.ASCII.GetString(buf, 0, count); // continue building the string sb.Append(tempString); } } while (count > 0); // any more data to read? // print out page source Console.WriteLine(sb.ToString()); }

    Read the article

  • DB2 Child Table Not Working - Create Table

    - by gamerzfuse
    I have a bit of a task before me. (DB2 Database) I need to create a table that will be a child table (is that what it is called in SQL?) I need it so that it has a foreign key constraint with my other table, so when the parent table is modified (record deleted) the child table also loses that record. Once I have the table, I also need to populate it with the data from the other table (if there is an easy way to UPDATE this). If you could point me in the right direction, this would help alot, as I do not even know what syntax to look for. Thanks in advance The table I have in place: create table titleauthors ( au_id char(11), title_id char(6), au_ord integer, royaltyshare decimal(5,2)); The table I am creating: create table titles ( title_id char(6), title varchar(80), type varchar(12), pub_id char(4), price decimal(9,2), advance decimal(9,2), ytd_sales integer, contract integer, notes varchar(200), pubdate date); I need the title_id to be matched with the title_id from the parent table AND use the ON DELETE CASCADE syntax to delete when that table is deleted from. My Attempt: CREATE TABLE BookTitles ( title_id char(6) NOT NULL CONSTRAINT BookTitles_title_id_pk REFERENCES titleauthors(title_id) ON DELETE CASCADE, title varchar(80) NOT NULL, type varchar(12), pub_id char(4), price decimal(9,2), advance decimal(9,2), ytd_sales integer, contract integer, notes varchar(200), pubdate date) ; Thanks in advance!

    Read the article

  • SQL SERVER – Detecting Leap Year in T-SQL using SQL Server 2012 – IIF, EOMONTH and CONCAT Function

    - by pinaldave
    Note: Tomorrow is February 29th. This blog post is dedicated to coming tomorrow – a special day :) Subu: “How can I find leap year in using SQL Server 2012?“ Pinal: “Are you asking me how to year 2012 is leap year using T-SQL – search online and you will find many example of the same.” Subu: “No. I am asking – How can I find leap year in using SQL Server 2012?“ Pinal: “Oh so you are asking – How can I find leap year in using SQL Server 2012?“ Subu: “Yeah - How can I find leap year in using SQL Server 2012?“ Pinal: “Let me do that for you – How can you find leap year in using SQL Server 2012?“ Indeed a fun conversation. Honestly, only reason I pasted our conversation here is – it was fun. What he was asking is that how to do it using new functions introduced in SQL Server 2012. Here is the article I have written which introduces all the new functions in SQL Server 2012 Summary of All the Analytic Functions – MSDN and SQLAuthority and 14 New Functions – A Quick Guide. There are many functions written to figure out to figure out if any year is Leap Year or not. The same I have written using T-SQL function over here. CREATE FUNCTION dbo.IsLeapYear (@year INT) RETURNS INT AS BEGIN RETURN(IIF(DATEPART(dd,(EOMONTH(CONCAT(@year,'0201')))) = 29,1,0)) END GO What I really like is that I was able to use three newly introduced function in SQL Server 2012 in above script. You can read more about them here. IIF, EOMONTH and CONCAT. You can validate above query by running following script. SELECT dbo.IsLeapYear('2011') 'IsLeapYear'; SELECT dbo.IsLeapYear('2012') 'IsLeapYear'; GO You will get result 1 if the year is leap year and 0 if year is not leap year. Reference: Pinal Dave (http://blog.sqlauthority.com) Filed under: PostADay, SQL, SQL Authority, SQL DateTime, SQL Function, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >