sybase

How to only create table if it doesn't exist? Using “object_id('table') IS NULL” doesn't work?

爷,独闯天下 提交于 2019-12-10 15:54:47
问题 I would like to check if the table does not exist, then create one, otherwise, insert data into it. use tempdb if object_id('guest.my_tmpTable') IS NULL begin CREATE TABLE guest.my_tmpTable ( id int, col1 varchar(100) ) end --- do insert here ... The first time run, the table was created but the 2nd run the sybase complains the table already exist. Thanks! 回答1: The reason is that the entire statement - if and its "true" part are compiled as one. If the table exists during compilation - error.

How to connect Sybase database using Java code in NetBeans?

女生的网名这么多〃 提交于 2019-12-10 13:49:29
问题 I want to connect remote Sybase from my Java code written in NetBeans . So far I have prepared a code as below: public static void connect() { String host = "192.168.150.11"; String url = "jdbc:sybase:Tds:"+host+":4100"; String username = "sa"; String password =""; SybDriver sybDriver = null; Connection conn; try { sybDriver=(SybDriver)Class.forName("com.sybase.jdbc3.jdbc.SybDriver").newInstance(); System.out.println("Driver Loaded"); conn = DriverManager.getConnection(url,username,password);

Java - Hibernate Exception - Feedback cannot be mapped [ from Feedback ]

时光毁灭记忆、已成空白 提交于 2019-12-10 11:58:17
问题 I am new to Hibernate. Recently, I was trying simple example to connect my UI with Database using Spring and Hibernate. I am able to successfully call a method to fetch the data through my controller, service etc using REST. But I am encountering below error,whenever I run the application. Here " Feedback " is the name of Table in Database as well as the same name of my Pojo Java class. Note : Giving different names to table and Java class also results in same error. org.springframework.orm

SQL SELECT INSERT INTO Generate Unique Id

孤街醉人 提交于 2019-12-08 16:07:30
问题 I'm attempting to select a table of data and insert this data into another file with similar column names (it's essentially duplicate data). Current syntax as follows: INSERT INTO TABLE1 (id, id2, col1, col2) SELECT similiarId, similiarId2, similiarCol1, similiarCol2 FROM TABLE2 The problem I have is generating unique key fields (declared as integers) for the newly inserted records. I can't use table2's key's as table1 has existing data and will error on duplicate key values. I cannot change

SQL query to return data only if ALL necessary columns are present and not NULL

人盡茶涼 提交于 2019-12-08 06:24:20
问题 ID | Type | total 1 Purchase 12 1 Return 2 1 Exchange 5 2 Purchase null 2 Return 5 2 Exchange 1 3 Purchase 34 3 Return 4 3 Exchange 2 4 Purchase 12 4 Exchange 2 Above is sample data. What I want to return is: ID | Type | total 1 Purchase 12 1 Return 2 1 Exchange 5 3 Purchase 34 3 Return 4 3 Exchange 2 So if a field is null in total or the values of Purchase, Return and Exchange are not all present for that ID, ignore that ID completely. How can I go about doing this? 回答1: You can use exists .

Analog of “select level from dual connect by level < 10” for Sybase?

左心房为你撑大大i 提交于 2019-12-08 05:57:22
问题 By select level from dual connect by level < 10 in Oracle I can generate sub-query of integer and transform it to another sequence. Is this possible with Sybase? PS I want to find dates where are no data in table (missing days). In Oracle I do this as: select to_date('2012-01-01', 'yyyy-mm-dd')+level-1 from dual connect by level < to_date('2013-01-01', 'yyyy-mm-dd') - to_date('2012-01-01', 'yyyy-mm-dd') MINUS select distinct date from TBL where date between to_date('2012-01-01', 'yyyy-mm-dd')

SQL query and stored procedure not producing desired results

一世执手 提交于 2019-12-08 05:45:47
问题 I have this table and Stored proc function: Table: CREATE TABLE _DMigNumbers( Number numeric(20,0) NOT NULL PRIMARY KEY ); INSERT INTO _DMigNumbers VALUES(0) Stored proc function: CREATE FUNCTION read_and_increment() RETURNS NUMERIC(20,0) BEGIN DECLARE @number_just_read NUMERIC(20,0); SELECT number INTO @number_just_read FROM _DMigNumbers; UPDATE _DMigNumbers SET number = number + 1; RETURN @number_just_read; End and I create this Numbers table as well CREATE TABLE _Numbers ( Number int NOT

Sybase token datastream length was not correct

左心房为你撑大大i 提交于 2019-12-08 05:42:32
问题 Getting below error while saving a binary into a image column. org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [insert into lens_dal_data(dal_cd,user_id,insert_dt,exp_dt,url,map_data,cat_cd) values(?,?,?,?,?,?,?)]; SQL state [ZZZZZ]; error code [3805]; The token datastream length was not correct. This is an internal protocol error. ; nested exception is java.sql.SQLException: The token datastream length was not correct. This is

How to set timeout for a long running Sybase sp in Perl

柔情痞子 提交于 2019-12-08 04:37:40
问题 I'm calling a stored procedure which deletes data from Sybase DB in a Perl. But the sp takes hours to complete. I just want the sp to run for 1 hour, then no matter whether it completes or not I want the codes afterwards to be running. How can I implement this? sub DelRef { print "starting defRefData\n"; $db = new Sybapi($user, $password, $server, $margin_database); #the following sql will take hours $db->exec_sql("exec CPN_Margins..clean_up_refData_db '$XrefCode'"); } &DelRef(); print

ADO Recordset object returning 80004003 Error

▼魔方 西西 提交于 2019-12-08 04:32:19
问题 I am simply trying to Open a Recordset, but it is returning me error.. Here is a part of my code: void MyFunction(_ConnectionPtr ConnPtr) { _RecordsetPtr RecPtr; std::string command = "Select * from MYTABLE"; RecPtr.CreateInstance(__uuidof(_Recordset)); RecPtr->Open(command.c_str(), ConnPtr.GetInterfacePtr(), adOpenStatic, adLockOptimistic, adCmdText); //ERROR!!!!!!! } int main(int argc, char** argv) { CoInitializeEx(NULL, COINIT_MULTITHREADED) _ConnectionPtr ConnPtr; ConnPtr.CreateInstance(