db2

problem with SQL query in DB2

牧云@^-^@ 提交于 2019-12-12 01:35:19
问题 How can i write a query in DB2 for following thing: The difference between current timestamp and a timestamp field in dB should be >=4 hours AND <= 24 hours 回答1: You don't really give enough information to answer the question (i.e., do you want data only from the past, only in the future, etc), but let's assume you want the data where the timestamp column ("tscolumn") is more than 4 hours old and less than 24 hours old: select * from table t where t.tscolumn between current timestamp - 4

Numeric field accepting characters in cics map

故事扮演 提交于 2019-12-12 01:32:04
问题 I have 4 fields in my map which are 9(6),9(3),9(3),9(3). I wrote validation code like this: IF ROLLNUM IS NOT NUMERIC MOVE DFHRED TO ROLLNUMC MOVE 'INVALID DATA' TO RESMSGO MOVE ROLLNUMI TO ROLLNUMO PERFORM SEND-MAP THRU SEND-MAP-EXIT PERFORM KEY-VALIDATION THRU KEY-VALIDATION-EXIT. But I am not getting any kind of error while inserting the values like A12AK into the database from cics. It is replacing A with 1, B with 2, and so on... Why is this happening? And how to avoid this 回答1: Add

IBM Db2 data server client install fails

微笑、不失礼 提交于 2019-12-12 01:24:24
问题 With reference to to A Client for IBM DB2 7.2 AIX I'm trying to install the windows Db2 client: DB2-winx64-client-9.1.1200.483-FP012 (see: http://www-01.ibm.com/support/docview.wss?uid=swg24033024).This fails because it detected previous level of Db2 products installed but it can not determine where is what installed (I don't know what should be uninstalled). I tried to check the log files but they dont give me a clue: === Logging started: 16-2-2017 16:00:26 === Action 16:00:26: INSTALL.

DB2 update and insert trigger, references a lot of fields can I use * to shorten them (in iSeries but might not matter)

♀尐吖头ヾ 提交于 2019-12-12 01:06:52
问题 DB2 on iSeries is a little different then DB2 than other platforms but like I said it might not matter. Here are my following triggers (which work) (One difference is the use of '/' vs '.' depending on what tool is used to create the query) create trigger utbachInsert after insert on CO99PR/UTBACH referencing new as n for each row mode db2sql begin atomic insert into CO99PRH/UTBACH values( n.BCGRP, n.BCID,n.BCSTAT,n.BCDESC,n.YYRGDT, n.MMRGDT,n.DDRGDT,n.YY1EDT,n.MM1EDT,n.DD1EDT, n.YYBLDT,n

How can I convert the standard AS400 CYMD date format to MDY in PHP?

百般思念 提交于 2019-12-12 01:06:12
问题 I am doing quite a few queries within PHP. I am displaying information from these queries but I would like to change the date format to something that people other than programmers can easily read. Currently I have been able to get by by using this: $compdt = str_split($fin47['COMPDT']); $compdt = "$compdt[3]$compdt[4]/$compdt[5]$compdt[6]/$compdt[1]$compdt[2]" The above works great. For example, from the database, I return this for the date: 1090225 After I do my array and string arrangement

Select individual records only

青春壹個敷衍的年華 提交于 2019-12-12 01:02:14
问题 I have a table as such custno, type, color A1234, B, Red A1234, C, Blue A1277, B, Red A1288, A, Black A1288, B, Red A1289, A, Black I need to retrieve only the unique records A1277 and A1289 that are only found once. 回答1: This will display the custNO on the result list, SELECT custNo FROM tableName GROUP BY custNO HAVING COUNT(*) = 1 but if you want to get the whole row, SELECT a.* FROM tableName a INNER JOIN ( SELECT custNo FROM tableName GROUP BY custNO HAVING COUNT(*) = 1 ) b ON a.custNo =

Get all the index information for a given schema — db2

耗尽温柔 提交于 2019-12-12 00:50:43
问题 I am writing a JDBC program to fetch some database meta data information and as part of that I want to query all the indexes that are there in a given schema. I had a look at some JDBC API and from DatabaseMetaData interface, can use methods like getTables to get all the tables for a given schema. I am trying to find something similar (or write using a combination of some API) to get information like all the indexes,views etc on a schema. Is there a way to get it? For ex, for index there is a

How to get all the tables on which a particular user has access-DB2

主宰稳场 提交于 2019-12-11 23:33:09
问题 I need to know all the tables on which particular user let's say 'Abc' has any(read, write) kind of access. Is this possible in db2? 回答1: Try the SYSIBMADM.PRIVILEGES administrative view. You can find more about it in the DB2 Knowledge Center: SELECT AUTHID, PRIVILEGE, OBJECTNAME, OBJECTSCHEMA FROM SYSIBMADM.PRIVILEGES WHERE OBJECTTYPE='TABLE' AND AUTHID='userID' 回答2: Please use below to get list of of users, corresponding table and type of access(delete, modify, update, select etc), SELECT

How to get rows for n distinct values of a column

▼魔方 西西 提交于 2019-12-11 21:14:41
问题 I need to get rows for n distinct invoice numbers. I have SELECT query that gives me results from the table: SELECT A.INVOICE_NUMBER, A.INVOICE_SEQ_NUMBER, B.FILE_NUMBER FROM TABLE1 AS A, TABLE2 AS B WHERE A.INVOICE_NUMBER = B.INVOICE_NUMBER AND A.INVOICE_SEQ_NUMBER = B.INVOICE_SEQ_NUMBER So I get this as a result of my query: ----------------------------------------------------- | INVOICE_NUMBER | INVOICE_SEQ_NUMBER | FILE_NUMBER | ------------------------------------------------------

db2 query in shell script doesn't run with empty results in shell

扶醉桌前 提交于 2019-12-11 20:47:37
问题 I have below script in shell. test.sh #! /bin/bash connect_stat=$(db2 -x "connect to $DB_NAME USER $DB_USER using $DB_PASSWORD" ) db2 "SET SCHEMA=SCHEMA1" while read line; do a=$(db2 -x "SELECT C.id FROM table C WHERE C.col1 IN ('$line)') with ur") echo $a done<inputs.txt I get empty results when I run "sh test.sh" Where as when I run the same above query in db2 through putty, I get results. I have below dbcon file. Will trigger the dbcon file in putty and results are available /admin/