Posts by Confundir • 1,144 points
42 posts
-
1
votes2
answers133
viewsA: COMMIT inside a CURSOR
Using the concept of collections it is possible to open the cursor and limit the amount of Fetch records if it is used within a loop, so it is possible to commit with a maximum amount of records for…
-
5
votes2
answers1154
viewsA: What type of variable allocates less memory, integer or string?
In Delphi there are several integer types, each occupying a given amount of memory and with a given range of possible values. In your example could use a WORD type, which would occupy only 16bits of…
-
0
votes2
answers1444
viewsA: Convert Integer to Decimal in Oracle
If your application already has treatment based on oracle types, it is possible to type cast the desired field using the function CAST select Cast(nvl(sum(ve.vl_vencimento),0) as DECIMAL(10,2))…
-
1
votes2
answers1201
viewsA: Display a message on command output
As the message is related to an error, it is possible to use the method Raise_application_error, that will interrupt the execution of the PLSQL procedure and will raise an exception for the…
-
0
votes1
answer721
viewsA: Procedure in Package receiving an array (coming from a cursor/function) as input parameter - Oracle
It is possible to create a function with the Type return of your collection, in the procedure you want to receive this collection you need to pass the same type parameter (If you need to handle the…
-
3
votes1
answer90
viewsA: Checklistbox - how to pass a checklisbox to a function in Delphi
Like any Delphi parameter, you need to declare your type. All Delphi components are objects, so just pass the name of the class referring to the object along with the parameter. function…
-
1
votes1
answer62
viewsA: How to make an appointment to know the averages of people a day of a week
You can return the day of the week using the to_char function, formatting the date with the parameter’d', which returns the day of the week. Thus it is possible to group the query by the day of the…
-
0
votes1
answer125
viewsA: Daily count - PL/SQL
Analytical function can be used Lead, making it possible to access values of different Rows. Excerpt: select e.dt_entrada, decode(lead (dt_saida,1) over ( ORDER BY dt_entrada desc), e.dt_entrada,…
-
1
votes2
answers64
viewsA: Delphi Two methods for Onmessage
It is not possible, since the event properties are usually a Procedure of Object, which is basically a pointer to the method. You can create a third method that calls the first two and assign this…
-
0
votes1
answer274
viewsA: Field for numbering or ranking distinct records - Oracle
To make this grouped numbering, it is possible to use the analytical function row_number, this allows grouping and sorting of specific records, example: select ROW_NUMBER() OVER(partition by…
-
0
votes2
answers26
viewsA: failure in function snippet to read table
Yes, it is possible to do dml operations without problem inside given plsql block, the problem is in the syntax of your select, you used twice the into clause within the same query. Correct would be…
-
2
votes1
answer142
viewsA: How to detect current Left and Top of Form when dragging (in Delphi)?
The problem is in the method declaration. It expects a operating system message to fire it. Failed to declare which message he is waiting for, the correct statement would be: procedure…
-
0
votes1
answer173
viewsA: Use variable in a run
For DML commands and plsql blocks the immediate execute accepts parameters directly in the executed command. To set the value of the parameters the declaration is used using. declare vID integer;…
-
1
votes1
answer319
viewsA: Problems for invoking/inserting data with Procedure
The answer is in the error message, has insufficient parameters in the call, its function has 4 parameters and you are calling it with 3, missing to pass vOPR.
-
0
votes1
answer45
viewsA: select picking up the items that are in the current day and time
The problem is in the date format, the correct would be 'DD/MM/YY HH24:MI', you are passing MM twice, so he is waiting twice a month. Also remember, if you need to compare to the current date, just…
-
5
votes1
answer338
viewsA: How to run a trial only when the previous one is finished?
This problem happens because using the shell execute, this just calls the third application, but does not wait for the end of its conclusion. I see two solutions to your problem: 1) If you use a…
-
2
votes2
answers849
views -
1
votes1
answer628
viewsA: Break line automatically on export to Excel by Delphi
You can use the function Wraptext, setting the maximum number of characters per line you want and it will return the string with the required line breaks. Uses System.SysUtils; ...…
-
4
votes2
answers1687
viewsA: PL/SQL Anonymous block | PLS-00103: Encountered the Symbol "CREATE" when expecting one of the following:
It is not possible to perform operations ddl directly into a plsql block. The only way to execute this type of operation would be by using the resource immediate execution . Ex: begin Execute…
-
2
votes1
answer2766
viewsA: Error while running a Trigger
This is the famous case of mutant tables, which are basically triggers that try to query/modify the same table that fires the Trigger, is a standard behavior of oracle. To solve your problem you…
-
3
votes1
answer483
viewsA: Taking the name of the Standard Printer
There is a procedure in the Set of the Printerindex property, when you pass the value -1 it will always return the default windows printer. Ex: if Printer.Printers.Count > 0 then begin…
-
2
votes1
answer111
viewsA: How to capture windows status (suspended/hibernating) via Delphi code
Based on @Guilherme-nascimento’s comment and this article by microsoft I was able to mount an example using the message WM_POWERBROADCAST , which is triggered when windows enters and suspension. The…
-
0
votes1
answer996
viewsA: Add and split columns to oracle
If you want to return the result directly in the sql query the syntax would be as follows: select (COLUNA1-COLUNA2-COLUNA3)/COLUNA4 AS Resultado from SUATABELA If necessary perform the operation in…
-
2
votes1
answer70
viewsA: ORACLE USERS
Yes, it is possible! It is necessary to grant(GRANT) the appropriate permissions for the USER/ROLE. To create the specific permission for table would be using the following command: GRANT SELECT,…
-
0
votes2
answers165
viewsA: Search full month ORACLE
A simpler option would be to use the add_mouths function, which passing a negative value subtracts months from the date, ex: ... where cliente.dtultcomp > add_months(sysdate, -1)…
-
3
votes1
answer201
viewsA: Substitution of Oracle character
Some quotes were missing in the parameters of replace, it is interpreting as having 4 parameters, the last two being '', the correct syntax would be: SELECT…
-
2
votes1
answer1219
viewsA: I need explanations of OUT mode and INOUT PL/SQL and Mysql Procedure
In accordance with the oracle documentation the out parameters behave as an uninitialized variable, so regardless of the value you pass in the parameter, the method will receive a null value as…
-
5
votes2
answers1727
viewsA: Oracle-Variable without data
In a "into" condition you must return only one record. If return several will give the exception ORA-01422, and if return no will give the exception you quoted. If you have a default value, for your…
-
1
votes2
answers865
viewsA: Select to know customers without service in the last 30 days plsql
If the accuracy is per month you can use the function Add_mouth, passing a negative value by removing months from the date, ex: select * from SuaTabela where SuaColuna < add_months(sysdate, -1)…
-
7
votes1
answer153
viewsA: Delphi 10.1, Function that only accepts an integer interval in the variable
You can create a type using an integer range, e.g.: Type TAteQuatro = 1..4; procedure Teste(valor: TAteQuatro); begin Writeln(valor); end; begin Teste(4); //Compila Teste(5); //[dcc32 Error]…
-
1
votes1
answer339
viewsA: Oracle - DBMS_APPLICATION_INFO.set_client_info - What is and when to use
The function set_client_info adds the information in the Client_info field of the view V$SESSION, according to the oracle documentation this field is to describe the application that is connected.…
-
2
votes1
answer109
viewsA: Get Constraint and drop name next
Just perform your query and make an "alter table drop Constraint", ex: create or replace procedure DropConstraint(aTabela varchar2, aCONSTRAINT_TYPE varchar2, aCOLUMN_NAME varchar2) is cursor…
-
0
votes2
answers639
viewsA: Zipping files with the same name inside a folder
You can use the class System.zip.Tzipfile from Delphi itself to do this implementation by looping the files with the same name (with different extensions) and adding them to the zip as per the rule…
-
1
votes1
answer60
viewsA: Reset sequence every year
In versions less than 12 you need to set the increment property with the current value only negative and call nextval to reset the current and return the increment to the pattern you use, thus…
-
1
votes1
answer436
viewsA: PLSQL shows error: PLS-00487: Invalid reference to Variabel
As mentioned in the comments, since a restructuring of the way of work is not possible, I will propose two solutions, one simpler and less dynamic and another dynamic, but that will be very boring…
-
8
votes1
answer9144
viewsA: UPDATE WITH CASE SQL
You have a syntax error in your Update, you should use only one case and each condition within a when block update produto2 set valor = case when categoria = 'A' then valor * (valor * 5 / 100) when…
-
1
votes1
answer607
viewsA: Generate . exe from my Program
As we talked in the comments, I am passing how I use the library Dcpcrypt for encrypt/decrypt files. This can be used as a component in Delphi, it is free and open source. Encrypt/decrypt file: uses…
-
1
votes1
answer1184
viewsA: PLSQL resume error while retrieving data from Database
This error happens because your query returns more than one record, and the record only supports 1. To return several you need to work with collections, making a table of record and filling with the…
-
3
votes1
answer527
viewsA: How to obtain hierarchy structure of a Delphi component?
It is possible to return this hierarchy using the Parent of the component, making a recursive loop until it reaches the Form. Ex, a button, inside a panel in a form: uses…
-
1
votes1
answer540
viewsA: How to select XML and return a specific column from an anonymous block?
It is possible to use the method Xmltable, where it is possible to map the xml and return it in an SQL query. Example: declare -- Local variables here vXML XMLType; cursor consulta is SELECT * FROM…
-
1
votes2
answers770
viewsA: Check subprocess in implementation
It is possible to search using the functions Process32first/Process32next windows, looping existing processes to search for the executable name for example. For your case you could initially do a…
-
0
votes1
answer688
viewsA: Query the webservice and populated a grid with the data
For this purpose I use the library Delphi-Rest-client-api, with it it is possible to load a JSON to a dataset. Follow the example of the creator: var vDataSet: TClientDataSet; begin vDataSet :=…