I am new to working with an AS400 green screen terminal and I am running some queries through the STRSQL command.
However, I cannot figure out how to clear the terminal screen to get rid of the past queries that were run.
An analogy; if im running command prompt and the screen gets too cluttered, i can run 'cls' to clear the screen. Is there a simular command on AS400?
You can press Shift-F1 (F13) and select option 3 "Remove all entries from current session". Then press Enter to confirm.
EDIT: Short answer: No. <- This is incorrect.
Long answer: you probably don't want to use STRSQL anyway. Use iNavigator (also on its way out) or IBM i Access for Web, which has a database interface. Another IBM offering is Data Studio. Alternatively, you could use any number of third party database tools like SQuirreL to do design work or for ad hoc queries. Basically, anything that uses ODBC / JDBC will work.
As a side note, the platform hasn't been called AS/400 for 20 years. Google searches for AS/400 are increasingly returning worse and worse results. A more modern name (only 10 years defunct) is iSeries. The current operating system is called IBM i, and the IBM web site is called the Knowledge Center. It's true that 'IBM i' doesn't yield the best search results, but that will never change unless we start using the term on the internet :-)
I use STRSQL all the time to prove an SQL statement either in my RPG or Web-based pgm.
I don't like clearing the historical statements because sometimes I find a hint, or a technique that I may need to reference again at some point.
With all that being said...
If your screen is "crowded" and you just want a brand new screen - simply page-down.
Related
I have a database which I didn't make and now I have to work on that database. I have to insert some information, but some information must be saved in not one table but several tables. I
can use the program which have made the database and insert information with that. While I am doing that, I want to see that which tables are updated. I heard that SQL Server Management Studio has a tool or something which make us see changes.
Do you know something like that? If you don't, how can I see changes on the database's tables? If you don't understand my question, please ask what I mean. Thanks
Edit : Yes absolutely Sql Profiler is what I want but I am using SQL Server 2008 R2 Express and in Express edition, Sql Profiler tool does not exist in Tools menu option. Now I am looking for how to add it.
Edit 2 : Thank you all especially #SchmitzIT for his pictured answer. I upgraded my SQL Server Management Studio from 2008 R2 express edition to 2012 Web Developer Edition. SQL Profiller Trace definitely works.
I agree with #Lmu92. SQL Server Profiler is what you want.
From SQL Server Management Studio, click on the "Tools" menu option, and then select to use "SQL SErver Profiler" to launch the tool. The profier will allow you to see statements executed against the database in real time, along with statistics on these statements (time spent handling the request, as well as stats on the impact of a statement on the server itself).
The statistics can be a real help when you're troubleshooting performance, as it can help you identify long running queries, or queries that have a significant impact on your disk system.
On a busy database, you might end up seeing a lot of information zip by, so the key to figuring out what's happening behind the scenes is to ensure that you implement proper filtering on the events.
To do so, after you connect Profiler to your server, in the "Trace properties" screen, click the "Events Selection" tab:
You probably are good to uncheck the boxes in front of the "Audit" columns, as they are not relevant for your specific issue. However, the important bit on this screen is the "Column filters" button:
This is where you will be able to implement filters that only show you the data you want to see. You can, for instance, add a filter to the "ApplicationName", to ensure you only see events generated by an application with the name you specify. Simply click on the "+" sign next to "Like", and you will be able to fill in an application name in the textbox.
You can choose to add additional filters if you want (like "NTUsername" to filter by AD username, or "LoginName" for an SQL Server user.
Once you are satisfied with the results, click "OK", and you will hopefully start seeing some results. Then you can simply use the app to perform the task you want while the profiler trace runs, and stop it once you are done.
You can then scroll through the collected data to see what exactly it has been doing to your database. Results can also be stored as a table for easy querying.
Hope this helps.
Although you describe in your question what you want, you don't explain why you want it. This would be helpful to properly answer your question.
ExpressProfiler is a free profiler that might meet your needs.
If you're looking to track DDL changes to your database, rather than all queries made against it, you might find SQL Lighthouse useful, once it is released in Beta shortly.
Disclosure: I work for Red Gate.
Do you know something like that? If you don't, how can I see changes
on the database's tables? If you don't understand my question, please
ask what I mean. Thanks
Red gate makes a lot of great tools. You can always make a database comparison. That will require that you make a backup, then doing whatever you want to do, and the compare the two databases, there is a free trial, works perfect to compare which tables has changed (deleted/inserted and modified)
http://www.red-gate.com/products/sql-development/sql-data-compare/
what you might maybe be looking for is "SQL Server Profiler". It's a SQL monitor where you can see all the SQL queries running real time.
http://technet.microsoft.com/en-us/library/aa173918(v=sql.80).aspx
Hope that helps you.
As far as I know SQL Profiler tool is not included in the Express edition of SQL Server (only Developer edition contains it). Maybe you can purchase it separately.
If you want you can try this https://sites.google.com/site/sqlprofiler/ free tool for profiling. Maybe it has limitations, but it you can check it.
There are also some profiling tools for integration with Visual studio, and also the ReSharper has InteliTrace (if you are using the tool at all).
Cheers.
Does anybody knows if there is any way to set the default value for the "With design from Server" drop down field ???
The inconvenience is that I have quite a long list of servers and have to select the development server every time I refresh the design.
It would be handy to be able just to click on OK button in this dialog box, rather then browsing for the same server name again and again...
Sorry. At least from my knowlegde this is not possible. Best option is trying what has already been suggested in the comments.
That said you can also change the design using the "load convert" command on the Domino server console (it's not just for converting mail boxes).
Ove
I have spent quite a bit of time scouring the overflow forums and using other resources to try and figure this out without success. My apologies if this has been answered elsewhere. But, to my knowledge it hasn't
Here is a little background. I have some experience with SQL, Visual basic and Auto Hot Key (awesome program). Currently I am trying to learn more than the basic stuff I know about SQL (little rusty too).
For my previous and current job I work(ed) a lot with IBM's iSeries (or 'Mainframe' as some veterans like to call it.) Specifically it's version: IBM DB2 PE 9.7 FP5 SRM R1 on the DB2 i5/OS.
As you may know, iSeries related emulators have a feature that allows its users to record macros for later playback. This feature of course has its limitations. I have written some from scratch in Visual Basic that are more flexible in the operations that they can perform. However, you can only do so much with VB.
Regardless of how you look at it, iSeries is slow IMO. In order to pass/retrieve information to/from its database/server its users are limited to the speed of the program (among other things). VB macros are subject to smart pauses/timeouts as these are needed for scripts to work (like auto hot key)
iSeries does have a feature where you can query information, interact with libraries (schemas if I have that right?) and tables using the i5/OS Query manager. It also has an FTP feature (which has its uses I guess).
I have started playing around with Powershell and SSH/Qshell, I have read a lot of documenation in IBMs extensive support section on their site regarding iSeries and all things related.
So here are the questions:
Is qshell/SSH an efficient way to retrieve information from a database, or more specifically, the libraries that 'DB2 for iSeries' uses (.lib/.file extension files?)?
Wouldn't writing SQL scripts and executing them via SSH/Qshell be faster than using the iSeries emulator itself?
Is this only possible via port forwarding or tunneling?
How do I find out more about the server via SSH commands? I can navigate the servers directories pretty easily and view files that I otherwise cannot see within iSeries. Its database files are .lib/.file/.mbr file extensions that I cannot view using the 'cat' command. This would require using SQL commands I am assuming?
Do I need to log on as a root user in order to have read/write access privelages and perform anything SQL related?
As mentioned above I have played around with ssh/qshell but I am having difficulty bringing up the mysql/sql prompt to do anything (I am using openSSH 4.7p1 / a unix CLI?) which I believe changes from $ to > when you successfully do this. I have been able to do this but am unable to execute any SQL related commands so I am not sure what I am doing wrong.
Below is an example of me logging into the server over ssh via powershell and trying to execute something SQL related:
PS H:> ssh -1 myusername#blabla.something.com "mysql -u myusername -e 'show tables;'"
enter password: password
connected
Could not chdir to home directory /home/myusername: A file or directory in the path name does not exist
bsh: mysql: execute permission denied
bsh: cannot execute
Connection closed to blabla.something.com
This is an example of just logging in over ssh as normal:
ssh -1 myusername#blabla.something.com
Could not chdir to home directory /home/myusername: A file or directory in the path name does not exist
$ Mysql
mysql: execute permission denied
$ "mysql
'show databases;'"
mysql
'show databases;'" not found
Any insight as to what I am doing wrong or feedback on my questions is greatly appreciated. I know there are alternatives to what I am trying to do using PuTTY (not really an option at work), ODBC drivers (can't really download an IBM iSeries fixpack to get the drivers or repair the installation of iSeries as I can't anyways I don't have Windows admin privs)
UPDATE
First, I want to thank you all for your comments and your insight.
Warren:
Thank you, for you insight. IBM DB2 PE 9.7 FP5 SRM R1 is indeed DB2 LUW, or "COBRA". This particular emulator is an adaption of IBM's 3270 emulator. This knock off brought to you by attachmate (they added a couple bells and whistles and no longer offer support, ODBC drivers etc). Within this version, I have the option to utilize IBM DB2 Query Manager for i5/OS. I would agree that the server is partitioned (I think?) as I have been able to call different prompts like DB2/SQLJ/JAVA, just haven't been too successful with using them lol. Perhaps my attempts below will reveal a little more.
James:
Thank you for your input, I never thought to do this from powershell directly. As for the redbook, have it! I'm still reading it though. This may be a little more advanced than where I currently stand with powershell and ADO.NET. I will need to take a more in depth look at your coding example to gain a better understanding of it.
Buck:
I appreciate your point by point feedback. Not sure what your setup is, but IBM i in general (especially anything after i5) is insanely fast. The company I work for.. or at least the immediate people I work with, know very little in regards to i/vba/qsh/etc. To put it politely. So, much of what I have learned has been through reading and applying what I learn. This, actually, is only my second post. On any website, ever. I don't like to just post away because I can't figure something out in a minute. I'm stubborn and will spend hours if I have to make a script work.
As for STRSQL, the equivalent I use is STRQRY. From reading IBM's i5/OS Query Manager PDF (300 pgs -_-). I would agree that this is a very powerful tool. The only drawback is 1. you have to make a form that will format the query and 2. You have to create the Query using SQL . This is no big deal whatsoever. Unfortunately, there are hundreds of schemas, and sometimes thousands of .FILE extensions within any given LIB (among other extension types). Luckily I have narrowed this down to the primary LIB that I access most. Unfortunately, there are something like 4000+ files extensions within this library and files within some of those files (︻╦╤─ ^ _ ^). Going through all of them is a little time consuming to say the least.
There are some "macros" that perform a query in batch and then prints the data to a formatted file onto the server (which takes erm... like 30 mins for 500-600 pages). Is there any way I could view the parameters of this batch run? "Work with queries/query forms?"
The primary reason I am more so interested in using QSH>SQL to perform a query and navigate a database is due to the fact I would like to improve my SQL skillz (beginner) but I would like to be able to apply this knowledge to other environments in the future.
God, I write too much s***
My recent efforts: I am sorry. My formatting sucks
After I log in via ssh this is what I attempted:
$ db2 "select * from sysibm.sysdummy1"
db2: cannot execute
$ cd /usr/bin
$ ls
ajar
qsh
sqlj
db2
db2profc
dataq
java
javadoc
javah .....
$ db2 "select from qsys.lib
++++++CLI ERROR++++++
SQLSTATE 42704
LIB in QSYS type *file not found // there are tons of .file extensions within btw
$ cd ..
$ cd qsys.lib
$ ls
A crap load of .lib .menu .file (*file?) extensions
$ db2 "select * from 1234abcd.lib"
++++++CLI ERROR++++++
SQLSTATE 42601
NATIVE ERROR CODE: -104
Token not valid bla bla VALID TOKENS: FOR SKIP FETCH ORDER GET // success! well still fail
Questions
So my problem now is I just need to use valid tokens. Does anybody know of a good example? (im going to attempt on my own still)
For the life of me I cannot replicate the process above, to where I at least get a cli error / SQLSTATE. Everything now returns:
"db2: you should just give up lol"
I try to log everything I do, guess I missed something important ay? Somewhere between...
$ cd /usr/bin
$ ls
and
$ db2 "select * from iforget.lib"
Something happened to where I could at least execute SQL statements. Now, nothing.
db2 : t(ಠ益ಠt)
Its late. So tired
Any feedback = Appreciation
The qshell (and DB/2) equivalent to the mysql cli command is db2:
db2 "select * from sysibm.sysdummy1"
If you have the IBM Access .NET data provider installed you can query directly from PowerShell:
# Assembly name from \\HKCR\Installer\Assemblies\Global
$an = 'IBM.Data.DB2.iSeries,Version="12.0.0.0",PublicKeyToken="9CDB2EBFB1F93A26",Culture="neutral"'
# Connection string
$cs = 'Data-Source=10.0.0.50;UserID=QPGMR;Password=****'
Add-Type -AssemblyName $an
$cn = New-Object IBM.Data.DB2.iSeries.iDB2Connection($cs)
$cn.Open()
$cmd = $cn.CreateCommand()
$cmd.CommandText = "SELECT * FROM SYSIBM.SYSDUMMY1"
$da = New-Object IBM.Data.DB2.iSeries.iDB2DataAdapter($cmd)
$ds = New-Object System.Data.DataSet
$cnt = $da.Fill($ds)
Write-Host "$cnt records selected."
$cmd.Dispose()
$cn.Close()
foreach ($dt in $ds.Tables) {
$dv = New-Object System.Data.DataView($dt)
$dv | Format-Table -AutoSize
$dv.Dispose()
}
$ds.Dispose()
For more information see the IBM Redbook Integrating DB2 Universal Database for iSeries with Microsoft ADO .NET .
1) Is qshell/SSH an efficient way to retrieve information from a
database, or more specifically, the libraries that 'DB2 for iSeries'
uses (.lib/.file extension files?)?
The synopsis was helpful; it appears you are interested in doing ad hoc queries rather than writing an end-user application. qshell is just as efficient as the IBM i command STRSQL in terms of issuing SQL statements and seeing the results immediately in an emulator window. I just queried a 2 million row table on a column without an index and got the first page of results in .23 seconds.
2) Wouldn't writing SQL scripts and executing them via SSH/Qshell be
faster than using the iSeries emulator itself?
It is difficult to understand what faster might mean. It seems you are using the emulator solely to play back macros; this is not particularly efficient. Typically, one would use the emulator to get to a command line, issue the STRSQL command and run ad hoc SQL queries from there. That is very fast in terms of getting the results to display.
3) Is this only possible via port forwarding or tunneling?
This depends entirely on how the network was configured.
4) How do I find out more about the server via SSH commands? I can
navigate the servers directories pretty easily and view files that I
otherwise cannot see within iSeries. Its database files are
.lib/.file/.mbr file extensions that I cannot view using the 'cat'
command. This would require using SQL commands I am assuming?
Whoever hired you must have given you some basic information to get you started, so you probably already know the libraries (schemas) and files (tables) which make up the production environment. So I'm assuming that you aren't asking about SQL catalogs like SYSCOLUMNS and SYSTABLES but rather things which are more specific to IBM i. The reference material for IBM i is located in the Infocenter.
5) Do I need to log on as a root user in order to have read/write
access privelages and perform anything SQL related?
No system demands root privileges in order to perform read/write access. Your employer will need to provide you with a user profile having privileges to the tables you want to access.
If you need a light weight terminal emulator, look at the tn5250 project on Sourceforge. You won't need Windows admin privileges to install or run it.
Oftentimes I need to troubleshoot a workbook that another person at my company has created and published to our server. To troubleshoot, I need to see their connection details, specifically their Custom SQL, to understand what data they are using in their extract.
Is there any way to view this connection info (specifically their SQL code) when viewing the published workbook on the server (web) version?
I am an admin and I am able to download their workbook to my desktop version of tableau, then open it, then reconnect to the data, then look through the data connections they created, to see their SQL. But it's a really cumbersome process.
All I'm looking to do is, when looking at a published workbook, see the data connection details so that I can see the Custom SQL, without going through the process of downloading I described above.
You can get some details on the SQL statement by creating a performance recording.
From the Tableau Server Admin Guide:
Enable Performance Recordings:
Choose the Admin button in Tableau Server.
Choose Site.
Select a site.
Choose Edit.
In the Edit Site dialog box, select Allow Performance Recording.
Choose OK.
You start performance recording for a specific view by adding ?:record_performance=yes to
the url. For example:
http://server.site.com/views/Variety/BaseballStatistics?:record_performance=yes
Now, notice a new link at the top of your view called "Show Performance Recording".
Click this to open the generated performance workbook dashboard. Click on the bar chart and observe the SQL appear at the bottom of the view. Note, the SQL text will truncate after about 250 characters.
The admin guide suggests viewing the "Tableau Log" to find the full SQL statement.. I have looked at all the server side logs in C:\ProgramData\Tableau\Tableau Server\data\tabsvc\logs but cannot locate the SQL. (please reply if you know where to find this?)
You can also run a database trace to see the SQL that the database sees. For example, for MS SQL Server, run the Profiler tool, setup a default trace, and filter on "Application Name" = "Tableau Protocol Server 8.0" or similar.
I have version 8.1 and this is how I got around this problem. Tableau shows a 'Custom SQL Warning' when you open a workbook that contains the custom SQL. You can copy all the text in this message by simply Ctrl + C as this is any other Windows warning message. And then paste it your editor of choice to analyze it.
I do not know if this works on earlier versions.
I thought you could do this easily, and originally answered that you could, but I didn't pay close attention to your question. You can change some things about data connections without editing the workbook, including the ip address or name of the database server, but there doesn't appear to be a simple way to access custom sql without downloading the workbook.
Go to the Administrator page and select Data Connections.
You can enter some search criteria to filter the list of data connections shown (or not).
Find the workbook in question by scanning the second column -- you can sort the column if that helps.
Then select the corresponding data connection in the 4th column to see the details of the connection.
If it makes sense for the connection, you can also modify the connection directly at the server. This is really useful if you, say, need to move your enterprise database to a new IP address or change a database password, without downloading, modifying and republishing alot of workbooks.
An even better practice is to start using shared data connections hosted on Tableau server instead of having each workbook have its own local copy of connection and related info.
So I've created an Access Project for one of my users so he can connect to a reporting database. The .adp project connects to the DB and he can query data to his heart's content. The problem is, no queries can be saved. Whenever he opens the project, he is presented with the following error:
"This version of Microsoft Access does not support design changes with the version of Microsoft Sql Server to which your Access project is connected. See the Microsoft Office Update Web site for the latest information and downloads. Your design changes will not be saved."
Again, this is Access 2007 and Sql Server 2005. My googling efforts - which are coming on a day when I seem to be especially stupid - keep bringing up information regarding this error for Access 2002/2003 trying to connect to Sql Server 2005, which is clearly not my problem.
I'm seeing that one can connect to Sql Server with the normal Access databases (.accdb in 2007 or some such), but I'm seeing mixed information regarding whether I want to do this or not. And since I can't get a copy of Access 2007, I can't really test this (topic for another time).
Before I do down that road, I'd like to get to the bottom of this one. Anyone have any suggestions, useful links, or useful knowledge? Or an older developer who knows the answer that is no longer needed, so I can eat him and absorb his knowledge and powers?
The account being used to connect to the DB was only a db_reader. I changed it to DBO and that fixed the problem - user can now create and save queries, and sleep at night knowing that tomorrow will bring a new day with new querying possibilities.
I'm not super crazy about this though the reporting database has been set up on a separate install/server from impotant App databases. I'm not worried about the user (or anyone on his group) blowing anything up. I'd like to understand why this is, and don't (outside of the obvious - reader is read only! I didn't expect that to extend to work in Access), and will try to do so at a later time. One of the unfortunate aspects of working at a dev shop focused on internal app development is, "well, it's working, you have other things to see to".
I am not sure if I can be of help here.
But you can have a view inside Access which connects to SQL database and use that view.
Alternatively, you can go the other way. Have a DB project with SQL Server & create a linked server to MS-Access DB.
Did you try linking to the tables through an ODBC connection?
CodeSlave, I did not. The attitude from higher up is "it's working, move on". I'm not sure the boss really wanted to go down that road anyway, but it's a moot point. I should probably try granting the account dbreader and dbwriter access and see if that accomplishes the same thing, but it being dbo isn't really a huge deal. Or rather, it's not a big enough deal that The Powers That Be want me to seek an immediate change.
I was going to try linked tables until changing the SQl Server account permissions "fixed the problem" (quotes very deliberate; it feels like one of those solutions you arrive at without a proper understanding of what it worked, which vexes me).