db2

how can I print results from sql procedure?

六眼飞鱼酱① 提交于 2020-01-25 06:48:15
问题 I'm writing a procedure to count rows in every table in my database. It so far looks like this: create or replace procedure count_database_rows() dynamic result sets 1 P1: begin atomic DECLARE stmt CHAR(40);-- FOR v1 AS c1 CURSOR FOR SELECT TABLE_SCHEMA, TABLE_NAME FROM sysibm.tables DO SET stmt = 'SELECT COUNT(*) FROM '||TABLE_SCHEMA||'.'||TABLE_NAME;-- PREPARE s FROM stmt;-- EXECUTE s;-- END FOR;-- end P1 ~ however, when I run it: db2 -ntd~ -f script.sql > dump.csv all I'm getting is:

How to grant access privileges to DB2 table using SQLAlchemy in a jupyter notebook

别等时光非礼了梦想. 提交于 2020-01-25 06:47:32
问题 I've followed several examples to create and drop a DB2 table using SQLAlchemy within a python jupyter notebook. That works fine. But after creating the table, I need to set privileges so others can view it. I use this code to create a new table from a Pandas dataframe "df" from sqlalchemy import create_engine, text engine = create_engine(r"...") df.to_sql(name='MYTABLE', schema='MYSCHEMA', con=engine, if_exists='replace', dtype=dashdb_typemap, index=False) I can drop the table just fine with

change sql parameter to date decimal

北战南征 提交于 2020-01-25 06:26:26
问题 I have a SQL command in crystal reports (its OK if your not familiar with crystal) and I need to convert a date parameter to a decimal (to match a column in the database.) SELECT decimaldate FROM TABLE1 WHERE decimaldate = {?normaldate} --ex: 12/01/2011 needs to become 12012011 IF I use a CAST on the above query it doesn't work: SELECT decimaldate FROM TABLE1 WHERE decimaldate = CAST(CAST{?normaldate} AS VARCHAR) AS DECIMAL) 回答1: Try something like this. select CAST(replace(convert(varchar,

DB2 connection through pyodbc and pandas.io.sql in Unix Box with non-root

落爺英雄遲暮 提交于 2020-01-25 04:38:07
问题 I am trying to connect to IBM DB2 through python using pyodbc and pandas.io.sql, now the twist is I am not Super User or better to say I dont have any right to install DB2 Driver or anything else. Is it possible to use pyodbc and pandas.io.sql to connect to DB2 with such conditions. The code which I used so far is cnxn = pyodbc.connect('Driver={FreeTDS}; Hostname=eee;Port=25369;Protocol=TCPIP;Database=rt;CurrentSchema=abc;UID=abc;PWD=efg;') Error pyodbc.Error: ('IM002', '[IM002] [unixODBC]

Cognos Report Studio (case statement) - Syntax error

﹥>﹥吖頭↗ 提交于 2020-01-25 00:52:53
问题 I have a case statement in Cognos report studio in which if the date is 1st of the current month of previous year then it should fetch data for last whole month (1 to the last date) data of the previous year. I think it is a syntax error. Below is the code that I'm sharing.Thanks in advance! Please let me know in case of concerns. case when [Corporate Calendar_BL].[Receive Date Details].[Receive Date - RD] = _first_of_month(_add_years(current_date,-1)) then [Corporate Calendar_BL].[Receive

Unable to setup a DB2 / DashDB JDBC Connection in Apache Airflow

♀尐吖头ヾ 提交于 2020-01-24 13:33:12
问题 I'm trying to create a DB2 / DashDB connection using the Airflow UI. I have added the db2jcc4.jar driver and provided the path as well as the class name com.ibm.db2.jcc.DB2Driver.class I tried to run a simple query (in the ad hoc UI) and always get the same error java.lang.RuntimeException: Class com.ibm.db2.jcc.DB2Driver.class not found Did anybody need to setup a DB2 / DashDB connection in Apache Airflow before? Found nothing on the web about that. Thanks 回答1: May be stupid thing to check

Is there an IBM Iseries/DB2 equivalent to SQL Profiler?

放肆的年华 提交于 2020-01-24 09:03:10
问题 Subject says it all. Looking to capture sql submitted to DB2. 回答1: Take a look at the Iseries SQL Exit Points which will allow you to log any submitted SQL. The only problem is you will have to write your own programs to do the logging: http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Frzaik%2Frzaikodbcexitprog.htm 回答2: If you have Java support enabled, you can use SQL PL Profiler. http://www.ibm.com/developerworks/data/library/techarticle/dm-0406rielau/index.html 回答3:

Default username and password for DB2 express

坚强是说给别人听的谎言 提交于 2020-01-23 06:50:50
问题 I have installed Db2 express on my local windows machine. Can anyone tell what is the default admin credentials. I have tried following combinations. Nothing works. username: db2admin password: db2admin username: db2admin password: Password123 回答1: Should be your local Windows login Here's what i read to find that: http://pic.dhe.ibm.com/infocenter/bldforge/v7r1m2/index.jsp?topic=%2Fcom.ibm.rational.buildforge.doc%2Ftopics%2Fpreinst_db_db2express_new_db.html There's this question too - that

How can I call a DB2 stored procedure with OUT parameters from SQuirreL SQL?

拜拜、爱过 提交于 2020-01-22 21:29:10
问题 I really like SQuirreL SQL as a SQL query tool, but I've never been able to get it to call stored procedures in our AS/400 DB2 database. I always get the error "The number of parameter values set or registered does not match the number of parameters." I've double-checked the number of params and had no luck. This is the syntax I've tried for a procedure that takes one IN and one OUT: call SOMESPROC(12345, ?); 回答1: It seems that SQuirrel currently is not capable of doing that on AS/400 DB2.

SQL Dump from DB2

与世无争的帅哥 提交于 2020-01-22 18:59:26
问题 I'm trying to dump the contents of a particular schema in one IBM DB2 UDB server into an sql text file (much like the mysqldump functionality of mysql). I came across db2look, but it only dumps the structure of the schema (only ddl, no dml). So how can I get my thing done? jrh. 回答1: You could use SQquirreL, an SQL Client implemented in Java, to accomplish this. In its "Objects"-Tree you would select all desired tables and select "Scripts > Create Data Script" from the context menu. 回答2: What