in perl, I am struggling to find a simple method of connecting to a database, determining if the result of my query is "true" and then testing against the result. I dont even really want the data that i am 'SELECT'íng. i effectively just want to check that a record exists with a UID column (primary key) that exactly matches the $uid that has been passed to my script.
I have managed to fudge a solution together that involves me having to
NOTE: the $uid is passed to script as an argument to the script
1) going to the db and doing "SELECT UID FROM table WHERE UID = $uid"
2) using fetchall_arrayref() to pull the result into an array (although should never be more than one return seeing as the data being requested is a primary key)
3) cycling through the array and sending each value to a fine in /tmp
seeing as this file will only ever contain something or nothing, i do a test later on the script to see if the file has content, if it does, i know that my query was "true" so to speak and I can be sure this a record for the $uid passed to my script in the database
I know that this seems a ridiculously over the top way to do this, but i am relatively new to perl and it was the only way i could get it to work.
I just wondered if any of the fine gurus on this site could advise me a way of doing a simple 1/2 line version of the above without all the faffing about that ive had to do . bear in mind, all i need to do is test that a record exists, i dont even need to pull any data from the DB or send any to it at this stage
PERL MODULE :
To debug my perl module code in test environment. I have taken production module to the test in the my home path directory and was trying to test it by changing the below path in my test code.
But still i am getting the error to debug it. can you please let me knw whether i am... (13 Replies)
Hi Gurus, kindly analyse the following for me, please
OS: Windows 7
Code location: C:\
Output: "Program Files not being recognised"
"System Volume Information is a directory"
"Windows not being recognised"
main {
my @dirlist = <*>;
foreach my $fn... (0 Replies)
Hello;
I was trying to set up a mysql database using following script, but never went through. The code seems fine without any syntax error as I tested it:
perl -c Brapa0101-db.pl
Brapa0101-db.pl syntax OKHowever, whenever I run it, an error message was tossed out:
DBD::mysql::st execute... (7 Replies)
Hey guys i am using perl and trying to pull a list of books from a database and then populate the list in a separate TT2 file. When the list is generated there should be 39 book names. When I do the foreach statement in my tt2 below, the first statement gives me 39 Array(random number) and the... (1 Reply)
Welcome. I am writing a perl script. I have to design a database consisting of a single table (any subject) saved in a text file. (I make it vi command name and I am giving permission chmod u + x?) The table should contain at least four columns, including a column containing the ID (serial number )... (4 Replies)
Hello,
I am new to Unix scripting, and would like some help with my issue:
I have vairous files having some alphanumeric codes in them e.g.
10000-01
34440TE
34590SR
All these codes are stored in the database, and I need to parse these codes out of these filenames, and match them... (2 Replies)
hi there, I have some database output that looks like this
SELECT nic_name,nic_duplex,nic_speed,nic_ip FROM network_table WHERE hostname = "server1"
result is this (ive delimited with a pipe for ease of reading)
bge0|full|1000|10.32.100.1
bge1|full|1000|11.12.101.7 ... (1 Reply)
Hi,
I tried to run this code but it isnt giving me any output or errors.
My aim is to retrieve the row based on the flag name(this is the primary key).
flag_test is my table
This is how i ran it:
perl read_db.pl flag1
flag1 is the criteria in where clause
--------
this is my... (2 Replies)
Hi,
While i am trying to connect to Oracle database from Perl using DBI module,am getting the error as follows :
Can't load '/usr/local/fuseperl-modules/lib/i586-linux-thread-multi/auto/DBD/Oracle/Oracle.so' for module DBD::Oracle: libwtc9.so: cannot open shared object file: No such file... (4 Replies)
I have a microsoft access database with anout 220 lines. theres a question and 4 option awnsers and only ones correct which is also listed in th database.
Is there any perl script that will copy and the lines from the database and put into a .asp website ? (2 Replies)