Sponsored Content
Top Forums Shell Programming and Scripting Need to capture error of sybase isql in unix Post 302587059 by aksar on Wednesday 4th of January 2012 08:21:19 PM
Old 01-04-2012
Need to capture error of sybase isql in unix

Hi Gurus,

I am very new in Unix,
I have 1 script, in which I am truncating the table , then BCP the data in Sybase table, and then loading the data from sybase table to sybase table.

every thing is working fine, but the problem is with Error.

I made some hanges in my insert statement so that it failed , but I am not getting any error msg. I dont know how to put error msg.

pls help me out.
Code:
retu_statu=`$SYBASE/OCS-15_0/bin/isql -S$DSQUERY -U$AAAUSER -P$AAAUSERPWD <<-END_SQL | grep "ERRORLEVEL" | cut -d ";" -f 2 
use $AAAREPDB
truncate table $AAAREPDB..CTF_EXTRACT_PTF
go
END_SQL`

bcp $AAAREPDB..CTF_EXTRACT_PTF in /oams/w_ctcb/ctcb2ta/data_extract/${BatchScript}.$$.out -U$AAAUSERPWD -P$AAAUSERPWD -S$DSQUERY -f portfolio.fmt -Y -F

    
err_code=$?
    if [[ $err_code != 0 ]]; then
        echo "ERROR: Data Loading failed!!!\n\n\n"
        exit 255
    fi

retu_statu=`$SYBASE/OCS-15_0/bin/isql -S$DSQUERY -U$USER -P$USERPWD <<-END_SQL | grep "ERRORLEVEL" | cut -d ";" -f 2 
use $AAAREPDB

insert into $REPDB..uob_dwh_portfolio
select *,getdate) from $REPDB..CTF_EXTRACT_PTF

select 'ERRORLEVEL',';',@@error,';'
go


END_SQL`

I am not getting any error Problem in query is Getdate()
It should give me error

---------- Post updated 01-05-12 at 09:21 AM ---------- Previous update was 01-04-12 at 05:06 PM ----------

any sollution

Last edited by zaxxon; 01-04-2012 at 05:08 AM.. Reason: "awaiting your replies" is similar as "urgent". removed that - I guess you don't want to post it again and again.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to connect to sybase from Unix(AIX)

I have a script given below so can anyone explain me what it does? echo "use $DSQUERY\n go\n insert into ff.SmartCareLogin (username, password, userrole, fullname) values ('$1', '$1', '$2', '$3') go"|isql -Uff -P what is the use of $DSQUERY and go. When i am firiing isql command... (0 Replies)
Discussion started by: sachin.gangadha
0 Replies

2. Shell Programming and Scripting

Isql query in unix shell

Hi i want write a script for list of sysbase are having access or open. then i wrote like: USER="abc" PASS="xyz" SERVER="SCCS" DB="blue" WORK_DIR="/usr/home/ramakrishna" set -x isql -U${USER} -P${PASS} -S${SERVER}<<EOF>$WORK_DIR/output.log go use blue (database name) go use... (0 Replies)
Discussion started by: koti_rama
0 Replies

3. Shell Programming and Scripting

unix capture oracle function error

Hi, I want to execute an oracle function from unix script so for that I created a sample oracle function as below: create or replace function test_fn(test_date out varchar2) RETURN varchar2 IS BEGIN select to_char(sysdate,'DD-MON-YY') into test_date from dual; return test_date;... (5 Replies)
Discussion started by: dips_ag
5 Replies

4. Shell Programming and Scripting

How do i access sybase using isql and how do i get result set in perl script?

Hi, How do i get result set in perl script using isql while connecting sybase server. I have a perl script which connected to sybase and get the result set. but i wanted to get the result set. How do i get the result set in perl script not unix shell script.. $server ="ServerName"; open... (1 Reply)
Discussion started by: solo123
1 Replies

5. Shell Programming and Scripting

Need to capture error of sybase sql in unix

Hi Gurus, I am very new in Unix, I have 1 script, in which I am truncating the table , then BCP the data in Sybase table, and then loading the data from sybase table to sybase table. every thing is working fine, but the problem is with Error. I made some hanges in my insert statement so... (1 Reply)
Discussion started by: aksar
1 Replies

6. Shell Programming and Scripting

Sybase isql writing spaces to file

I'm running isql in sybase on a Linux box to read a table, and write the contents to a file. It needs to be a nice comma delimited file for input into another system. It reads the DB fine and writes the file. However, I have two issues. 1) I don't want the line width to be limited in any... (2 Replies)
Discussion started by: Cynthia
2 Replies

7. Shell Programming and Scripting

How to assign value from isql to UNIX variable

I want output to be assigned to UNIX variables echo "Enter RRS ID: " read rrs isql -SPROD_DDS -USYBUSER -PSYBPASS -b -osfg.out << EOF use sip go set nocount on select issuerId, legalStructTxt, productName, issuerName from sf_product where rrsId = $rrs go EOF (1 Reply)
Discussion started by: JayDoshi
1 Replies

8. Shell Programming and Scripting

Error in Sybase connectivity via UNIX

Helo Experts, I have an issue in connecting to sybase from UNIX. PFB, my code : #!/bin/ksh ############################################################################### # # Filename: docflo_split.sh # # Description:docflo_split.sh WrapperScript splits the temporary file... (1 Reply)
Discussion started by: Nits
1 Replies

9. Shell Programming and Scripting

Isql syntax error in UNIX script

Hello Everyone, Coming again for your help to solve the below error: In a script, i had created a temp table (Temp_table) and loaded the data in it using bcp command (performed successfully) and I wanted to move it to the preferred table (called Main_table) for further use. hence I have added... (1 Reply)
Discussion started by: Suresh
1 Replies

10. UNIX for Advanced & Expert Users

Isql and If Exist syntax error in UNIX script

Hello Everyone, Coming again for your help to solve the below error: In a script, i had created a temp table (Temp_table) and loaded the data in it using bcp command (performed successfully) and I wanted to move it to the preferred table (called Main_table) for further use. hence I have added... (7 Replies)
Discussion started by: Suresh
7 Replies
DBIx::Class::Storage::DBI::Sybase::ASE(3)		User Contributed Perl Documentation		 DBIx::Class::Storage::DBI::Sybase::ASE(3)

NAME
DBIx::Class::Storage::DBI::Sybase::ASE - Sybase ASE SQL Server support for DBIx::Class SYNOPSIS
This subclass supports DBD::Sybase for real (non-Microsoft) Sybase databases. DESCRIPTION
If your version of Sybase does not support placeholders, then your storage will be reblessed to DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars. You can also enable that driver explicitly, see the documentation for more details. With this driver there is unfortunately no way to get the "last_insert_id" without doing a "SELECT MAX(col)". This is done safely in a transaction (locking the table.) See "INSERTS WITH PLACEHOLDERS". A recommended connect_info setting: on_connect_call => [['datetime_setup'], ['blob_setup', log_on_update => 0]] METHODS
connect_call_blob_setup Used as: on_connect_call => [ [ 'blob_setup', log_on_update => 0 ] ] Does "$dbh->{syb_binary_images} = 1;" to return "IMAGE" data as raw binary instead of as a hex string. Recommended. Also sets the "log_on_update" value for blob write operations. The default is 1, but 0 is better if your database is configured for it. See "Handling_IMAGE/TEXT_data_with_syb_ct_get_data()/syb_ct_send_data()" in DBD::Sybase. connect_call_datetime_setup Used as: on_connect_call => 'datetime_setup' In connect_info to set: $dbh->syb_date_fmt('ISO_strict'); # output fmt: 2004-08-21T14:36:48.080Z $dbh->do('set dateformat mdy'); # input fmt: 08/13/1979 18:08:55.080 This works for both "DATETIME" and "SMALLDATETIME" columns, note that "SMALLDATETIME" columns only have minute precision. Schema::Loader Support As of version 0.05000, DBIx::Class::Schema::Loader should work well with most versions of Sybase ASE. FreeTDS This driver supports DBD::Sybase compiled against FreeTDS (<http://www.freetds.org/>) to the best of our ability, however it is recommended that you recompile DBD::Sybase against the Sybase Open Client libraries. They are a part of the Sybase ASE distribution: The Open Client FAQ is here: <http://www.isug.com/Sybase_FAQ/ASE/section7.html>. Sybase ASE for Linux (which comes with the Open Client libraries) may be downloaded here: <http://response.sybase.com/forms/ASE_Linux_Download>. To see if you're using FreeTDS run: perl -MDBI -le 'my $dbh = DBI->connect($dsn, $user, $pass); print $dbh->{syb_oc_version}' It is recommended to set "tds version" for your ASE server to 5.0 in "/etc/freetds/freetds.conf". Some versions or configurations of the libraries involved will not support placeholders, in which case the storage will be reblessed to DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars. In some configurations, placeholders will work but will throw implicit type conversion errors for anything that's not expecting a string. In such a case, the "auto_cast" option from DBIx::Class::Storage::DBI::AutoCast is automatically set, which you may enable on connection with connect_call_set_auto_cast. The type info for the "CAST"s is taken from the "data_type" in DBIx::Class::ResultSource definitions in your Result classes, and are mapped to a Sybase type (if it isn't already) using a mapping based on SQL::Translator. In other configurations, placeholders will work just as they do with the Sybase Open Client libraries. Inserts or updates of TEXT/IMAGE columns will NOT work with FreeTDS. INSERTS WITH PLACEHOLDERS
With placeholders enabled, inserts are done in a transaction so that there are no concurrency issues with getting the inserted identity value using "SELECT MAX(col)", which is the only way to get the "IDENTITY" value in this mode. In addition, they are done on a separate connection so that it's possible to have active cursors when doing an insert. When using "DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars" transactions are unnecessary and not used, as there are no concurrency issues with "SELECT @@IDENTITY" which is a session variable. TRANSACTIONS
Due to limitations of the TDS protocol and DBD::Sybase, you cannot begin a transaction while there are active cursors, nor can you use multiple active cursors within a transaction. An active cursor is, for example, a ResultSet that has been executed using "next" or "first" but has not been exhausted or reset. For example, this will not work: $schema->txn_do(sub { my $rs = $schema->resultset('Book'); while (my $row = $rs->next) { $schema->resultset('MetaData')->create({ book_id => $row->id, ... }); } }); This won't either: my $first_row = $large_rs->first; $schema->txn_do(sub { ... }); Transactions done for inserts in "AutoCommit" mode when placeholders are in use are not affected, as they are done on an extra database handle. Some workarounds: o use DBIx::Class::Storage::DBI::Replicated o connect another Schema o load the data from your cursor with "all" in DBIx::Class::ResultSet MAXIMUM CONNECTIONS
The TDS protocol makes separate connections to the server for active statements in the background. By default the number of such connections is limited to 25, on both the client side and the server side. This is a bit too low for a complex DBIx::Class application, so on connection the client side setting is set to 256 (see "maxConnect" in DBD::Sybase.) You can override it to whatever setting you like in the DSN. See <http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.sag1/html/sag1/sag1272.htm> for information on changing the setting on the server side. DATES
See "connect_call_datetime_setup" to setup date formats for DBIx::Class::InflateColumn::DateTime. LIMITED QUERIES
Because ASE does not have a good way to limit results in SQL that works for all types of queries, the limit dialect is set to GenericSubQ. Fortunately, ASE and DBD::Sybase support cursors properly, so when GenericSubQ is too slow you can use the software_limit DBIx::Class::ResultSet attribute to simulate limited queries by skipping over records. TEXT
/IMAGE COLUMNS DBD::Sybase compiled with FreeTDS will NOT allow you to insert or update "TEXT/IMAGE" columns. Setting "$dbh->{LongReadLen}" will also not work with FreeTDS use either: $schema->storage->dbh->do("SET TEXTSIZE $bytes"); or $schema->storage->set_textsize($bytes); instead. However, the "LongReadLen" you pass in connect_info is used to execute the equivalent "SET TEXTSIZE" command on connection. See "connect_call_blob_setup" for a connect_info setting you need to work with "IMAGE" columns. BULK API
The experimental DBD::Sybase Bulk API support is used for populate in void context, in a transaction on a separate connection. To use this feature effectively, use a large number of rows for each populate call, eg.: while (my $rows = $data_source->get_100_rows()) { $rs->populate($rows); } NOTE: the add_columns calls in your "Result" classes must list columns in database order for this to work. Also, you may have to unset the "LANG" environment variable before loading your app, as "BCP -Y" is not yet supported in DBD::Sybase . When inserting IMAGE columns using this method, you'll need to use "connect_call_blob_setup" as well. COMPUTED COLUMNS
If you have columns such as: created_dtm AS getdate() represent them in your Result classes as: created_dtm => { data_type => undef, default_value => 'getdate()', is_nullable => 0, inflate_datetime => 1, } The "data_type" must exist and must be "undef". Then empty inserts will work on tables with such columns. TIMESTAMP COLUMNS
"timestamp" columns in Sybase ASE are not really timestamps, see: http://dba.fyicenter.com/Interview-Questions/SYBASE/The_timestamp_datatype_in_Sybase_.html <http://dba.fyicenter.com/Interview- Questions/SYBASE/The_timestamp_datatype_in_Sybase_.html>. They should be defined in your Result classes as: ts => { data_type => 'timestamp', is_nullable => 0, inflate_datetime => 0, } The "<inflate_datetime =" 0>> is necessary if you use DBIx::Class::InflateColumn::DateTime, and most people do, and still want to be able to read these values. The values will come back as hexadecimal. TODO
o Transitions to AutoCommit=0 (starting a transaction) mode by exhausting any active cursors, using eager cursors. o Real limits and limited counts using stored procedures deployed on startup. o Blob update with a LIKE query on a blob, without invalidating the WHERE condition. o bulk_insert using prepare_cached (see comments.) AUTHOR
See "AUTHOR" in DBIx::Class and "CONTRIBUTORS" in DBIx::Class. LICENSE
You may distribute this code under the same terms as Perl itself. perl v5.16.2 2012-08-23 DBIx::Class::Storage::DBI::Sybase::ASE(3)
All times are GMT -4. The time now is 10:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy