Jump to content

ballouta

Members
  • Posts

    625
  • Joined

  • Last visited

Everything posted by ballouta

  1. Thank you
  2. Hello I am writing an Update trigger for my homework I have two questions Please: 1) I am declaring variables in the trigger e.g: Set @old_part_num = OLD.part_number; when I use this variable in a later query in the trigger, do I use the @ sign before the variable, in other words, do I always use the variable name preceded by @ sign? 2) I have If statement in my trigger, the first condition contains more than once statement how do i put several statements in one block (scope) as in If and later in Else... thank you here is my trigger delimiter // create trigger order_line_ad #this is the update Trigger After Update on order_line for each row Begin Set @old_part_num = OLD.part_number; Set @new_part_num = New.part_number; Set @order_num = OLD.order_number; if EXISTS (select part_number from order_line where part_number = old_part_num) THEN Set @old_units_onhand = select units_on_hand from parts where part_number = @old_part_num; Set @new_units_onhand = new.units_onhand; update parts set units_on_hand = new_units_onhand - old_units_onhand; ELSE Set @units_to_return = select number_ordered from order_line where part_number = @old_part_num; Set @old_units_onhand = select units_on_hand from parts where part_number = @old_part_num; Set @new_units_ordered = New.number_ordered; update order_line set part_number = @new_part_num, number_ordered = @new_units_ordered where order_number = @order_num; update parts set units_on_hands = @old_units_onhand + @units_to_return where part_number = @old_part_num; End; // delimiter
  3. I appreciate ur help yes I am using the command line BYE
  4. Thank You It is clear now. whenever I execute a new procedure or trigger, the commands don't execute after that. for example if I write select * from customer; it gives me mysql -> why?
  5. Thank you so much it is working Kindly i have a question is there anyway to put the insert statement inside this trigger? I am confused because the examples in saw in the book make some kind of filtration on the insert command, but in this question, we are not doing any kind of filtration except we r decreasing an amount from another table. correct? thanks
  6. Hello I have two tables: 1) order_line (order_number, part_number,number_oredred, quoted_price) 2) part (part_number, units_on_hands, item_class...) i am requested to write an INSERT trigger on order_line table. the trigger should decrease the units on hands in the part table for the part just inserted into the order_line table. I am trying to write this trigger by myself, but I have something wrong. Please Help delimiter // create trigger order_line_ai After Insert on order_line for each row Begin Set @part_num = New.part_number; update part set units_on_hands = units_on_hands-- where part.part_number = @part_num; End; //
  7. Thank You
  8. Hello I am studying a function getCompletion(inputControl, evt) the html code is <input id="name" type="text" onkeyup="getCompletion(this, event)"/> the function starts with statement and my questions about it: evt=evt ? evt : (event? event : null); 1) is evt the second parameter sent in the onkeyup event? 2) What is event? 3) how can we read this statement? what does it do? thank you very much
  9. Thank you
  10. Thank you
  11. Hello what is the regular expressions that match any occurrence of the word Javascript in a text string? is this correct? /^.JavaScript.$/ thanks
  12. Thank you ignace, this is very helpful i appreciate that
  13. Hello I want to write a specific procedure as a Homework. I started with simple procedure, without declaring and exit or leave or IF statements. I wrote and created this procedure correctly: delimiter // create procedure customer_proc3 (IN cus_id INT(11), IN lname VARCHAR(50), IN fname VARCHAR(50), IN dobirth date, IN phone_num VARCHAR(20), OUT the_result INT) BEGIN Declare the_result INT default 0; CASE cus_id when cus_id < 0 THEN SELECT 'The customer ID is less than Zero'; when cus_id = 0 OR cus_id IS NULL THEN SELECT 'The customer IS is equal to zero'; ELSE SELECT 'The Customer ID is smthg else'; END CASE; END; // When I call it, i have an error: mysql> call customer_proc3 (0,'John','Smith','1979-05-18','7687564', 5); the error is: 1414 (42000): OUT or INOUT argument 6 for routine test.customer_proc3 is not a variable or NEW pseudo-variable in BEFORE trigger If I call the procedure with only the five parameters, it also gives an error! ERROR 1318 (42000): Incorrect number of arguments for PROCEDURE test.customer_proc3; expected 6, got 5 WHY are both errors? Thank you very much
  14. Hello I have a customers table: +-------------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+-------------+------+-----+---------+----------------+ | customer_id | int(11) | NO | PRI | NULL | auto_increment | | last_name | varchar(50) | NO | | NULL | | | first_name | varchar(50) | NO | | NULL | | | dob | date | YES | | NULL | | | phone | varchar(20) | YES | | NULL | | +-------------+-------------+------+-----+---------+----------------+ i want to write a stored procedure that accepts as parameters all customers table columns. if customer id is 0 or NULL, then make insertion, otherwise an update. This is the code i wrote: delimiter // create procedure customer_proc (IN cus_id INT(11), IN lname VARCHAR(50), IN fname VARCHAR(50), IN dobirth date, IN phone_num VARCHAR(20)) BEGIN IF cus_id == 0 OR cus_id IS NULL THEN insert into customers (last_name, first_name, dob, phone) values (lname, fname, dobirth, phone_num); ELSE update customers set last_name = lname, first_name = fname, dob = dobirth, phone = phone_num where customer_id = cus_id; END IF; END; // I got this error: ERROR 1064 (42000): 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 '== 0 OR cus_id IS NULL THEN insert into customers (last_name, first_name, dob,' at line 3 Thank you very much
  15. Thanks MrAdam ur code solved the problem actually this code is not mine, our instructor asked us to read handouts she posted, and i like this code function and wanted to test it then I had troubles with it, the code that you used is what we studied at college thank you
  16. Thanks now i have another error! oHideButton is not defined thank u very much
  17. Hello I am testing this script on firefox <script type="text/javascript"> function fnHide(oToHide){ window.setTimeout("fnHide2(" + oToHide.id + ")", 3000); } function fnHide2(sID){ var o = eval(sID); alert (o); o.style.display="none"; } </script> <input type="button" value="Count Down" id="oHideButton" onclick="fnHide(this)"> when I click the count down button, and after 3 seconds, the firebug shows this error message: oHideButton is not defined window.setTimeout("fnHide2(" + oToHide.id + ")", 3000); Please help thank you
  18. Hello I would like to know what is the job of document.observe? i tried to google it, but i found long articles. as i want only to know its definition in simple words. thank you so much
  19. Thank You all.
  20. Thank You so much
  21. Hello Kindly help me in this, I want to know what statements are correct in MySQL. A. SELECT state, sum(sales) sum_sales FROM sales WHERE sum_sales > 100 GROUP BY state. B. SELECT state, sum(sales) sum_sales FROM sales HAVING sum(sales) > 100 GROUP BY state. C. SELECT state, sum(sales) sum_sales FROM sales WHERE sum(sales) > 100 GROUP BY state Thank you so much
  22. Hello I am doing a homework for my college, i am asked to attach an existing event handler names fastSpeedChange to the onchange event of the <select> node. the <select> node is referenced in this statement: this.fastSpeedNode = $ (params.fastSpeedId); the event handler is: this.fastSpeedChange = function () { alert ("working"); } if I write this: this.fastSpeedNode.onchange = fastSpeedChange; i get this error: fastSpeedChange is not defined plz help thank you
  23. Hello you are right, maybe this application i am working on is just to teach some aspects and not very accurate but i like your exact reg. thanks
  24. Hello I am doing a javascript homework, i am asked to write a reg to validate a password like this: start with 4 or more letters, end with 2 or more digits so i wrote this return /^\w{4,}\d{2,}$/.test(text); is it correct? when testing the application i write abcd12 as password but it doesn't work, plz help thank u
  25. Thank You
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.