DBMS_OUTPUT.PUT_LINE doesn't print with output and pooling turned on - toad

DBMS_OUTPUT.PUT_LINE( ) doesn't print output however output and spooling are turned on. "Procedure is completed successfully" message is displayed without any output. When run in SQLPLUS it throws errors.
Do you have any idea to check? I tried the DBMS_OUTPUT.ENABLE() etc.

Make sure you "execute as a script" by pressing F5. Make sure the editor window has this line before calling your procedure:
set serveroutput on size unlimited;
Here is an example calling a homegrown function that returns an element from a list (in this case the 6th element, "mirror") where the delimiter is a space. Note you can view output on the "DBMS Output" tab too (click the "turn output on" button first).
Click on the image to view full size

i found this little tricky button in jetBrains Datagrip, it turns on dbms_output without any dbms_output.enable or set serveron etc.

Related

Indentation after for instruction in xcode doesn't work

I've been using xcode for some months and this has never happened before, i'm not sure whether i pressed something i shouldn't have or meddled with the settings. Basically i write something like for(int i=1;i<=n;i++) and press enter, and the cursor is on the next line above the instruction, so there's no visual subordination of what I'm about to write next.
If i press the tab key before writing a new instruction below and then write for instance cout<<n-i<<endl;, the moment I press ; , the entire thing is moved in the same column(if that makes sense) again. This doesn't happen with other instructions like while or if. Help?
Normally indentation occurs when you open a block, as in type {. If you're using a blockless if then the code editor has to figure out after the fact what you're doing.
I'm not able to reproduce your problem, but here are a few tips :
To format a selection in the editor
Main menu : Editor > Structure > Re-indent ( or ^I )
To remove the automatic formatting when pressing ;
User Preferences : Text Editing > Automatic indent for : Uncheck the “;” box

Displaying large output on terminal window

int a[10000];
for(int i=0;i<10000;i++)
{
a[i]=i; cout<<a[i]<<endl;
}
Suppose this is the code and on the terminal screen I need all outputs (0-9999) But it only displays (9704-9999) at the end
I want to see all the numbers on the terminal window but it removes the upper part of the data. I guess I have to change some settings.
Increase the console buffering. Depending on which terminal you're using it'll be different. For example on Windows conhost.exe is the default console used by cmd and PowerShell. Just click the icon on the top left > Properties > Layout and set Screen Buffer Size to a large enough number
But the better solution would be redirecting to file, because no one wants to read 10000 lines on the console, and there's no guarantee that the console will have a buffer of infinite length or length of more than 10000 lines. conhost for example only supports maximum 9999 lines so you'll miss at least the command you typed and the first output line. Besides that'll often remove other commands' output from the history which is undesirable
Either do that from the command line with the redirection operator >
yourapp.exe >output.txt
or save to file directly from your code

Programmatically expand terminal to a specific size

In my output there are certain lines that are refreshed every few seconds. If I resize the terminal by clicking F11, then output is just as I wanted. If terminal isn't big enough some long lines that are refreshed are splitted in two, and because of that, only one part of line is refreshed, and every time line is refreshed I also get new line.
This could be easily avoided if I could specify default size of terminal (resize terminal from my program). Also it would be great if I could forbid user to change terminal size while program is running.
while(1)
{
cout<<"Long line that is refreshed every 5s... \r";
//if line is splited in two lines, \r will return to beginning of that new line
//and the first part of original line would stay as it is(won't be rewrited)
sleep(5);
}
How do I specify a terminal size or stop terminal resizing?
Some terminal emulators (including the default macOS Terminal.app) support being resized/moved/etc in response to printed control sequences. The sequences are fairly standard but not all terminal emulators implement all of them.
For example:
# set terminal width to 50, height to 100
cout << "\e[8;50;100t";
This answer includes an overview of some other available control sequences.
I don't think you can forbid the user to change the terminal size. A better way would be to catch the SIGWINCH signal that is sent to the process everytime the window size is changed, and use the TIOCGWINSZ / TIOCGSIZE ioctl() to get the dimensions.

How to view values of variables in KDevelop?

I am using KDevelop as IDE for my C++ program. I have an array char buffer[1024] in my program. After reading data to buffer, I would like to check it manually. But in the left panel, I need to read the array character by character. Is there some way by which I can get the content of the array at a stretch?
Use GDB tool view available in KDevelop. In KDevelop 4.6, Window->Add ToolView->GDB will open the GDB tool view at the bottom/left/right of KDevelop IDE. Debug your program and at the point at which you have to check value of the variable, enter print variable_name in the textbox corresponding to GDB cmd. The value of variable will be printed.
Some example commands:
Show an array (will show first 200 elements by default):
(gdb) print buffer
print buffer
$1 = "\000\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !\"#$%&'()*+,-./0123456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307"...
Show an array range buffer[index]#count:
(gdb) print buffer[50]#40
print buffer[50]#40
$2 = "23456789:;<=>?#ABCDEFGHIJKLMNOPQRSTUVWXY"
There's the Variables tool view.
Show it by right clicking left, right or bottom border of KDevelop's window and click Variables

How to read text from an application window using pywinauto

I have a python code which opens a SSH session using Putty and passes a command to reboot a remote machine using pywinauto.
I want to read the text from the putty terminal after typing the password and compare it
Is there a way I can do it?
Below is the piece of code for the same
app_Putty = application.Application()
app_Putty.start_("C:\Users\debajyoti.bose\Downloads\putty.exe")
app_Putty.top_window_().TypeKeys(IP)
app_Putty.top_window_().TypeKeys("{TAB}"+"22")
app_Putty.top_window_().RadioButton4.Click()
app_Putty.top_window_().OpenButton.Click()
time.sleep(10)
app_Putty.top_window_().NoButton.Click()
time.sleep(2)
app_Putty.top_window_().TypeKeys(user+"{ENTER}")
time.sleep(3)
app_Putty.top_window_().TypeKeys(password+"{ENTER}")
time.sleep(3)
app_Putty.top_window_().TypeKeys("/bin/reboot"+"{ENTER}")
time.sleep(5)
app_Putty.kill_()
time.sleep(120)
I am using pywinauto v0.4.0
Thanks in advance.
OK, let's try app_Putty.top_window_().WindowText(). If it fails your mission looks impossible.
You can't capture directly like this from what I can tell, but I had to find a workaround, and the one I found was this
#clear the buffer with alt space menu
app.window(title='PuTTY - Title').type_keys('% l',with_spaces=True)
#copy the buffer to clipboard
app.window(title='PuTTY - Title').type_keys('% o',with_spaces=True)
I was having to do this because the putty.log file was missing the selection indicator icon (asterisk) on the screen when it was logging output and I needed a way to know which item was selected to move up or down.