writing SQL queries in db2 database - db2

I'm new be to DB2/AS400. I know writing sql queries to insert/update in the database but not sure how could i perform same thing in DB2/AS400.Can any body guide me how could i write the sql insert/stored procedure queries in db2 database

STRSQL as suggested previously would work fine but it is a green screen (5250 emulation) option; if you are not familiar with that environment, I would recommend you use the 'Run SQL Script' function from either IBM i Access Client Solutions or IBM i Navigator, whichever is available to you.

On the AS400 command line issue the following command.
STRSQL
Start Here and this is typical IBM documentation. It leaves you guessing why am I here.

Related

Can we see IBM DB2 stored procedure content in AQT(Advanced Query Tool)?

I am not an expert in IBM Host tools as I am from development distributed side. Is there anyway that we can see the source code of IBM DB2 stored procedure in AQT tool. I know we can use any emulator tools like Attachmate Extra! X-treme, but the process seems very tough for me. To view a single stored procedure content, I had to type many number of commands. So I just thought it would be great if we have an option to view the same in a simple way, like we have sp_helptext in SQL SSMS (SQL Server Management Studio).
Update:
When I go to the Database Objects -> Procedures, all the schema's for different stored procedures are loading. And when I click on each schema, the stored procedures associated with that are loading, where I am able to see the procedure parameters, run procedure, create procedure etc. But I couldn't find any option to see the actual SQL query of the procedure.
When I click right click on procedure name and select View, I am getting options as,
Procedure Details
Procedure Params
User Access List
Package Access List
I am not seeing any option like Procedure Text. The language in Procedure Detail shows as COBOL and User Access List shows Execute G. Sorry that I can't provide any screenshots here, as it is the client machine I am working on.
Are you using the right tool for the job?
The AQT tool appears to be for procedures that are written in SQL, but your procedures appear to be COBOL stored-procedures. Source code for COBOL stored-procedures is normally managed outside of the RDBMS.
Talk with your DBA team or COBOL developers to find out which toolset at your site gives access to the source code for the COBOL stored procedures.

DatagGrip does not recognize Redshift specific commands

I'm trying to run Redshift UNLOAD command in DataGrip and it will not work. Datagrip highlights the UNLOAD keyword and the message displayed is:
<statement> expected, got UNLOAD.
It will not run.
Regular SQL statements run against Redshift though.
I'm using the Redshift JDBC driver.
Am I missing a setting somewhere or is there a specific way of running UNLOAD in DatagRip?
Thanks
Talked to people at DataGrip, they do not support the redshift sql dialect at this time. Boo.
I use DataGrip for my Redshift work almost exclusively (and have done since it was 0xDBE).
It works totally fine, especially with the Redshift JDBC driver (set the class to com.amazon.redshift.jdbc42.driver and the dialect to PostgreSQL) .
If something doesn't want to run then just highlight the whole SQL statement and hit ⌘+⏎ and it sends the query unmodified. But, as of 2016.3, I'm not getting these syntax errors.

Graphical query designer for PostgreSQL

I have for years used MS Access and its query tool that is used for making queries. This tool is so good that I have never been forced to do very much SQL programming myself. The query tool has done all the work.
However, now I have started using Postgres and the Graphical Query Builder in pgAdmin. It seems that the Graphical Query Builder is rather primitive: It cannot be used if you need an aggregate function like SUM or COUNT.
Is this really correct?
Does anybody know a better graphical query builder for PostgreSQL?
Until now I have 'solved' the problem by linking MS Access to the Postgres database through ODBC and used MS Access' query tool to generate SQL commands which I then copy into pgAdmin's Graphical Query Builder - and edit the SQL commands until everything is correct.
SQL Maestro has a query designer, although it is PC only, AFAIK
http://www.sqlmaestro.com/products/postgresql/maestro/screenshots/getting_started/visual_query_builder/
EMS SQL Manager also has a query designer
http://www.sqlmanager.net/en/products/postgresql/manager/screenshots
Try SQLeo, its free and has a specific feature (autosavepoint) to prevent
ERROR: current transaction is aborted, commands ignored until end of transaction block.
Try a browser-based query builder for PostgreSQL called Skyvia. And you don’t have to worry about which operating system it works. It works where a browser exists. Simply make a connection to your PostgreSQL database and start building your queries. See a sample below.
Note that you can still switch between SQL code and query builder if you want to, just like in MS Access. Get the details here.

DB2 Where are profile tool like SQL Server Profiler?

I'm using DB2 9.5. Is there exists tool like SQL Server Profiler?
I want to view all executing SQL queries.
To watch all executed queries you can create an event monitor. Please see CREATE EVENT MONITOR statement for statements.
Finally have found a nice small and light-weight and freeware tool: db2mon.
http://www.db2mon.com/

Progress ABL procedure to SQL Insert

We have a software solution that involves syncing some data between a Progress database and SQL server. Unfortunately, we do not have any Progress gurus in house, so I'm working kinda blind here and would welcome any advice that is on offer.
For the workflow that is already in place, what would work very well for us is the ability to do an external call to insert a row into an SQL database from an within ABL procedure's 'for each' loop.
Is anyone able to direct me to any code snippets or articles that might help me achieve this?
Many thanks,
In case your SQL database is MS SQL Server, you might want to have a look at OpenEdge DataServer for Microsoft SQL Server (web.progress.com/en/openedge/dataserver-microsoft.html, documentation.progress.com/output/OpenEdge102b/pdfs/dmsql/dmsql.pdf).
The DataServer provides you with ABL access to a non-Progress database so you can use standard Progress statements, e.g. CREATE to add new records or FOR EACH to retrieve query results.
OpenEdge DataServers are also available for Oracle (using Oracle Call Interface), DB2 and Sybase (using ODBC). The DataServer for MS SQL Server uses ODBC behind the scenes as well. web.progress.com/docs/datasheets/openedge/openedge_dataservers.pdf
You dont need the dataserver, connection with ADODB works fine in ABL, you can even call stored-procedures with the command object, the user you connect with will have to be granted EXEC rigths on the SQL-Server to do that.
I'm not a Progress guru, but I did do some work in it for awhile. AFAIK there is no way to have ABL code connect to a non-Progress database (part of that whole vendor lock-in strategy Progress Corp. leverages).
Your best bet is probably to have the ABL code serialize the records to XML, and use something like ActiveMQ (or even a plain socket or named pipe/FIFO depending on your setup) to send them to a program written in a more capable language to do the SQL insert.