sybase

Sybase: trying to lock a record on select so another caller does not get the same one

喜你入骨 提交于 2019-12-04 19:15:50
I have a simple table in Sybase, let's say it looks as follows: CREATE TABLE T ( name VARCHAR(10), entry_date datetime, in_use CHAR(1) ) I want to get the next entry based on order of "entry_date" and immediately update "in_use" to "Y" to indicate that the record is not available to the next query that comes in. The kicker is that if two execution paths try to run the query at the same time I want the second one to block so it does not grab the same record. The problem is I've found that you cannot do "SELECT FOR UPDATE" in Sybase if you have an ORDER BY clause, so the following stored proc

Sybase sp_who truncates hostname

倖福魔咒の 提交于 2019-12-04 13:32:28
I am connecting to sql databse using Rapid SQL or isql provided by sybase server. When I issue sp_who username command I should get list of connected users. I do but hostname column is truncated so for example when host address is host0001 it get truncated to host0 this is a problem because there are many hosts which names start with same prefix e.g. host001, host002.... Because of that I do not know which processes are blocking my database and I can not log to the machine and kill those processes. I do not have privileges to kill them from database isql console. I have to log to machine and

SQL Parent/Child recursive call or union?

♀尐吖头ヾ 提交于 2019-12-04 12:25:13
问题 I can't seem to find a relevant example out there. I'm trying to return a sub-set of a table, and for each row in that table, I want to check how many children it has, and return that number as part of the result set. Parent Table Columns: PK_ID, Column1, Column2, FK1 For each FK1 in result set, select count(*) from child_table. Final result set 3, col1text, col2text, 1(child) 5, col1texta, col2texta, 2(child) 6, col1textb, col2textb, 0(child) 9, col1textc, col2textc, 4(child) I'm struggling

What is the best way to connect to a sybase database from python?

試著忘記壹切 提交于 2019-12-04 06:58:38
I am trying to retrieve data in a sybase data base from python and I was wondering which would be the best way to do it. I found this module but may be you have some other suggestions: http://python-sybase.sourceforge.net/ Thanks The sybase module you linked is by far the easiest way. You can get data like so: import Sybase db = Sybase.connect('server','name','pass','database') c = db.cursor() c.execute("sql statement") list1 = c.fetchall() print list1 You will have to use something like freetds to setup the interfaces for sybase, however. you can also connect through ODBC . There is also

SQL Union to NHibernate Criteria

可紊 提交于 2019-12-04 06:47:15
There's a way to convert this SQL statement to a NHibernate Criteria? (select b1.FieldA as Name, b1.FieldA as FullName from Sale b1 where b1.FieldA like '%john%' or b1.FieldA like '%john%' order by b1.Id desc) union (select b2.FieldC as Name, b2.FieldD as FullName from Sale b2 where b2.FieldC like '%john%' or b2.FieldD like '%john%' order by b2.Id desc) union (select c.FieldE as Name, c.FieldF as FullName from Client c where c.FieldE like '%john%' or c.FieldF like '%john%' order by c.Id desc) I've found that NHibernate doesn't support Unions. Try using a view. It can be mapped directly in

Answers to the mysterious Sybase ASE 'timestamp' datatype questions

让人想犯罪 __ 提交于 2019-12-04 05:19:45
Eric Johnson ask the following questions in Aug 2010. "What is the mysterious 'timestamp' datatype in Sybase? What the heck is a timestamp? Does it have any relation at all to time or date? Can I convert it to a datetime? If its not a time or a date, what do you use it for?" I attempted to answer the above post but this site would not accept a new answer due to the age of the original post. As the subject matter remains a FAQ amongst SAP/Sybase ASE professional, I have decided to re-post the original questions above and give hopefully some clear answers below. Answer to Q#1 : 'What the heck is

How to escape single quotes in Sybase

╄→尐↘猪︶ㄣ 提交于 2019-12-03 23:35:08
I come from MySQL and the below query doesn't work in Sybase. How should I escape single quotes? UPDATE Animals SET NAME = 'Dog\'s friends' WHERE uid = 12 If working with Sybase, having got used to MySQL which more database users have experience you may soon discover you are unable to escape single quotes with backslash in. So how do you escape quotes in Sybase? In fact, in Sybase SQL the single quote acts as the escape character. See below for an example UPDATE statement in both “languages”: MySQL UPDATE Animals SET NAME = 'Dog\'s friends' WHERE uid = 12 Sybase UPDATE Animals SET NAME = 'Dog'

sybase数据库中时间类型转换以及比较

≯℡__Kan透↙ 提交于 2019-12-03 23:19:10
一. 时间转换 Sybase 时间处理Convert 的使用 1. 怎样将datetime类型的日期转换为yyyy-mm-dd格式 SELECT STR_REPLACE(CONVERT(VARCHAR, GETDATE(), 111) ,'/','-'); 2. DateTime转换成Varchar样式 语句及查询结果: Select CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM Select CONVERT(varchar(100), GETDATE(), 1): 05/16/06 Select CONVERT(varchar(100), GETDATE(), 2): 06.05.16 Select CONVERT(varchar(100), GETDATE(), 3): 16/05/06 Select CONVERT(varchar(100), GETDATE(), 4): 16.05.06 Select CONVERT(varchar(100), GETDATE(), 5): 16-05-06 Select CONVERT(varchar(100), GETDATE(), 6): 16 05 06 Select CONVERT(varchar(100), GETDATE(), 7): 05 16, 06

JRruby, Sybase JDBC and DBI - fetching column name with the AS clause issue

久未见 提交于 2019-12-03 21:53:18
I have a ruby script which I run using the JRuby Interpreter. The script connects to a Sybase database using DBI and Sybase JDBC (jTDS3.jar and jconn3.jar) My problem is that I have a select query that alters the column names of table. For example: SELECT t.TRANSACTION as 'business_transaction', t.TRADE_CURRENCY as 'currency', t.CURRENCY as 'settlement_currency' ...etc... FROM TRADE t ...etc... My problem is when using the examples directly from the documentation sth = dbh.execute(stmt) printf "Number of rows: %d\n", rows.size printf "Number of columns: %d\n", sth.column_names.size sth.column

Loading 26MB text data from database consume JVM heap of 258MB

别等时光非礼了梦想. 提交于 2019-12-03 17:36:48
An app (Spring, JPA Hibernate, Sybase 12, Webapp) when run locally on startup consumes 40MB of the 256MB heap space based on VisualVM. When I trigger a search that returns 70,000+ rows (text data no blobs) the heap space graph shoots up to 256MB and throws out of memory. I have resolved this by using setMaxResults(limit). However, when I queried the same data, copy-pasted to a text file and saved to the filesystem, I can see that the size is only 26MB worth of text. So in effect, 216MB(from 256-40) is consumed by loading a 26MB amount of text from the databases, who is consuming the 190MB by