How to get the grid view for query results using oracle sql developer in mac? - oracle

When I issue a query like select * from city; using oracle sql developer in mac I get the output that is not aligned and it is very hard to read. How do I get the grid view and set it as default?

Sounds like you're getting the script output. You can have that formatted nicely by using SET SQLFORMAT ansiconsole, we'll make the columns line up as nice as possible based on the size of the display.
But if you want the data back in a grid, use Ctrl+Enter or F9 or the first execute button in the toolbar to execute.
This will get you the output in a grid, like this:
I talk about both executing as a script or statement here.

If your issue is with formatting, you may want to look at this link
If your issue is with records not getting inserted, please note these.
Records inserted in one session will not be visible in another session unless they are committed.
If you are checking the count in the same session where you inserted the records, then check for errors in insert. Add a show errors command at the end of your script, "path_to_file.sql" to check if any errors occurred while inserting the records.
Hope this helps.

Related

Table name becomes undefined when query is moved to new tab?

I have a query which is part of several queries in a tab.
I want to modify each of the queries by adding exclusions.
But when I copied the first query and put it in a new tab for testing, the table was underlined in red, and when you hovered over the text, it said 'Undefined table.'
Does anyone know why this would happen when the query is moved to a new tab?
I hadn't made any changes, yet!
The query looks like this:
SELECT
CONCAT ('DX COST',null) as "R List",
TRIM(T$SKU) as "SKU",
T$PDDP as "Price"
FROM TRITON.DDIITM001145
WHERE T$GSIZ NOT in ('LED','ODS');
The part TRITON.DDIITM001145 part of the query was underlined in red, when I copied the query and moved it into a new tab.
I've never seen that happen before?
Also, I'm not sure how to put the whole query in code, on here? I used the {} / code sample button to paste what you can see, but it didn't include the FROM statement?
Any thoughts would be appreciated!
Thank you!
In your new query tab, are you using the same database? Because our parser checks the data dictionary to see if it can find a view, table, or synonym called DDIITM001145
If we can't find it, you get the squiggly 'warning.'
This is ONLY a warning. It won't prevent you from running the query. It's just a heads-up that it might not work before you trying running it.
If you look at the Log panel, you can see where we query the database looking for your table.

Lazarus DBGrid totally blank after record commit

I have been using Lazarus 2.x (free pascal) with firebird 3 (via flamerobin) and i try to commit records via TSQLConnection, TSQLQuery, TDBConnection in data module (appeals) etc.
I run the following code snippet and the records are successfully commited to firebird, but unfortunately DB connection afterwards is lost and thus there is not any record to be seen via DBGrid (not even column headers - totally blank). I have to terminate the application and reopen it to gain visual insight of my firebird via DBGrid.
Button click event
appeals.SQLTransaction1.Active:=false;
appeals.SQLQuery1.SQL.Text:='UPDATE appeals set name=:name,date_entry=:entry,date_suspended=:suspended,'+
'date_court=:court,date_judgement=:judgement where id='+IntToStr(row_num);
appeals.SQLQuery1.Params.ParamByName('name').AsString:=Trim(Edit1.Text);
appeals.SQLQuery1.Params.ParamByName('entry').AsDate:=DateTimePicker1.Date;
appeals.SQLQuery1.Params.ParamByName('suspended').AsDate:=IncDay(DateTimePicker1.Date,10);
appeals.SQLQuery1.Params.ParamByName('court').AsDate:=DateTimePicker2.Date;
appeals.SQLQuery1.Params.ParamByName('judgement').AsDate:=IncDay(DateTimePicker2.Date,20);
appeals.SQLTransaction1.StartTransaction;
appeals.SQLQuery1.ExecSQL;
appeals.SQLTransaction1.Commit;
I have also used .CommitRetaining as exactly mentioned in lazarus forum without success. Any idea what could i do in order to see my records live in DBGrid after commit.
Regards
The reason the DBgrid shows nothing is that SqlQuery1.ExecSQL does not return a result set, so SqlQuery1 cannot supply any records for the DBGrid to display. So call SqlQuery1.Open after your Commit.
However, before you can call SqlQuery1.Open, you need to give it a SELECT statement to Execute, because a SQL UPDATE statement does not return a result set, as you have already found. So, do something like:
[...]
appeals.SQLTransaction1.StartTransaction;
appeals.SQLQuery1.ExecSQL;
appeals.SQLTransaction1.Commit;
appeals.SQLQuery1.Sql.Text := 'Select * from appeals where ...';
appeals.SQLQuery1.Open;
obviously replacing '...' in the 'where' clause by something appropriate. Normally. a SELECT query should be parameterised to limit the number of rows returned and the amount of time the table is locked on the server.

Oracle Apex Application manual tabular form

I have an interactive report, where the query is combined, so I can't use editable interactive grid. That's why I have to use manual form in my query.
I've found some nice tips about the APEX_ITEMs, but I have problem with my process.
In my query there are columns like:
APEX_ITEM.HIDDEN(1,coursestudent.id)
...
APEX_ITEM.SELECT_LIST(2,coursestudent.signed,'Signed;1,Failed;0')
I have a submit button, and here is my process:
FOR i in 1..apex_application.g_f01.count LOOP
UPDATE coursestudent
SET signed=apex_application.g_f02(i)
WHERE id=apex_application.g_f01(i);
END LOOP;
I've thought that it's not too difficult, but after I press Submit nothing happens, except that the Success message is written out the page.
What should I do?
I'm using the Oracle Apex version: 5.1.1.00.08
Thanks to Jeffrey, I found the error: it is a bug.
I had to copy-paste the sql query again, and it works now. Ok, really, in that case I always put a select 1 from dual in it's place, save, and just after that paste back the query.
I've faced this bug before that, sometimes the new columns just don't showing in the page. Since I put the hidden column after I first create the query, it hadn't shown in the page, so the loop in the process never worked.

Linq equivalent of SQL LEFT function?

We have a database with some fields that are varchar(max) which could contain lots of text however I have a situation where I only want to select the first for example 300 characters from the field for a paginated table of results on a MVC web site for a "preview" of the field.
for a simplified example query where I want to get all locations to display in the table
(this would be paginated, so I don't just get everything - I get maybe 10 results at a time):
return db.locations;
However this gives me a location object with all the fields containing the massive amounts of text which is very time consuming to execute.
So what I resorted to before was using SQL stored procedures with the:
LEFT(field, 300)
to resolve this issue and then in the Linq to SQL .dbml file included the stored procedure to return a "location" object for the result.
However I have many queries and I don't want to have to do this for every query.
This maybe a simple solution, but I am not sure how I can phrase this on a search engine, I would appreciate anyone who can help me with this problem.
You can use functions that directly translate to those functions too, this is useful when you need to translate code that functionally works just fine in SQL at no risk in LINQ.
Have a look at System.Data.Objects.EntityFunctions
Locations.Select(loc=>System.Data.Objects.EntityFunctions.Left(loc.Field,300))
This will get directly translated into a LEFT on the server side.
EDIT: I misread LEFT for LTRIM. Here's all the String functions that can't be used in LINQ to SQL. Have you tried String.Substring()?
Your best option is to map the stored procedure and continue using it. Here is an excellent article with screen shots showing you how to do so.
If you're not using the designer tool you can also call ExecuteCommand against the DataContext. It isn't pretty, but it's what we have for now.
I found something like this worked for me:
return from locationPart in db.locations
select new LocationPart
{
Description = locationPart.description,
Text = locationPart.text.Substring(0,300)
};
Not ideal because I have to use "select new" to return a a different object, but it seems to work.

FileMaker Pro 10 - How to have cursor be in first field on new record?

When I start a new record in FileMaker is there a way for the cursor to automatically be in the first field so I can just start typing? And to specify which field that should be?
Background:
I'm trying to set up a FileMaker layout for use with a barcode scanner. So someone can scan in one record (there are two fields on the layout). After scanning it should go to a new record and place the cursor in the scan field so it's ready to scan again.
I put a trigger on the scan field to run a script to create a new record after hitting the enter key in the one field. After the new record statement I put a "go to field" statement but it doesn't seem to do anything. It always goes to the other field instead of the scan field.
Updates
I just tried using a "set selection" statement in the script instead of "go to field" (I also tried using both one after the other). Neither of those seemed to work.
I tried changing the tab order but it still goes to the other field instead of the scan field.
The default behavior when you create a new record is to go to the first field in the tab order, so this should work without you having to do anything.
The fact that it's not sounds to me like there might be a script trigger, either at the layout or field level, that's interfering with this or exiting the record. Try turning on the script debugger, create a new record, and see if a script runs.
I ended up doing a workaround.
I have just one field on the scan layout. After a user scans, a script fires which changes the layout to one which shows all the information about the scanned record that was just entered. It pauses for 1 second and then goes back to the scan layout for the next scan.
You may be able to set your scanner to submit pre and post data keystrokes. We routinely use this to invoke a filemaker script pre-scan to "go to field", enter the data, then post-scan to "perform a find"
I eventually devised a decent workaround with a second trigger script which seems to have no disadvantages.
However the tabs are set, I have found that an OnObjectExit trigger or an OnObjectSave trigger set up on the scan field will perform a script to process the scanned data, but the the step to return the cursor to the scan field will NOT work, probably because that field is still active in some way.
Rather than banging my head against I brick wall, I decided to set up an OnObjectExit trigger on the field to which the cursor is always deflected. This fires off a script to clear the scan field and then return the cursor to the scan field, ready for the next scan. This way, the cursor DOES arrive back where I want it.
Perhaps rather inelegant, but it works fine!

Resources