How do you catch a log suspend error in Sybase?

Sybase

You have two issues.

One is the UNIX/Linux script does not detect errors correctly.

Secondly the transaction log is filling up frequently.

First the script needs to have the standard output AND the error output go to your log file. When you use the > it is using file descriptor 1. When you want to capture error output you need to use 2> for file descriptor 2. So the command would look like the following.

isql    > error.log    2> error.log

Better yet, use this.

isql    2>&1    > error.log

The previous command says to have file descriptor 2 go to file descriptor 1 which goes to a log file.

Now to detect errors, look for “Msg” which all Sybase errors have in front by using the grep command.

stackoverflow

 

 

 

 

Secondly to resolve the transaction log space, you need to grow the size of the log which should be on its own device separate from data. Then you need to set the threshold to dump aka flush the completed transactions to a disk file automatically. You need to investigate the following commands to do this.

alter database, sp_helpthreshold, sp_addthreshold, sp_thresholdaction

Good SQL, good night.

Does Sybase support string types that it doesn’t right trim?

Yes.

Sybase

For char columns to be fixed length, you must use the not null attribute.

For variable length columns, use varchar or char with a null attribute.

Then to measure the real data size including trailing spaces use the datalength function not the len function nor the charlength function.

Good SQL, good night.

stackoverflow

Death to the Death Star

Recently a White House Petition at the “We The People” website received the required 25,000 signatures.  This particular petition asked for the government to build a Death Star by 2016 to boost job creation and bolster national defense.

deathstar

Because it received the required signatures, the White House had to respond. Thus Paul Shawcross, Chief of Science and Space at the White House Office of Management and Budget, formulated the following reply.

  • Financially
    • It costs $850,000,000,000,000,000
    • We need to reduce the budget not expand it.
  • Morally
    • The Administration does not support blowing up planets.
  • Practically
    • It is a flawed concept – can be exploited by a one-man starship.

Evidently the answer is no.  Maybe the next Administration will be more lenient.

Sybase Functionality

QUESTION:

Does anybody know if Common Table Expressions and User-defined functions (not from Java) are supported in Sybase?

ANSWER:

Microsoft SQL Server is based on Sybase 7.0. Sybase may not have Common Table Expressions (CTE) and User-Defined Functions, but there are equivalent ways to do the same thing.

For example CTE can be done either in nested queries or via temp tables using a number sign (#) in front of the table name.

For User Defined Functions, create a stored procedure with simple SQL code and call it via the exec function for example “exec my_sql_code”. This allows nesting of stored procedures.

Good SQL, good night.

NOTE TO BANKS – A Prepaid Gift Card is NOT A Debit Card

Several times I have received a gift card or a prepaid card that clearly says “DEBIT CARD” on the card above the VISA or MasterCard logo.  But NOOOO…..

giftcard

When I go to use it I have to say it is a Credit Card because it does not have a pin number.

Why don’t the banks put the following on the card?

PREPAID CARD (use like Credit Card)

You would think the banks making billions of dollars a year could figure this out.

January Caption Contest Entry

2013_01_caption

SCOTTY, BEAM US UP!