I have more than 3 views. My database looks like this:
Category:
CatID | CatTitle
----------------
1 | XYZ
2 | Sample
Content:
ItemID | ItemCatID | ItemText | ItemText2 | ItemText3 | ItemText4
-----------------------------------------------------------------
1 | 1 | Test | Bla | Sample | MoreContent
2 | 1 | Test2 | BlaBla | Sample2 | Other Content
3 | 2 | Test3 | BlaBla2 | Sample3 | Other Content2
I want a view where first page category, second page list (ItemText), third page detail.
I'm not sure how to go about accomplishing that. If I use JOIN should I define "sqlite3_stmt *compiledStatement" in triple?
I think it can be done with 'For', "get parent,child" (like a cursor in java)?
Any advice welcome.
I'm not sure what you want.
Can you be more specific?
I can give you two tips though, first SQLite does not support stored procedures and has a very limited support for PL/SQL:http://www.sqlite.org/whentouse.html
if you REALLY MUST use it I suggest looking at this, I never tried it but it may work:
http://chriswolf.heroku.com/articles/2011/01/26/adding-stored-procedures-to-sqlite
Second, you usually wanna use a Wrapper around SQLite c functions so you worry about the SQL itself more and less about the c functions, examples:
Best Cocoa/Objective-C Wrapper Library for SQLite on iPhone
Hope this helps
Related
I am currently working with Postgresql and I am facing a problem.
I have two tables "question" and "question_detail" in which there are codes. In "question_detail" are the codes including subcode so e.g. TB01Q07, TB01Q07a, TB01Q08_SQ002. Now I wanted to use the command LIKE to see if the table "question" also contains these records. But in "question.code" there are only codes without the following underscore. This is a table that was given to me, I find this somehow very stupid.
The problem is that when I search with LIKE the value TB01Q07a is listed twice. This is also understandable to me, since searching for TB01Q07% also returns the value TB01Q07a.
Does anyone know of a way to search only for TB01Q07a without it resulting in TB01Q07% as TB01Q07a?
Command
SELECT qd.code, qd.label, q.type
FROM public.question q,
public.question_detail qd
where CASE
WHEN qd.code = q.code THEN qd.code = q.code
ELSE qd.code like CONCAT(q.code,'%')
END;
question
| code | type |
| ---------|-------- |
| TB01Q07 | comment |
| TB01Q07a | comment |
| TB01Q08 | option |
**question_detail**
```none
| code | label |
| -------------- | ------|
| TB01Q07 | AB01 |
| TB01Q07a | AB02 |
| TB01Q08_SQL002 | AB03 |
I ran the SQL and wanted the TB01Q07a value to appear only once and not be listed twice.
I think I have found a solution with distinct on.
SELECT distinct on (qd.code) q.id_question,qd.code, q.question, q.question_type
FROM public.question q, public.question_detail qd
where qd.code like CONCAT(q.code,'%');
like('TB01Q07%') matches both TB01Q07 and TB01Q07a, so you get two rows for TB01Q07 and one row for TB01Q07a.
You need to be more precise and include the underscore. Also make sure it's escaped, _ means any one character in a like.
There is no need for a case, use or. Avoid using multiple from statements, use an explicit join with an explicit on. This is clearer and gives you more control over the join.
select qd.*, q.*
from public.question q
join public.question_detail qd
on qd.code = q.code OR qd.code like q.code || '\_%'
Demonstration.
Note: this problem doesn't exist if you use foreign keys. Assign unique IDs to question and reference them in question_detail. This is faster, shields you from changes to the question code, and ensures the referred to question exists.
We are using Serenity with Jbehave for out automation stories, and we have recently upgraded our version to Serenity(2.2.1) and jbejave(1.46.0). Jbehave-core updated from 4.1.3 to 4.4. After the update i am facing an issue with examples table. it is forcing to use delimiter for the step table provided which is taken from story Examples.
This worked previously and got expected values into table
Scenario: Verify scenario
Meta:
Given modal should contains the next content:
{transformer=FROM_LANDSCAPE}
| modalTitle | expectedTitle1 |
| modalFooterTitle | expectedFooterTitle |
Examples:
{transformer=FROM_LANDSCAPE}
| expectedTitle1 | this is first expected title |
| expectedFooterTitle | This is expected footer text |
Now i have to use delimiter to get my expected content into table as below
Given product modal should contains the next content:
{transformer=FROM_LANDSCAPE}
| modalTitle | <expectedTitle1> |
| modalFooterTitle | <expectedFooterTitle> |
Examples:
{transformer=FROM_LANDSCAPE}
| expectedTitle1 | this is first expected title |
| expectedFooterTitle | This is expected footer text |
Also tried with configuration steps like ParameterControls().useDelimiterNamedParameters(false) but didn't worked. We have already implemented thousands of stories and it is hard to replace storied with delimiters. is there any work around to solve my problem?
What's the best way to translate the database content of a zend application ?
I am thinking to add field to database tables
Or create others tables
What I do is to have two tables and a view.
Let's say we have "nouns". So, I create a table NOUN_R with only "IdLanguage" (and whatever needed), another table NOUN_TR (translation), with, "IdLanguage" , a Locale (EN, DE, ...), description and text.
So far:
NOUN_R
NOUN | IDlanguage
Yellow | 1
Red | 2
NOUN_TR
NOUN | IDlanguage | Language
Yellow | 1 | EN
Giallo | 1 | IT
Red | 2 | EN
Rosso | 2 | IT
Finally, you get a view which filters on Locale!
That's the way I'm using right now, not the "best solution" :)
I can't find my way around copying a column, or a series of them, from a table.
The only solution I found so far is to copy the whole table and then delete the columns I don't need.
I suppose there must be another easier way for this. Maybe I am just too tired to realize how to do it.
I think the easiest way would be to take advantage of emacs rectangles
To create your rectangle, put your cursor at one of the corners of the rectangle you want to create.
Use C-SPC, or whatever you have set-mark-command set to.
Place your cursor at the diagonal corner of your rectangle.
Use C-x r rr to copy the rectangle to the register named r
Use C-x r ir to insert the rectangle that is being held in the register named r.
Following this process will copy and insert the columns that you want. You may need to repeat this process if the columns are not adjacent.
NOTE
I am using a bolded r to denote that this is technically a name of the register, and not some special input.
If you specifically want to copy the column(s) into another org table (or indeed back into the original table), there's support for that.
See C-hf org-table-copy-region RET
It works much like the regular rectangle commands, so it's not a better interface for selecting the column; but the associated paste command is smart about what it does with the content.
I you are planning to use emacs rectangle command you avoid the use of registers by using the command copy-rectangle-as-kill bound C-xrM-w, execute the command after selecting a region this will copy the rectangle (see this for an example of how marking rectangles works). Then you can paste the copied retangle by doing C-xry.
UPDATE
The page org-mode hacks describes a way to copy columns using org-table formulas. You will need to name the table.
Here is an example of using table formulas to copy columns from another table
Suppose you have following table named FOO, it is necessary to name the table for referring it from table formulas.
#+TBLNAME: FOO
| 0 | 2 | 1 |
| 1 | 3 | 2 |
| 2 | 4 | 3 |
You want to copy the columns 1 and 3 from table FOO to column 1 and 3 of the following table (lets call it B)
| | 5 | |
| | 6 | |
| | 7 | |
The following formula will do the trick, you will need to copy the formula below the table B and move cursor on the formula and do C-cC-c
#+TBLFM: $1=remote(FOO,###$1)::$2=remote(FOO,###$3)
The table B will be converted to the following
| 0 | 5 | 1 |
| 1 | 6 | 2 |
| 2 | 7 | 3 |
You can read about the syntax of the org table formulas here, basically $N refers to Nth column, #N refers to Nth row. ## and $# can be used instead of N to refer the row and column where the current value goes. remote(table-name, #N$N) refers to the Nth row and Nth column of the table table-name. :: concats multiple formulas.
I too had trouble using the standard rectangle operations. When moving to the next column, all of all of the rows between the point and the mark were highlighted. When I tried copying columns by formula as described above and in the org mode hacks, org threw errors if the column's values were non-numeric with more than one word.
But a good hint about cutting and pasting revealed that the problem is the initial direction of motion of the cursor. Moving first rightward to the next column, then down highlights the correct region. Standard rectangle operations then work correctly.
The "native" way in org mode is already covered in the answer by user2053036; I just wanted to add that in the simpler context, "to copy a column within a table": Let's say you have this table
| hello | world |
| is | good |
And want to repeat column 2 in column 3.
Steps:
Place the cursor after the bottom right | of the table
Open a new column to the right using keys Alt-Shift-<right>
| hello | world | |
| is | good | |
Add the "row copy from" formula (for example by putting cursor to row 1 column 3 and typing =$1 C-c C-c; or just type the TBLFM below the table and jump to step 4)
| hello | world | hello |
| is | good | |
#+TBLFM: $3=$1
Place the cursor on the TBLFM and type C-c C-c
| hello | world | hello |
| is | good | is |
#+TBLFM: $3=$1
That will copy column 1 to column 3.
I would like to insert a ASCII art table (as below) in the documentation.
The Markdown feature of doxygen comes in the way and messes it all up.
I've tried to the HTML table and they are fine but the source document becomes unreadable then.
Can I somehow get doxygen not to process a section but still include it in the output file?
Similar to here where 4 blanks allow to to inserted already formatted text in fixed width font.
|-------------|-------------------------|---------------|
|AUTO_NEW_OFF | Entry action | LED_FLASH |
| | | SEQ_OFF |
|-------------|-------------------------|---------------|
| | eXit action | |
|-------------|-------------------------|---------------|
| | | |
|-------------|-------------------------|---------------|
| OFF | SEQ complete | |
|-------------|-------------------------|---------------|
I think I can answer this myself already.
The Fenced Code Blocks ( 3 x ~) feature seems to work ok
~~~
|-------------|-------------------------|---------------|
| MAN_NEW_OFF | Entry action | LED_FLASH |
| | | SEQ_OFF |
|-------------|-------------------------|---------------|
~~~
An improvement on fenced code would be to surround the table with the doxygen commands #verbatim and #endverbatim.
If you use a "code" style, be that markdown's ~~~ or doxygen's #code, there's a chance that current or future versions of Doxygen will start trying to colour it in syntactically.