I need help knowing where to save a query I wish to associate with a specific table
| User, date | Message |
|---|---|
|
Written by member
2 years ago Category: General 22 posts since Fri, 23 Apr 10 |
When I write a query, that I would reuse to do math in a table, is using snippets the correct place to save it? I do not understand anything about procedures or stored routines. I would think there should be an easy access way to save table specific queries. I can't really seem to find any sort of manual for Heidi and the help in the program is way over my head. Could you point me in the right direction? Would the snippets option be the best choice? I am currently saving my query in a varchar field titled notes, but I am thinking that this can't be the best option. Thanks |
|
Written by Tribal
2 years ago 23 posts since Thu, 28 Oct 10 |
as it sounds like, the best option for you indeed would be to simply save it as a snippet, as long as you're the only one using that specific query...once you need a query beeing also called by others, there's no way around using procedures/functions as you can assign access rights to certain users and more...but just as i said, saving it as a snippet should be the option in your case... |
|
Written by member
2 years ago 22 posts since Fri, 23 Apr 10 |
I would love to understand procedures/functions. Do you know of any place where I could learn how that works in Heidi? Would that be a stored routine? Could you give a really short example? I don't want to cause you too much trouble. Thanks |
|
Written by Tribal
2 years ago 23 posts since Thu, 28 Oct 10 |
well, as heidi is only an interface to mysql you have to learn the syntax and the operating principles of stored routines in mysql...adding such using heidi is simple:
information on how stored routines work and their syntax can be found here you should consider using the 'mysql reference manual' as your first place to go in case of looking for help... tutorials for working with stored routines can be found thousendfold on the web i hope i could help you a bit :) |
|
Written by Tribal
2 years ago 23 posts since Thu, 28 Oct 10 |
@anse: is the link parsing that corrupted or is there some step im doing wrong when inserting them? :D could you please spend a minute on reformating them and explain the mistake on my part for me? after '...syntax can be found here' in my previous post there should be the following link: http://dev.mysql.com/doc/refman/5.5/en/stored-routines.html thanks in advice :) |
|
Written by member
2 years ago 22 posts since Fri, 23 Apr 10 |
Tribal, Your links led to this: DELIMITER // CREATE PROCEDURE GetAllProducts() BEGIN SELECT * FROM products; END // DELIMITER ; So when I found this: BEGIN END After selecting create new stored routine while I was in the database tab, I inserted my query between begin and end. This required clicking on edit and paste, as paste did not work. I then named and saved the routine. This added the routine by the name i gave it in the list of tables on the left with the word run in front. Right clicking gave me the option to run the routine. It posted this in a query window : CALL `run name of routine`() and it also automatically ran without my having to enter via the blue arrow. Alternatively, I erased some of the changes and just put CALL `run name of routine`() and hit the blue arrow I will look at the other information in the link you gave, but you helped me very much with the info you provided. I am posting this in hopes it will help someone else also. Thank You!!! |
|
Written by ansgar
2 years ago 3949 posts since Fri, 07 Apr 06 |
The link parser expects something between the brackets, which you did not enter. Just fixed these links here. |
|
Written by ansgar
2 years ago 3949 posts since Fri, 07 Apr 06 |
Oh my god I have 2,212 posts here? |
|
Written by member
2 years ago 22 posts since Fri, 23 Apr 10 |
Forget about this part: with the word run in front In this phrase "This added the routine by the name i gave it in the list of tables on the left with the word run in front." I think I wrote run in front. |
|
Please login to leave a reply, or register at first. |