Gomer <> wrote:
> How can I send a parameter I read inside of a PERL script to a SQL
> script.
> For example, I have the following:
>
> chomp ($login_name = uc(<STDIN>));
>
> Now, I want to send that $login_name to a SQL script. I'm doing
> something like the following:
>
> $sql = "declare \n";
> $sql .= " v_new_pswd varchar2(20); \n";
> $sql .= "begin \n";
> $sql .= " v_new_pswd := db_login.crypt_passwd('NEW_PASSWORD'); \n";
> $sql .= " update table set pswd = v_new_pswd where user_id =
> '$login_name'; \n";
> $sql .= "end; \n";
> $sql .= "/ \n";
> $sql .= "commit; \n";
Did you try adding this statement at this point?
print $sql;
You should use a "here-document" if you want to see what
you are writing:
my $sql =<<ENDSQL;
declare
v_new_pswd varchar2(20);
begin
v_new_pswd := db_login.crypt_passwd('NEW_PASSWORD');
update table set pswd = v_new_pswd where user_id = '$login_name';
end;
/
commit;
ENDSQL
Does the same thing as your code, but *looks like* what
you are constructing.
> @output = run_sql_query ($login,$password,$sql);
>
> I'm using some libraries that came with my system so I know that
> everything is working correctly except that the login_name isn't being
> passed.
How does run_sql_query() indicate errors?
No Perl there.
> How can I format the login_name so it's correctly interpreted in
> my SQL script?
That depends on how an "SQL script" wants it formatted. Looks OK to me...
No Perl there either.
--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas