Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Converting from one language to another?

by Anonymous Monk
on May 30, 2003 at 21:53 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-25 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found