Calling MySql Select Procedures In Perl
I am trying to call a "select" stored procedure from perl. I am not quite sure how to do it. Here is the stored procedure:
CREATE PROCEDURE spTest() begin select x AS X from tblTest;
It works fine when called from within MySQL.
mysql> call spTest():
+------+
| X |
+------+
| 24 |
| 3 |
+------+
I have the following code in perl:
my $spt = $db->prepare("Call spTest()");
$spt->execute();
$spt->bind_columns($id);
while($spt->fetchrow_array()){
print "X = $id";
}
I get an error that says I need to use "select into". How do I call this procedure from perl?
View Complete Forum Thread with Replies
Related Forum Messages:
Select Via Perl
I am trying to read a file and see if the contents of it exists in the DB or not and am trying to do it via a Select.I try to do a select * into outfile /tmp/result.txt from table where field like "%$var%"; but it always goes through the first two lines of the input file and then says the file already exists. Is this because I read each line of a file in a for loop in perl and the mysql query tries to recreate the outfile each time? Is there any other way I can dump the results of the select to a file of some sort?
View Replies !
Calling Mysql Db From Php
for some reason any php script I write will not call any mysql databases. I have loaded ,mysql 5.0.27 onto my computer as well as apache 2.0.52 and php 5.0.2 but I don't really know if I need to change some code which allows php to call the mysql db's I'm using a windows machine if that makes any difference.
View Replies !
Stored Procedures For View / Select Query
i am trying to use a stored procedure inside a view in mysql 5.1.4 and it does not seem to work. the thing is i have a sp containing a simple SELECT statement and a simple view to select only some fields from my stored procedure. here's my sp DELIMITER // CREATE PROCEDURE sp1() BEGIN SELECT a, b FROM tbl ; END // DELIMITER ; i need to select only one field from this procedure through a view/query.
View Replies !
Calling Mysql C API In C++ Project
I am using mysql C API in my C++ project. I am using mysql-4.1.4-gamma and gcc 3.2.2. Problem with this code is that when add_data(i) is called second time SEGMENTATION FAULT occurs at mysql_real_query(). First time it executes the add_data() function successfully. Code:
View Replies !
Calling Mysql Fields Into A .php Webpage
Situation: I have created a .php document that displays a youtube video and it works fine. What I want: I want this .php document to display a users youtube video, so i need to get the field from the database and make it so the .php document can call it and use the link from it to display the video. The server is called: 'localhost' The database is called 'db_vbulletin' The table is called 'userfield' The field is called 'field39' But saying this, the youtube video link will be different between users, so im not sure what kind of factor that would have.
View Replies !
Calling MySQL In Unix In One Line
I'm running MySQL in Unix and I need to run mysql without ever actually going into mysql. Basically I need to open the database, do what i need to do to the database and exit all in one line of code. If I have to, I could save the sql in a file and go mysql -h localhost -u ______ -p _________ << mysqlcode.txt or something with Unix redirection/piping. However, I'd like to do something more like mysql -h localhost -u _________ -p ________ - (use tempdatabase; select * from test;) Is there anyway to do this. The -e paramater looks like it might do that, but I can't figure out how to use it.
View Replies !
Calling A Php Funtion Inside A Mysql Query
hi there, im trying to call a php function that i have created inside a query and im getting an error.when i remove the funtion statment the query is successful. i was wondering is it possible to call a php function inside a query, if so how do i go about doing so. this is my code:
View Replies !
Calling MySQL Experts! Using LIMIT Within IN Subquery Question
I have 2 tables that I need to pull data from: 1. members (which contains all my members, of course) 2. blogs (which contains blog posts made by members) The primary key of members is userid, which is a foreign key in blogs. So.. what I'm trying to do is pull out the latest 30 entries and NOT show duplicate posts from the same member. The closest working query of this I wrote is this:
View Replies !
MySQL, Perl CGI
I'm developing a simple computer helpdesk system with MySQL as the backend and Apache/CGI/Perl as the user interface. I've sucessfully set up the part where a user enters an issue via HTML form and "submits" it to the MySQL database. My question is: I have it set up where the user posts the issue to the database, the database auto_increments an issue_id number field. How do I return that issue_id number back to Apache so that the user can see it (and use it as a reference number)?
View Replies !
Perl-DBD-MySQL
I have a binary distribution of MySQL 4.0.20 installed in /usr/local/mysql. Therefore, the only libmysqlclient file I have is libmysqlclient.a (static library). And also, Perl:DBI already installed. I'm trying to install perl-DBD-MySQL-2.9004 from source. What should I add to 'perl Makefile.PL' as arguments to make sure it finds the static library? I've tried 'perl Makefile.PL --libs=/usr/local/mysql/lib/libmysqlclient.a and gotten this: --------------------------------- [root@localhost DBD-mysql-2.9004]# perl Makefile.PL --libs=/usr/local/mysql/lib/lib/mysqlclient.a I will use the following settings for compiling and testing: cflags (mysql_config) = -I/usr/include -mcpu=pentiumpro libs (Users choice) = /usr/local/mysql/lib/lib/mysqlclient.a nocatchstderr (default ) = 0 nofoundrows (default ) = 0 ssl (guessed ) = 0 testdb (default ) = test testhost (default ) = testpassword (default ) = testuser (default ) = To change these settings, see 'perl Makefile.PL --help' and 'perldoc INSTALL'. Unrecognized argument in LIBS ignored: '/usr/local/mysql/lib/lib/mysqlclient.a' Using DBI 1.30 installed in /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBI Writing Makefile for DBD::mysql [root@localhost DBD-mysql-2.9004]# --------------------------------- What should I do to get DBD-MySQL to install correctly?
View Replies !
Using Perl With Mysql
I have heard that if you want a view with mysql, perl is one iof the best applications to use. I want to make a user interface with perl that will prompt the user to enter values and then those values will be stored into the database. I'm just started to learn how to use perl, can anyone give me a little help with writing the code?
View Replies !
Perl DBD::mysql - Using Arrayref
I have an app where I would like to display a returned table with column headings as specified in the inquiry (select), while preserving the column sequence of columns as specified in the original inquiry - without having access to the original inquiry. If I use the fetchrow_hashref method, I can determine the column headings, but I lose the sequence. If I use fetchrow_arrayref, I preserve the sequence, but I lose the column headings. I suspect there is an easy answer. Anybody have it?
View Replies !
Dealing With Mysql Through Perl
i'm working with a mySql database. i have accessed the database through perl. now i want to know how i can store images in the databases through perl and how to retrieve it.. does anyone have an idea abt this?
View Replies !
Perl And Mysql Datetime
I am trying to have an update form for a datetime field. I've been looking all morning and haven't been able to find any examples of how to do it. I have the date in the form formatted by perl like this: 08-14-2006 11:29:28 and when I do the update to mysql nothing happens. It does not work. I need to make it so the user can put the time the student left.
View Replies !
Perl/mysql On Linux
i am not getting the output for the following code (given below) in apache server on linux. but i do get ouput in perl interpreter please replay me . vinaykumarms@rediffmail.com #!/usr/bin/perl print "ContentType: text/plain "; use DBI; # Connecting to the database # Replace DATABASENAME with the name of the database, # HOSTNAME with the hostname/ip address of the MySQL server. $drh = DBI->install_driver("mysql"); $dsn = "DBI:mysql:database=vinay;host=localhost"; $dbh = DBI->connect($dsn,"",""); # Select the data and display to the browser my $sth = $dbh->prepare("SELECT * FROM login"); $sth->execute(); while (my $ref = $sth->fetchrow_hashref()) { print "Found a row: id = $ref->{'id'}, name = $ref->{'name'} "; } $sth->finish(); # Disconnect from the database. $dbh->disconnect();
View Replies !
Verifying Mysql Writes (perl)
What is a proper way of verifying that a mysql write was successfull, and to retry if it wasnt? In my perl script I add records through: my $dbh=DBI->connect($dsn, $db_user_name, $db_password); my $sth=$dbh->prepare("insert into TABLE (X, Y, Z) values ('1', '2', '3')"); $sth->execute; $sth->finish; I have noticed that from time to time this fails, due to limitations of my webhost. I thus want to do a check after the write, that it actually happened, and if not redo.
View Replies !
Unable To Connect To Mysql Via Perl
I am attempting to connect to my mysql using a perl script, and keep getting an error message that tells me the I am missing a sub routine. I have installed DBI and DBD::mysql but still can not use my $dbh = open_dbi($db,$username,$password) I am assuming that open_dbi is not installed, does anyone know of another, or better way to access mysql via perl.
View Replies !
Installing MySQL 5 Perl DBI Must Be Installed?
the steps to installing MySQL 5 on Red Hat Linux 9? When I follow the steps as outlined in the manual or Red Hat text I get an error that Perl DBI must be installed. After attempting to download the Perl DBI; that failed because the server was not availabe. Eventually I was able to download some Perl stuff, but not the DBI. Here is the problem at its root. Where is the information to handle all of the error messages? Where is the source of knowledge to work around these problems?
View Replies !
Retreiving MySql Data With Perl (DBI)
I have been trying to retrive data out of MySql data file using DBI and Perl for a while with no luck. I get message "Can't locate loadable object for module DBI in @INC (@INC contains: C:/Program Files/Perl/lib C:/Program Files/Perl/site/lib .) at C:/Program Files/Perl/lib/DBI.pm line 258" I have DBI.pm in above respected directories. I have no problem retreiving data out of flat files ie simple text file with delimiters. I use windows xp,Perl,Apache server and MySql server at home with no other problems.
View Replies !
MySQL/Perl Book Recommendation For A Beginner?
Here's the situation: I have a Perl-based forum that I wrote myself. It currently supports user accounts, but these are stored in a flat text file (as is everything else for that matter). I'm looking to convert this to a MySQL database so that I can do more with that information, but with less processing time (reading through that huge text file to find something isn't very efficient). In the future I hope to move the whole forum over to MySQL, but I thought a good starter project would be just one aspect of it. At this point I am looking for recommendations on good books for someone moderately experienced with Perl, but who has NO experience with MySQL or anything similar. Since I'd prefer to integrate this with my existing script, I'd rather stick with Perl and not learn PHP at this time. So far it seems like "MySQL and Perl for the Web" is a good - are there others? I prefer reference-style texts with useful code examples, rather than lesson-style books.
View Replies !
GUI For Stored Procedures In MySQL?
I have a website that is using MS SQL Server 2000 with ASP scripting. I want to switch over to MySQL, but I'm just sticking my toes in the water at the moment to see if it makes sense. One of my favorites things about MS SQL is being able to use the Enterprise Manager as a GUI in constructing VIEWS that I later turn into stored procedures. EM makes it super simple to link tables and create a query. It basically writes the source code for you as you go and you can test run it interactively until you get the results you want. I then take the resultant source code and paste it into a stored procedure, which in turn is called by my website script. This allows a relative novice like me to manage a somewhat complex database structure. My question is: does the MySQL GUI allow for the management of stored procedures in a similar manner? Can I create a view and just "cut-and-paste" the source into a dialog box that will then create the stored procedure for me? Does MySQL allow for the visual management of stored procedures within its GUI?
View Replies !
MySQL 5 Stored Procedures
I've recently downloaded the Windows mySQL 5 binaries. Is there any GUI that supports the creation of Stored procedures? I'm using mySQLcc 0.9.3 and this doesn't seem to like them (from a SQL window) unless there is a trick that I'm missing.
View Replies !
ASP.net And MySQL And Stored Procedures
Hopefully this is simple and I'm making too much of it... here it goes... First part of the question (which I'm hoping most can answer) I have googled and googled and gave up in the end of trying to find a clear example of creating a stored procedure USING a parameter in MySQL. ANY help or simple direction to a tutorial would be awesome. Second... I have downloaded the evaluation of Visual Studio 2005 to get used to asp.net. I'm using MySQL database, please note I have installed and patch all the revelant dot net components and plugins to get it to create a connection string to MySQL Server. Though it doesnt look liek the VS GUI wants to communicate with MySQL leaves it up to you to create the SQL. (Which isn't a problem.) But... I want it to work with Stored Procedures (you see Visual DOES let you use exisiting stored procedures contained within your database server) .... Which points back to question one, but anyway the point of question two is has anyone else experience an attempt to get MS Visual Studio 2005 and MySQL working together? Note: I can already pull in data from MySQL using coded connection string within the backend code of a .net page.
View Replies !
Debugging Mysql Stored Procedures
I serfed web to find some kind of mysql stored procedure debugger. But I found nothing. Last week at last a tool with integrated debugger was released. It uses debug engine. like an oracle dbms_debug, and supports breakpoints, watches, call stack, and stepping through code facilities. May be it can help you developing complex stored routines.
View Replies !
Mysql And Triggers/stored Procedures
I have a question regarding the use of triggers. I have difficulties implementing trigger that let's say reacts before/after select statement (select of user), and increments the counter value (of the selected user). Is there a way to achieve this through triggers, or it's not possible?
View Replies !
Calling One Value From Table
I got a table that has only 1 field 1 row of an INT value: $query = "SELECT * FROM site_counter $result = mysql_query($query); $row = mysql_fetch_array($result); echo "$row[0] People Visit My Site"; is there any shorter way to call up that value ?
View Replies !
Calling Db Function
how do i call a db function from with in a db function which returns a result. can some one pls help me with the syntax, when i call a function from with in a function it says funtion does not allow to return a result set where as it returns only one values.
View Replies !
Calling Another Database?
I've encountered an issue using foreign keys with mysql: is it possible to call another local database from within a table of a database? For example, if I've got a database consisting of car manufacturers and another one consisting of retailers, then I'd like to have the retailer database to reference the manufacturer database in some way. For example: CREATE TABLE retailer1 ( FOREIGN KEY car TEXT REFERENCES manufacturer.cars(car) ON DELETE CASCADE ON UPDATE CASCADE; ) TYPE INNODB; This way I hope to be able to have the retailer database up-to-date. Is it possible to reference another database in this manor? How do I do it in that case?
View Replies !
MySQL 5 Stored Procedures: Returning Prematurely
I would like to know whether it is possible to return prematurely from the body of a MySQL 5 procedure. It seems MySQL 5 only allows the RETURN keyword in PROCEDURES, so I end up having to solve this problem by using a whole bunch of nested IF statements. Is there a better way?
View Replies !
Difference In Stored Procedures Between MSSQL & MySQL
what's the differences in stored procedures between mysql and mssql? for example to start: CREATE PROCEDURE spinsertnew @filesource int, @firstname nvarchar(200), @lastname nvarchar(200), @email nvarchar(250), this is already erroring withing the first few lines why? i'm trying to convert a stored procedure from MSSQl to mysql. -- can you point me to a place that's good to learn mysql stored procedure syntax?
View Replies !
Can Arrays Be Used In Stored Procedures And Triggers In Mysql?
I was trying to use arrays in stored procedures but it resulted in syntax errors.Is there any way to use arrays in stored procedures. I have one more question,in triggers if we want to check each column of a table if updated ,is there any way that i can write then in a loop. In the example given below I tried to check change for each column in a table.If there are 10 columns then I have to wirte 10 if statements. Is there any way that I list all the columns of the given table with in a trigger and write loop that contain a if statement that works for all the columns. create trigger updata after update on dataid_list for each row BEGIN if NEW.databaseid <>OLD.databaseid then insert into view_changes SET old=OLD.databaseid,new=NEW.databaseid, operation='UPDATE',column_name='databaseid' end if; if NEW.databasename <>OLD.databasename then insert into view_changes set old=OLD.databasename,new=NEW.databasename, operation='UPDATE',column_name='databasename' end if; END;
View Replies !
MySQL Persistent Connections, Stored Procedures
We have a PHP/MySQL based website. It's our first project where the DB work is being handled my someone else the client hired. They are having us use a lot of stored procedures they created. We've found that in order to run the procedures we have to use a persistent (mysql_pconnect) connection in our PHP scripts. Otherwise, using mysql_connect, ALL the stored procedures generate a mysql error. If we use pconnect they don't. Is this normal to have to use pconnect with stored procedures and if not, what could be the cause? The second problem we are now running into is we are unable to connect to the database because we are exceeding the max connections. Even on our development server which uses a separate database on a separate server with maybe only has 5 or 6 different people that know about the website and use it. The production site is maxed out, getting a too many connections error message. We are still invetigating but I believe they said there were 40 connections to the database. The website is inaccessible because it can't connect. I guess another thing I'm curious about is on a website that is very DB intensive and has maybe a max of 50 simultaneous users at a time, what would a reasonable setting be for max connections on MySQL considering we have to use persistent connections?
View Replies !
Calling A Stored Procedure
From what I've read, you can't call a stored procedure directly from a select statement...is that correct? I have this query I'm trying to run: select * from projects where proj_desc like '%".$searchterm."%' and proj_type = '".$proj_type."' and GetDistance($lat1, $lat2, proj_lat, proj_lon) < 50 order by ".$order This query is looking through a database of projects, and running a stored procedure(GetDistance) to find which ones are within a certain distance away (hence the lat and lon being passed to the sproc). The query is doing this while also processing the user's search term they've put in.
View Replies !
|