Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Not Getting Proper\Correct output


  • Please log in to reply
6 replies to this topic

#1 nitinkpandit

nitinkpandit

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:04:48 AM

Posted 22 June 2017 - 05:47 AM

Code AS below [below highlighted BOLD letters should come after last "SELECT" statement from file] ::

 

loop=1;

SEL_COUNT=2; [Count of select statements from file "sel_${HF}.file". I have multiple files].
 
## Printing Statement from original code ###
 
cat $ROOT_DIR/sel_${HF}.file | while read line ## while loop start
do
if [ ${loop} -lt ${SEL_COUNT} ]
then
echo "${line};";
echo "\nIF results='FAIL' then HF_result:='FAIL';";
echo "END IF;\n";
else
echo "${line};"
echo "\nIF results='FAIL' then HF_result:='FAIL';";
echo "END IF;\n";
 
echo "\n";
echo "IF HF_result='FAIL' then";
echo "RAISE ex_RedLight ;";
echo "END IF ;";
 
echo "\n";
echo "HF_result:='PASS';";
echo "\n--------------------------------------------------------------------------------";
fi
loop=`expr $loop+1`;
done ## while loop end
 
 
Input File [sel_${HF}.file]  to Printing Stmt ::
 
select distinct decode (UNTIL_DATE, to_date ('02/04/2017','MM/DD/YYYY'),'PASS','FAIL') as results from XXXXX where ID='XXXXXXXXX'
select distinct decode (Count(*), 9,'PASS','FAIL') as results from XXXXX where id=XXXXXXXXXX
   
Current Output ::
 
select distinct decode (UNTIL_DATE, to_date ('02/04/2017','MM/DD/YYYY'),'PASS','FAIL') as results from XXXXX where ID='XXXXXXXXX';
 
IF results='FAIL' then HF_result:='FAIL';
END IF;
 
select distinct decode (Count(*), 9,'PASS','FAIL') as results from XXXXX where id=XXXXXXXXXX;
 
IF results='FAIL' then HF_result:='FAIL';
END IF;
 
 
EXPECTED OUTPUT ::
 
select distinct decode (UNTIL_DATE, to_date ('02/04/2017','MM/DD/YYYY'),'PASS','FAIL') as results from XXXXX where ID='XXXXXXXXX';
 
IF results='FAIL' then HF_result:='FAIL';
END IF;
 
select distinct decode (Count(*), 9,'PASS','FAIL') as results from XXXXX where id=XXXXXXXXXX;
 
IF results='FAIL' then HF_result:='FAIL';
END IF;
 
IF HF_result='FAIL' then
RAISE ex_RedLight ;
END IF ;
 
HF_result:='PASS';
 
 


BC AdBot (Login to Remove)

 


#2 DeimosChaos

DeimosChaos

  • BC Advisor
  • 1,421 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:United States, Delaware
  • Local time:06:18 PM

Posted 22 June 2017 - 12:31 PM

Hi there nitinkpandit.

 

Can you give more detail on what you are trying to accomplish with this code? At least for me, I have no idea what you are doing and what you need it to do.

To make the code easier to read as well, use the code blocks button in the reply editor. Its the button with the '<>'.


OS - Ubuntu 14.04/16.04 & Windows 10
Custom Desktop PC / Lenovo Y580 / Sager NP8258 / Dell XPS 13 (9350)
_____________________________________________________
Bachelor of Science in Computing Security from Drexel University
Security +


#3 nitinkpandit

nitinkpandit
  • Topic Starter

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:04:48 AM

Posted 23 June 2017 - 02:47 AM

hi DeimosChaos,

 

I want to print select statements from files. However after last select statement from file, I want to print below bold statement. But currently it is not printing.

 

IF HF_result='FAIL' then
RAISE ex_RedLight ;
END IF ;
 
HF_result:='PASS';
 
I am trying to achieve here, I have PLSQL file and i have to create that select statments in proper format by manually and put it back in PL SQL file. And same file DBA will use to run from sqlplus.
 
Thanks for showing "Code <>" symbol. It is very useful. 
loop=1;
SEL_COUNT=2; [Count of select statements from file "sel_${HF}.file". I have multiple files].

## Printing Statement from original code ###

cat $ROOT_DIR/sel_${HF}.file | while read line ## while loop start
do
if [ ${loop} -lt ${SEL_COUNT} ]
then
echo "${line};";
echo "\nIF results='FAIL' then HF_result:='FAIL';";
echo "END IF;\n";
else
echo "${line};"
echo "\nIF results='FAIL' then HF_result:='FAIL';";
echo "END IF;\n";

echo "\n";
echo "IF HF_result='FAIL' then";
echo "RAISE ex_RedLight ;";
echo "END IF ;";

echo "\n";
echo "HF_result:='PASS';";
echo "\n--------------------------------------------------------------------------------";
fi
loop=`expr $loop+1`;
done ## while loop end


#4 DeimosChaos

DeimosChaos

  • BC Advisor
  • 1,421 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:United States, Delaware
  • Local time:06:18 PM

Posted 23 June 2017 - 10:37 AM

Okay.. so assuming the logic is correct, which I don't see anything that jumps out on that front.

 

Once your loop hits the end you should print the following:

echo "${line};"
echo "\nIF results='FAIL' then HF_result:='FAIL';";
echo "END IF;\n";
 
echo "\n";
echo "IF HF_result='FAIL' then";
echo "RAISE ex_RedLight ;";
echo "END IF ;";
 
echo "\n";
echo "HF_result:='PASS';";
echo "\n--------------------------------------------------------------------------------";

Is that correct? Does any of that print out at all?


OS - Ubuntu 14.04/16.04 & Windows 10
Custom Desktop PC / Lenovo Y580 / Sager NP8258 / Dell XPS 13 (9350)
_____________________________________________________
Bachelor of Science in Computing Security from Drexel University
Security +


#5 GoofProg

GoofProg

  • Banned
  • 224 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:04:18 PM

Posted 25 June 2017 - 05:19 PM

yeah.. all I see is blah blah BASH blah blah SQL blah blah blah.

It looks to complicated and you may have to walk through your code which is the other type of debugging when things are not right.



#6 nitinkpandit

nitinkpandit
  • Topic Starter

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:04:48 AM

Posted 25 June 2017 - 11:08 PM

Thanks a lot Deimos, it is working now.

 

I have figured it out, where exactly it went wrong.



#7 DeimosChaos

DeimosChaos

  • BC Advisor
  • 1,421 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:United States, Delaware
  • Local time:06:18 PM

Posted 26 June 2017 - 09:25 AM

Cool, glad you got it working!


OS - Ubuntu 14.04/16.04 & Windows 10
Custom Desktop PC / Lenovo Y580 / Sager NP8258 / Dell XPS 13 (9350)
_____________________________________________________
Bachelor of Science in Computing Security from Drexel University
Security +





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users