Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Update table procedure through pl sql using loop

2986888Jul 29 2015 — edited Jul 31 2015

Assuming that I have only one table : members_tbl which columns are : SN, FN, DB, IDDBL,FLAG, DBLCRIT

I need to update the table if some conditions are OK with this algorithm :

id_dup := 1;

FOR (i in 1 to Nrow(members_tbl)) THEN

  {

  FOR (j in (i+1) to Nrow(members_tbl)) THEN

  {

  IF(members_tbl(i).iddbl IS NULL) THEN

  members_tbl(i).iddbl := id_dup

  IF (((members_tbl(i).DB ==members_tbl(j).DB)

     AND (UTL_MATCH.jaro_winkler_similarity(members_tbl(i).SN,members_tbl(j).SN) > 80)

     AND (UTL_MATCH.jaro_winkler_similarity(members_tbl(i).FN,members_tbl(j).FN) > 80))

     AND (members_tbl(j).iddbl IS NULL)) THEN

       {

         members_tbl(j).iddbl := id_dup;

         members_tbl(i).flag := 1;

         members_tbl(j).flag := 1;

         members_tbl(i).dblcrit:= 1;

         members_tbl(j).dblcrit:= 1;

  }

  }

  id_dup := id_dup + 1;

  }

Is there a way to write this algorithm in a pl/sql procedure ? I'm relatively new to PL/SQL and i've never written a stored procedure.

This post has been answered by BluShadow on Jul 30 2015
Jump to Answer

Comments

807567
Have you tried the following:

./start_of_my_script ... \
contination of parameters \
more continuation ...

I believe by breaking it up with the '\' you can get around the character limitation.
807567
Hello,

thank You for reply - temporarly I used "\" character to "split" command - it works, but I want send all in one line.... :/
807567
Maybe you should just put the whole thing in a shell script. What is causing the command to be so long? Do you have to call the absolute path?
807567
Hello,

unfortunately I cant use script - I use shell as a one of connection types.
All scripts I writes in Expect and from that I send all commands.Commands are creates dynamically. I send "snmpset" command, which have more characters than allowed for sh size.

Cheers,
Jacek
807567
Hello.

I do not understand if I understood your problem correctly.

I tried the following script:
#!/bin/sh
# The following line is more than 3000 characters long
echo 0 1 2 3 ... 1000
It works well on Solaris 10/x86 and Solaris 9/Sparc.

Do you have any example script?

Martin
807567
Hi,

simple example :



#!/usr/mdstest/bin/expect -f


spawn /bin/sh
set cmd "snmpset -v 2c -c ptcBRASprovisioning 10.18.124.17 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.3.184549545.33.55551 i 4 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.4.184549545.33.55551 i 103355551 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.5.184549545.33.55551 i 2 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.6.184549545.33.55551 i 0\r"

puts $cmd
send $cmd


expect {
-re "Timeout: No Response from" {
puts "Can't connect to ATM"
}

-re "Was that a table" {
puts "Invalid name of table"
}
-re "Error in packet\.\[^\n\]+" {
puts " pierszy |$expect_out(buffer)|"
expect {
-re "Reason:(\[^\n\]+)" {
puts "BEGIN$expect_out(1,string)END";
}
}
expect {
-re "Failed object\[^\\$\n\]+" {
puts "ERR in packet - ||$expect_out(buffer)||"
}
}

}
-re "SNMPv2\n-SMI::enterprises\[0-9\\.\]+\[ \]+=\[ \]+INTEGER:\[0-9 \r\]+" {

puts "END TRANSMISSION "

}

-re "\\$ " {
puts "PROMPT"
}
default { puts "default" }
}


When it I ran script I got ( line from send command ):
snmpset -v 2c -c ptcBRASprovisioning 10.18.124.17 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.3.184549545.33.55551 i 4 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.4.184549545.33.55551 i 103355551 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.5.184549545.33.55551 i 2 .1.3.6.1.4.1.4874.2.2.8.1.$ PROMPT

another simply test : from bash invoke /bin/sh and try to paste line :
snmpset -v 2c -c ptcBRASprovisioning 10.18.124.17 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.3.184549545.33.55551 i 4 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.4.184549545.33.55551 i 103355551 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.5.184549545.33.55551 i 2 .1.3.6.1.4.1.4874.2.2.8.1.3.3.1.6.184549545.33.55551 i 0
- it has more than 257 characters

Cheers,
Jacek
Robert Cohen
You might want to try spawning /bin/bash instead of /bin/sh.
The gnu variant of tools tend to be more resiliant to issues like buffer lengths.
807567
I tried with

bash-3.00$ which bash
/pkg/bin/bash


but I have the same results....
807567
On my Blade-1000 I was able to re-produce the problem:

Three "shells" are involved in your script:
- Bash
- Tcl/TK
- Expect

The "send" command is used to send data from Tcl/TK to Bash. This is done using a pseudo-tty, not using pipes (as it is done normally).

All TTYs (terminal, console, pseudo-tty, telnet, ...) seem to be limited to 256 characters when being used in "canonical" (line-wise) mode.

None of the programs (Bash, Tcl/TK, Expect) have a limitation to 256 characters.

The solution would be calling the command line directly (something like "spawn $cmd"), if possible using pipes instead of a pseudo-tty (using "open |xxx" instead of "spawn").

Note: Investigating your problem I had my first experiences with Tcl.

Martin
807567
Hello,

Yes You are right, none of them - bash, tcl, Expect havn't limitations - only shell has it.
For that reasons I ask here, which system parameter should be changed to fix it...

I think that MAX_CANON, but I not sure. What do You think ? Do You know any side effect of increasing this parameter ?

Cheers,
Jacek
807567
Hello.

You are right. It is MAX_CANON.

However looking on the OpenSolaris sources you can see that you would have to re-compile the ldterm kernel module because the MAX_CANON parameter is hard-coded into this module.

Martin
807567
Hello,

Thank You for all help and explanations.

Cheers,
Jacek
807567
Another option is to insert this expect command before spawning the process:

set stty_init raw

for more information, see

https://www.pooryorick.com/secure/wiki/Pub/UnixTroubleshootingInteractiveInputLineLength
1 - 13
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 28 2015
Added on Jul 29 2015
21 comments
3,002 views