sybase-ase

Sybase: HAVING operates on rows?

假装没事ソ 提交于 2019-12-02 06:12:39
I've came across the following SYBASE SQL: -- Setup first create table #t (id int, ts int) go insert into #t values (1, 2) insert into #t values (1, 10) insert into #t values (1, 20) insert into #t values (1, 30) insert into #t values (2, 5) insert into #t values (2, 13) insert into #t values (2, 25) go declare @time int select @time=11 -- This is the SQL I am asking about select * from (select * from #t where ts <= @time) t group by id having ts = max(ts) go The results of this SQL are id ts ----------- ----------- 1 10 2 5 This looks like HAVING condition applied to rows rather than groups.

Sybase ASE 15 Aggregate Function for strings

蹲街弑〆低调 提交于 2019-12-02 05:41:56
问题 I'am findind a way to aggregate strings from differents rows into a single row in sybase ASE 15. Like this: id | Name Result: id | Names -- - ---- -- - ----- 1 | Matt 1 | Matt, Rocks 1 | Rocks 2 | Stylus 2 | Stylus Something like FOR XML PATH in T-SQL. Thanks! 回答1: Sybase ASE does not have any string aggregate functions like list() or group_concat() ; and while there is some support for FOR XML , it does not include support for the PATH option/feature. Assuming you could have an unknown

Discover primary / unique keys in Sybase ASE

我只是一个虾纸丫 提交于 2019-12-02 04:14:06
In Sybase ASE, I would like to discover all primary and unique keys. I want to do something similar to what is explained in this answer: Identifying Sybase tables, fields, keys, constraints But unfortunately, this doesn't work for me. Somehow the syskeys table does return any rows for my own keys, only for system table keys. What may I be doing wrong? Some missing grants? I have installed Sybase ASE 15.5 and I'm connecting with user dbo , login sa When you explicitly declare a key field - say in a CREATE TABLE statement - this doesn't populate the syskeys table. You would use (e.g.) sp

How Do I Generate Sybase BCP Fmt file?

我的未来我决定 提交于 2019-12-02 02:12:54
I have a huge database which I want to dump out using BCP and then load it up elsewhere. I have done quite a bit of research on the Sybase version of BCP (being more familiar with the MSSQL one) and I see how to USE an Import file but I can't figure out for the life of me how to create one. I am currently making my Sybase bcp out files of data like this: bcp mytester.dbo.XTABLE out XTABLE.bcp -U sa -P mypass -T -n and trying to import them back in like this: bcp mytester.dbo.XTABLE in XTABLE.bcp -E -n -S Sybase_157 -U sa -P SyAdmin Right now, the IN part gives me an error about IDENTITY_INSERT

MYSQL group_concat equivalent in Sybase ASE?

梦想与她 提交于 2019-12-02 01:23:00
问题 Is there a equivalent function in Sybase ASE to the group_concat of MYSQL? 回答1: No, you have to create a stored procedure. 回答2: Better yet create a cursor that processes one row at a time which could go into a stored procedure. The cursor query is assumed to sort the data via the order by clause and then concatenates the data via an expression like group_concat = group_concat + field. You have the power! Good SQL, good night. 回答3: This query will concat the rows in the "column_to_concat"

Sybase Sequence

落爺英雄遲暮 提交于 2019-12-02 00:49:15
问题 I am creating a sequence in sybase but getting mentioned exception, can anyone please help? CREATE OR REPLACE SEQUENCE dbo.event_id_sequence START WITH 100 INCREMENT BY 1 MINVALUE 100 NO MAXVALUE NO CACHE NO CYCLE go GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID maintenance GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID readonly GRANT USAGE ON SEQUENCE dbo.event_id_sequence TO userID reports go Exception: [Error] Script lines: 1-14 ------------------------- Incorrect syntax

MYSQL group_concat equivalent in Sybase ASE?

Deadly 提交于 2019-12-02 00:00:18
Is there a equivalent function in Sybase ASE to the group_concat of MYSQL? No, you have to create a stored procedure. Better yet create a cursor that processes one row at a time which could go into a stored procedure. The cursor query is assumed to sort the data via the order by clause and then concatenates the data via an expression like group_concat = group_concat + field. You have the power! Good SQL, good night. This query will concat the rows in the "column_to_concat" column, you can change the space separator character with commas, slash, etc. In this case i choose space because with

NullPointerException thrown by Charset.availableCharsets due to our Sybase JDBC driver

和自甴很熟 提交于 2019-12-01 23:27:47
问题 I am running into a blocking issue with my install (JDK 1.7). Basically I have the following NPE: 10:19:17.548 [main] ERROR o.s.t.w.s.TestDispatcherServlet - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org

NullPointerException thrown by Charset.availableCharsets due to our Sybase JDBC driver

坚强是说给别人听的谎言 提交于 2019-12-01 20:55:53
I am running into a blocking issue with my install (JDK 1.7). Basically I have the following NPE: 10:19:17.548 [main] ERROR o.s.t.w.s.TestDispatcherServlet - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter]: Constructor threw

Finding the n-th row in Sybase ASE?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 14:00:16
问题 I'm trying to find the n-th row in a sybase database. I'm more familiar with SQL server so I decided to use a with statement but for some reason that's not working in sybase. Could you guys please explain what's wrong with this code: With test AS ( select *, row_number() over (order by M_MAT) as 'row' from OM_MAT_DBF ) SELECT * FROM test WHERE row = 2 回答1: with and row_number() are not valid commands in Sybase ASE. One option is to select your data (or key data) into a temp table, then use