db2

DB2 Drop table if exists equivalent

血红的双手。 提交于 2019-12-19 05:16:42
问题 I need to drop a DB2 table if it exists, or drop and ignore errors. 回答1: First query if the table exists, like select tabname from syscat.tables where tabschema='myschema' and tabname='mytable' and if it returns something issue your drop table myschema.mytable Other possibility is to just issue the drop command and catch the Exception that will be raised if the table does not exist. Just put that code inside try {...} catch (Exception e) { // Ignore } block for that approach. 回答2: Try this

SQL Developer “disconnected from the rest of the join graph”

北战南征 提交于 2019-12-19 05:15:07
问题 I have the following SQL: select <misc things> from pluspbillline left outer join workorder on workorder.siteid=pluspbillline.siteid and workorder.wonum = pluspbillline.refwo and workorder.orgid = pluspbillline.orgid left outer join ticket on ticket.ticketid = pluspbillline.ticketid and ticket.class=pluspbillline.ticketclass left outer join pluspsalesorder on pluspsalesorder.salesordernum=pluspbillline.salesordernum and pluspsalesorder.siteid=pluspbillline.siteid In Oracle SQL Developer 4.0.0

DB2 connection from excel macro

荒凉一梦 提交于 2019-12-19 04:55:46
问题 I want to connect to DB2 from excel macro...This is my code, but it not working, Its giving error as 'Run-time Error'...Can anyone help me... Option Explicit Dim DBCONSRT, QRYSTR As String Dim DBCON, DBRS As Object Private Sub query() DBCONSRT = "Driver=jdbc:db2://my_host;Database=PRTHD;hostname=NZ1;port=5355;protocol=TCPIP; uid=my_user;pwd=my_pass" 'CHANGE THE BELOW QUERY STRING ACCORDING TO YOUR NEED QRYSTR = "select * from PRTHD.STRSK_OH_EOO" Set DBCON = CreateObject("ADODB.Connection")

IBM DB2: Generate list of dates between two dates

只谈情不闲聊 提交于 2019-12-19 03:38:11
问题 I need a query which will output a list of dates between two given dates. For example, if my start date is 23/02/2016 and end date is 02/03/2016, I am expecting the following output: Date ---- 23/02/2016 24/02/2016 25/02/2016 26/02/2016 27/02/2016 28/02/2016 29/02/2016 01/03/2016 02/03/2016 Also, I need the above using SQL only (without the use of 'WITH' statement or tables). Please help. 回答1: I am using ,ostly DB2 for iSeries, so I will give you an SQL only solution that works on it.

DECLARE GLOBAL TEMPORARY TABLE Vs CREATE GLOBAL TEMPORARY TABLE in DB2

£可爱£侵袭症+ 提交于 2019-12-19 00:37:07
问题 am creating a GLOBAL TEMPORARY TABLE in DB2. and when i surfed i got a two way to create 1. Declare 2. Create. 1. DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMP_EMP (EMPNO CHAR(6) NOT NULL, SALARY DECIMAL(9, 2), BONUS DECIMAL(9, 2), COMM DECIMAL(9, 2)) WITH REPLACE ON COMMIT PRESERVE ROWS ; 2. CREATE GLOBAL TEMPORARY TABLE TMPDEPT (TMPDEPTNO CHAR(3) NOT NULL, TMPDEPTNAME VARCHAR(36) NOT NULL, TMPMGRNO CHAR(6), TMPLOCATION CHAR(16) ) ON COMMIT PRESERVE ROWS ; and from IBM site i got a info that

How to find all open/active connections in DB2 (8.x)

折月煮酒 提交于 2019-12-18 21:48:49
问题 I'm currently working with Db2 Enterprise Server V 8.2 with FixPak 10 And I want to retrieve list of all the open active connections with an instance. In Oracle there is a utility program called "Top Session" which does the similar task. Is there any equivalent in DB2? Thanks in advance, Kamal 回答1: To get more detailed information from list applications: db2 list applications for database {dbName} show detail For applications with lots of active connections it is useful to pipe the results to

How to add an IBM DB2 server to SQL Server's Linked Server

百般思念 提交于 2019-12-18 13:36:41
问题 From .Net, I'm able to connect to the DB2 database: First I include a reference to "IBM.Data.DB2.iSeries" Then I create a new IBM.Data.DB2.iSeries.iDB2Connection. The connection string is DataSource=ChaDb2Server;UserID=MyUsername;Password=MyPassword; Then I create an IBM.Data.DB2.iSeries.iDB2Command, and so on. Now I'm trying to get my SQL Server 2005 to access the same data directly. In SQL Server Management Studio, I right-click on Linked Servers, and select "New Linked Server..." Linked

Executing DB2 Commands from Command Line to Remote Server

冷暖自知 提交于 2019-12-18 13:31:55
问题 I have two DB2 servers running Workgroup. For example, Server1 and Server2. From Server2, at a command prompt I would like to run a SQL command against a known database on Server1. Can someone explain to me exactly the steps I need to do in order to accomplish this. And do I simply use DB2ADMIN login for crendentials or do I need to setup some other login? 回答1: You need to catalog the Server1 database on Server2. You haven't mentioned if the servers are Windows or *nix. If the servers are

Cycle detection with recursive subquery factoring

点点圈 提交于 2019-12-18 11:45:36
问题 Oracle SQL can do hierarchical queries since v2, using their proprietary CONNECT BY syntax. In their latest 11g release 2, they added recursive subquery factoring, also known as the recursive with clause. This is the ANSI standard, and if I understand correctly, this one has been implemented by other RDBMS vendors as well. When comparing the connect-by with the recursive with, I noticed a difference in the result set when using cycle detection. The connect by results are more intuitive to me,

SQL query of multi-member file on AS400

烂漫一生 提交于 2019-12-18 11:22:40
问题 On AS400 in interactive SQL in a 5250 session, select * from myfile returns rows from one member only when myfile has more than one member. How can I get rows from a specific member? Important: in the end I'd like to do this over JDBC with jt400 so really I want a solution that'll work there. Thanks. 回答1: You can create an alias using the create alias command: CREATE ALIAS myLibrary/myAlias FOR memberLibrary/memberFile(memberName) This will allow you to run sql against that member using the