Re: insert sql commands from a perl script

From: Ephrayim J. Naiman <ejnaiman_at_access4.digex.net>
Date: 1996/01/10
Message-ID: <4cv1qf$3ab_at_news4.digex.net>#1/1


Herve Muyal (hmuyal_at_disun5.epfl.ch) wrote:
> How do I have to do if I want to execute sqlplus commands in a perl script?
> I just want to do this command:
>
> INSERT INTO tablename VALUES ($var1,$var2,$var3);
>
> where $var1, $var2, $var3 are perl variables.
>
> If anybody has a -not too complicated- solution please let me know.

You need a package called oraperl. Once you have it, there are a number of functions available. You can run SQL code with PL/SQL blocks with an ora_do() function. Or, embedded SQL is done as follows (no error checking here):

#!/usr/local/bin/oraperl

$lda = &ora_login("<DB_name>", "<User>", "<Password>"); # Notice there are single quotes around value1. The issue of # SQL parsing for a character value is still needed. $csr = &ora_open($lda, "insert into <table> values ('${value1}', ${value2})"); _at_results = &ora_fetch($csr);
&ora_close($csr);
&ora_logoff($lda);

-- 


						Ephrayim "EJ" Naiman
						ejnaiman_at_access.digex.net
Received on Wed Jan 10 1996 - 00:00:00 CET

Original text of this message