Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Converting from one language to another?

by Anonymous Monk
on May 30, 2003 at 21:53 UTC ( #261958=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Can code that is written in sql be converted to perl?
  • Comment on Converting from one language to another?

Replies are listed 'Best First'.
Re: Converting from one language to another?
by boo_radley (Parson) on May 30, 2003 at 22:44 UTC

    Hello, and welcome to the fascinating world of perl.
    You'll be pleased to know that perl has bindings to many popular databases. This means that your code doesn't even need to be converted, but can be wrapped into perl directly! Just take your SQL and swaddle it in layers of perl. There are plenty of references for working with databases in perl; here's a good starting place.
    You may also, as your fascinating journey progresses, you may decide to return to perlmonks. Should you do so, you might want to think about perusing our help system, and in particular, how to craft your question for maximum impact.

Re: Converting from one language to another?
by ctilmes (Vicar) on May 30, 2003 at 22:07 UTC
    SQL isn't really a programming language (though there are variants that are like PL/SQL, Transact-SQL and the like).

    SQL is a query language.

    There are ways of expressing similar queries to SQL in Perl-like ways, but it is more likely to use something like DBI/DBD to interface with an SQL database directly.

    In any event, your question is very vague, so the answer isn't really that clear. What exactly are you trying to accomplish?

Re: Converting from one language to another?
by tcf22 (Priest) on May 31, 2003 at 00:08 UTC
    Perl and SQL are languages created to do totally separate things, so converting SQL to PERL really wouldn't be all that useful.

    However using PERL and SQL together can make your jobs a lot easier and can also lighten the load on your SQL server. Compiling large amounts of data and having SQL do processing on all of the records, which on heavily used database servers, can slow the server a lot, which can be a problem especially with CGIs which will timeout. Instead you can do the data processing in PERL, which will free up some processing time on the database server. Not to mention huge SQL queries are just a pain to begin with.

    This is just from personal experience, where we had many database servers brought to their knees by programmers who didn't take advantage of perl's data processing power.
Re: Converting from one language to another?
by TomDLux (Vicar) on May 31, 2003 at 00:57 UTC

    The thing about SQL is that that is the language your database server understands. It is possible but extremely unlikely for DB servers to understand more than one language. However, if you found one that did understand more than one language, it is a toss of a coin whether that second languyage would be Pascal or Basic or FORTRAN or Perl or ..... But, in fact, none of those languages are suitable for dedscribing set operations on data base tables.

    If a database server DID understand Perl how would you specify that it should find you all single employees under age 25 who have more than 5 hours overtime this week?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://261958]
Approved by Zaxo
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2019-07-24 06:31 GMT
Find Nodes?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?

    Results (32 votes). Check out past polls.