Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Perl DBI issue

by Win (Novice)
on Mar 14, 2007 at 14:49 UTC ( #604828=note: print w/replies, xml ) Need Help??


in reply to Re: Perl DBI issue
in thread Perl DBI issue

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Perl DBI issue
by izut (Chaplain) on Mar 14, 2007 at 15:13 UTC

    Why don't you just show the code you are using? If you do that, I bet a lot of people will try to help you to figure that out. If you don't help people to understand your problem and give them any resources for doing that, then you are lost. As I said before on CB, try to help the others to help you. You will learn more, the others will be satisfied to help you. Try to fix your position while people are still complaining about you, be worried when people just start to ignore you.

    Going back to your problem, your code is executed from a Linux box or a Windows box? I understand that you're trying to reach a SQL Server 2000, but what about the client? Another point, the DSN is usually the first argument for DBI::connect(). For exemple, when using a SQLite database, your DSN will probably looks like dbi:SQLite:dbname=my.db. The DBD driver you'll be using will be the thing between the :.

    Now, what are you using as DSN to connect the database and what is the operational system where the script is running?

    Igor 'izut' Sutton
    your code, your rules.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^3: Perl DBI issue
by Jenda (Abbot) on Mar 14, 2007 at 16:28 UTC

    So I scaned all your other posts in this thread and all I found was that you said in the root one that you are using MS SQL Server 2000 (I admit asking you for the value of @@VERSION would be pointless, there is no need for that level of detail in this case) and ... in one of the responses ... that you are using DBD::ODBC.

    I asked you to tell us the VERSIONS of the modules! And ... guess what ... they are nowhere to be found in the whole thread. Maybe the bug (if there is any) was alerady fixed in a newer version than the one you have. Maybe not, but how do we know?

    BTW, want some code? OK

    use DBI; our $db; our %sp; sub open_db { return if $db and $db->{'Active'}; Log "\nConnecting to the database"; eval { $db = DBI->connect('dbi:ODBC:Driver=SQL Server;Server=JobVIPeR +;Database=XxxXXXxX', 'xxx', 'xxx', {PrintError => 0,RaiseError => 1,LongReadLen => 65536,Auto +Commit => 0}); }; if (! $db) { Log("\tCannot connect to the database! : $DBI::errstr"); return; } Log "\tConnected"; prepare_sps(); } sub prepare_sps { $sp{SetDirty} = $db->prepare('EXEC dbo.SetInt ?, 1'); #... } #... $sp{SetDirty}->execute($objname."_dirty"); #...
    If you want to use placeholders for OUTPUT parameters than that's a bit more complex. You have to use bind_param_inout() for that, something like:
    my $import = $db->prepare_cached('EXEC dbo.ImportClient ?, ?, ?, ? +, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?'); db_error("compiling ImportClient",$db) if !$import; my $WasNew = 0; $import->bind_param_inout( 15, \$WasNew, 1); #... my $id = 0; $import->bind_param(++$id, $_) for @{$rec->{fields}}{@fields}; if ($import->execute()) { if ($WasNew) { $new++; } else { $updated++; } } else { db_error("updating client '$rec->{fields}->{client_desc}'" +,$db,1); $import->finish(); $incorrect++; } #...

    Does this help?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://604828]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2021-04-19 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?