DBMS_OUTPUT.PUT_LINE doesn't print values in shell script
Hello,
I'm trying to print the value of my cursor in the dbms_output.put_line in shell script, but it only shows "PL/SQL procedure successfully completed." nothing else. I have set serveroutput on,
Below is my script : Any advise would be really helpful.
Regards,
Chiranjit
--- Post updated at 12:34 PM ---
I have now able to print the values, however it is only printing the first value where i am selecting first 20 rows in the cursor.
Is there a way to print all the values ?
Thanks,
Chiranjit
Last edited by mail.chiranjit; 09-18-2019 at 02:39 AM..
I have the following crontab entry to run a shell script for every 30 minutes of every day:
30 * * * * $HOME/main.sh > $HOME/main.log 2>$HOME/error.log
after I created the crontab file I have also done:
$crontab my_crontab
I also check to make sure it exists, by using the following... (11 Replies)
Hi,
I have created a pl/sql block utilises dbms_output.put_line. This script works fine when I call from sqlplus ie sqlplus @./scriptname but when I embed it within my shell script I get no output to screen so I end up with an empty spool file. I know it's executing successfully when called from... (6 Replies)
Dear All,
As I'm new here, please forgive me if any rule violation occurred.
I have a script like this:
#! /bin/ksh
# Author : Saptarshi
# Date : 18-Mar-2011
# Version : 1.0
Return_op=`sqlplus -s <<ENDOFSQL
db_user/db_pass@db_nm
WHENEVER SQLERROR EXIT 1
set ... (1 Reply)
Hi All,
I Have written a script through that i am calling sql file
Sqlfile.sql
set time on
set timing on
set echo on
set head off
set scan on
set feedback on
set serveroutput on
set linesize 1000
DECLARE
v_acc_no NUMBER(10);
v_product_no NUMBER(10);
BEGIN... (3 Replies)
Hi,
I need a shell script, which would search the result values from another files.
1)execute " select column1 from table_name" query on the table.
2)Based on the result, need to be grep from .wft files.
could please explain about this.Below is the way i am using.
#!/bin/sh... (4 Replies)
Hi Gurus,
I have below sample script. I expect it print error when running script without input parameter. but the it doesn't.
would you please help me about this issue.
thanks in advance.
/script$cat test.ksh
#!/bin/ksh
while getopts :f: arg
do
case $arg in
... (4 Replies)
hi guys, i want help... Reding XML file and print the values into the text file using linux shell script file as per below xml file
<sequence>
<Filename>aldorzum.doc</Filename>
<DivisionCode>US</DivisionCode>
<ContentType>Template</ContentType>
<ProductCode>VIMZIM</ProductCode>
</sequence>... (1 Reply)
Hello,
I have a simple shell script, which starts from crontab like this:
00 03 * * 2-6 /export/applications/dte/sh/fwmarg.sh > /export/applications/dte/data/cron_log/fwmarg.cronlog.`date +\%m.\%d` 2>&1
The script doesn't get any argument. But inside it I see the line
... (10 Replies)
Discussion started by: digioleg54
10 Replies
LEARN ABOUT REDHAT
declare
DECLARE(7) SQL Commands DECLARE(7)NAME
DECLARE - define a cursor
SYNOPSIS
DECLARE cursorname [ BINARY ] [ INSENSITIVE ] [ SCROLL ]
CURSOR FOR query
[ FOR { READ ONLY | UPDATE [ OF column [, ...] ] ]
INPUTS
cursorname
The name of the cursor to be used in subsequent FETCH operations.
BINARY Causes the cursor to fetch data in binary rather than in text format.
INSENSITIVE
SQL92 keyword indicating that data retrieved from the cursor should be unaffected by updates from other processes or cursors. Since
cursor operations occur within transactions in PostgreSQL this is always the case. This keyword has no effect.
SCROLL SQL92 keyword indicating that data may be retrieved in multiple rows per FETCH operation. Since this is allowed at all times by
PostgreSQL this keyword has no effect.
query An SQL query which will provide the rows to be governed by the cursor. Refer to the SELECT statement for further information about
valid arguments.
READ ONLY
SQL92 keyword indicating that the cursor will be used in a read only mode. Since this is the only cursor access mode available in
PostgreSQL this keyword has no effect.
UPDATE SQL92 keyword indicating that the cursor will be used to update tables. Since cursor updates are not currently supported in Post-
greSQL this keyword provokes an informational error message.
column Column(s) to be updated. Since cursor updates are not currently supported in PostgreSQL the UPDATE clause provokes an informational
error message.
OUTPUTS
DECLARE CURSOR
The message returned if the SELECT is run successfully.
WARNING: Closing pre-existing portal "cursorname"
This message is reported if the same cursor name was already declared in the current transaction block. The previous definition is
discarded.
ERROR: DECLARE CURSOR may only be used in begin/end transaction blocks
This error occurs if the cursor is not declared within a transaction block.
DESCRIPTION
DECLARE allows a user to create cursors, which can be used to retrieve a small number of rows at a time out of a larger query. Cursors can
return data either in text or in binary format using FETCH [fetch(7)].
Normal cursors return data in text format, either ASCII or another encoding scheme depending on how the PostgreSQL backend was built. Since
data is stored natively in binary format, the system must do a conversion to produce the text format. In addition, text formats are often
larger in size than the corresponding binary format. Once the information comes back in text form, the client application may need to con-
vert it to a binary format to manipulate it. BINARY cursors give you back the data in the native binary representation.
As an example, if a query returns a value of one from an integer column, you would get a string of 1 with a default cursor whereas with a
binary cursor you would get a 4-byte value equal to control-A (^A).
BINARY cursors should be used carefully. User applications such as psql are not aware of binary cursors and expect data to come back in a
text format.
String representation is architecture-neutral whereas binary representation can differ between different machine architectures. PostgreSQL
does not resolve byte ordering or representation issues for binary cursors. Therefore, if your client machine and server machine use dif-
ferent representations (e.g., ``big-endian'' versus ``little-endian''), you will probably not want your data returned in binary format.
However, binary cursors may be a little more efficient since there is less conversion overhead in the server to client data transfer.
Tip: If you intend to display the data in ASCII, getting it back in ASCII will save you some effort on the client side.
NOTES
Cursors are only available in transactions. Use to BEGIN [begin(7)], COMMIT [commit(7)] and ROLLBACK [rollback(7)] to define a transaction
block.
In SQL92 cursors are only available in embedded SQL (ESQL) applications. The PostgreSQL backend does not implement an explicit OPEN cursor
statement; a cursor is considered to be open when it is declared. However, ecpg, the embedded SQL preprocessor for PostgreSQL, supports
the SQL92 cursor conventions, including those involving DECLARE and OPEN statements.
USAGE
To declare a cursor:
DECLARE liahona CURSOR
FOR SELECT * FROM films;
COMPATIBILITY
SQL92
SQL92 allows cursors only in embedded SQL and in modules. PostgreSQL permits cursors to be used interactively. SQL92 allows embedded or
modular cursors to update database information. All PostgreSQL cursors are read only. The BINARY keyword is a PostgreSQL extension.
SQL - Language Statements 2002-11-22 DECLARE(7)