Hello I was trying to learn db2 sql and I was having some problems.
I want to bind a package, but I don't have any packages to bind.
So when I try to create a package it obviously gives me an error. I know that a package is created when we create a database. But then why doesn't it list any packages when i do
db2 list packages
I have seen a lot of links but no help. I would really appreciate if someone actually explained it to me.
Thank you very much
In order to understand a package, you first need to understand dynamic and static queries.
Dynamic queries are created at execution time. Everything from PHP, Perl, Python, Ruby or Java (JDBC) are Dynamic queries. For example, when using Java, you get a Prepared statement, and you assign values (setXXX) to the parameter markers (?).
However, there are other programming languages, such as C, Java (sqlj), cobol, where you create the program, with embedded SQL. For example, when using SQLj, you write a class in a .sql file, and the queries are written in specific tags (not java, but started with #sql { }), then you do a precompilation, that is a process where the SQL are taken out from the code, and translated to natural programming language (ie. from sqlj to Java). The SQL in then inserted into a file that is called a bind file. Once you have that, you need to compile the code (javac to create the .class) and bind the file in the database. In this last step is where the packages are created.
A package is a set of data access plans. However, they were calculated at the bind time, not at the execution time, like in the dynamic queries. They are difference between them.
Finally, in order to create a package, you need to change the bind properties, and eventually the bind file itself.
Related
I'd like to specify the database schema for a query by comment. I know that you can do it for files in the settings of intelliJ. But since this information is stored in the intellij configurations (I guess) which aren't shared in our company through git, those information are lost when the project is shared through a VCS like git. And so would other people not get correct validation of the queries.
What I'd like to do is basically something like this:
#schema=foo
SELECT * FROM bar;
Which would be the same as if you write:
SELECT * from foo.bar;
For what? Basically just for code completion and validation from intellij that your query is correct and has no syntactic or logical errors. Does anyone know if there's a plugin or hidden functionality? I searched around google but didn't find anything.
E: Nice would be if you can specify those comments for the whole file or only for single queries (first one would be better, second optional)
E2: It maybe looks strange why I don't just write the second example with the schema. But if I don't write that I can load the file to e.g. java and specify the schema dynamically in my source code through the database connection.
Just use appropriate "use statements" in sql file/console. IntelliJ IDEA honors them when doing resolve, and code completion. This is implemented so that you would have the same experience when executing the sole script or within IDE. This way the script will be valid from both points: stand alone execution and IntelliJ IDEA intellisense.
I've created a program with FM: TR_TADIR_POPUP_ENTRY_E071. I am trying to generate at the same time text-symbols for this program.
Any ideas how to do that?
I think there's no standard interface for that. Check the ABAP statement INSERT TEXTPOOL. Documentation is placed here.
Before anything I recommend you to manually create a local program with text-symbols and in another program read the texts with READ TEXTPOOL command to see what's the data structure. In that way you can build up the input data.
SAPLINK uses this technique also.
How do I generate SQL code for a SQLite3 database somehow dynamically with something like a template engine? I'm new to this and I'm using jinja2 to generate HTML. Could jinja2 possibly be used for such a purpose as well, if so, is that a good idea? I would like my program to save all the data (attribute values of instances of various classes) before it stops running.
check out https://pypi.python.org/pypi/jinjasql/0.1.6
it seems to basically just apply jinja2 to SQL templates. I haven't played with it much yet but was just asking the same question and came upon this.
I'm a bigginner at Talend,and I'm trying to load a database into an XML file, and that must be done automatically.So I don't have to specify any schema for the xml file all must be generated, because I'll have to use that XML file in other jobs. Is that possible using Talend ? and how can I do it ?
Thank you for your answers.
This is not possible by the very inner design of Talend: every schema (db, xml, delimited-files...) must be defined at compile time. It's not possible to detect it at runtime. You could try a complete java-solution using a user routine and some custom code, but this will move to a complete java-based solution, outside from Talend scope (and very inelegant and time-consuming, in my opinion). If it's your case, you probably should redesign your process.
I am maintaining an old VB6 application, and would like to include SQL scripts directly in part of the project. The VB6 application should then extract the text of this script and execute it on the server.
The reasons for this approach are various - among others, we want to deliver only an updated executable rather than a complete update/installation package. Hence, the SQL scripts need to be compiled into the application just like a resource file. And, obviously, one has to be able to get at the content from code, in order to send it to the database server.
Does anyone have a good way to do this?
The simplest solution is to just create a VB module with the scripts as strings.
If you want to use a resource file instead, you can do that too. You can associate a resfile with a VB project (I don't remember how to do this directly in the VB IDE but the VBP file supports a ResFile32 parameter).
EDIT: It seems like the issue here is mostly about formatting -- you don't want to store SQL queries as one long string, but formatting the query nicely inside VB is tedious because you have to add quotes, add string concatenation operators to join the lines together, etc.
I would recommend placing the SQL in a text file and formatting it in whatever way you like. Write a script that will take the text and convert it into a VB module. The build process would be modified to always apply this script first before compiling the application.
For scripting, use your favorite scripting language; if you don't have a favorite scripting language, this is an easy enough task that you could do it in VB, C#, or any other language. If it were me, I'd probably use awk (gawk) or Python.
If you want to use a resource (.RES) to store your SQL, go to the menu:
Add-ins > Add-in Manager...
and select VB 6 Resource Editor. Configure the add-in to be loaded and to load at startup.
From the editor add-in, VB provides a simple interface to add resource strings. You will refer to these using the provided constant values. To load the strings at runtime, use the LoadResString function:
Public Const SQL_INSERT As Integer = 101
Dim strSQL As String
strSQL = LoadResString(SQL_INSERT)
(replace "101" with the constant value of the string you wish to load)
Just another thought on your approach. Because I find myself tweaking the program's behavior or UI for customers I might be in the middle of a change that either is not ready or has not yet been tested and approved. So if I have properties that change from time to time, but I want to maintain control of, for instance connection settings to our ftp server, I will create a resource only dll exposing my properties and use a resource file in the dll to supply the values. When my network manager changes something on the ftp server I change the strings in the resource maanger, recompile the dll and release just the updated dll. I'm sure there are many more solutions, but that is how I do it. If you don't think you might have to change your SQL scripts at the same time you are changing you exe this probably only complicates your work. It has worked well enough for me that now this is pretty much standard for me.