Home » SQL & PL/SQL » SQL & PL/SQL » String Parameter from Unix Shell
String Parameter from Unix Shell [message #37484] Mon, 11 February 2002 17:36 Go to next message
diaz
Messages: 58
Registered: October 2001
Member
Hello..

I have this code
DECLARE
/* eop dynamically declared outside of the code */
/* payment is the sum of payment done by the customer */
/* mysaldo is the deposit owned by the customer */
thiseop VARCHAR(6);
regional varchar(2);
/* FUNCTION getTunggakan */
/* MAIN */
BEGIN
thiseop := &1;
regional := &2;
dbms_output.put_line(thiseop);
dbms_output.put_line(regional);
tagihan := 'tagihan' || regional;
dbms_output.put_line(tagihan);
END;

if i enter the second parameter : 01 or 02 ... etc
the result is : tagihan1, tagihan2 ..
i wanted to make it as : tagihan01, tagihan02 .. etc
how can i do that..

thx
Re: String Parameter from Unix Shell [message #37486 is a reply to message #37484] Mon, 11 February 2002 19:00 Go to previous messageGo to next message
Ripu
Messages: 3
Registered: February 2002
Junior Member
Hi,

use lpad function in your parameters 'thiseop and regional.

regards
Re: String Parameter from Unix Shell [message #37489 is a reply to message #37486] Mon, 11 February 2002 19:43 Go to previous message
diaz
Messages: 58
Registered: October 2001
Member
thanks,
i've tried it.. but doesn't work.

Here's my code :
DECLARE
/* eop dynamically declared outside of the code */
/* payment is the sum of payment done by the customer */
/* mysaldo is the deposit owned by the customer */
thiseop VARCHAR(6);
regional varchar(2);
tagihan varchar(20);
/* FUNCTION getTunggakan */
/* MAIN */
BEGIN
thiseop := &1;
regional := &2;
lpad(regional,2);
dbms_output.put_line(thiseop);
dbms_output.put_line(regional);
tagihan := 'tagihan' || regional;
dbms_output.put_line(tagihan);
END;

Here's the error :

SQL> @ recons 200110 01;
old 11: thiseop := &1;
new 11: thiseop := 200110;
old 12: regional := &2;
new 12: regional := 01;
lpad(regional,2);
*
ERROR at line 13:
ORA-06550: line 13, column 1:
PLS-00306: wrong number or types of arguments in call to 'LPAD'
ORA-06550: line 13, column 1:
PL/SQL: Statement ignored

this can be done by using the if else statement
if regional < 10 then add the character '0' before it but i don't want to that .. cause i believe PL/SQL has already built the function to work something like this...
and there're some many functions.. and i'm running out of time here... need fast solution..

so pls help me...
Previous Topic: Better Hard SQL Window?
Next Topic: Re: Rollback to savepoints in a distributed transaction
Goto Forum:
  


Current Time: Wed Apr 24 14:31:53 CDT 2024