HMG.EASY.SQL.2025.09.04

HMG Samples and Enhancements

Moderator: Rathinagiri

Post Reply
User avatar
Roberto Lopez
HMG Founder
Posts: 4022
Joined: Wed Jul 30, 2008 6:43 pm

HMG.EASY.SQL.2025.09.04

Post by Roberto Lopez »

Hi All,

Changelog:

- New: Report(cQuery,cTitle,aHeaders,aWidths,aJustify,cPdfName,lPreview,aFormats) method.
Creates a PDF report from a MySql Query.
Returns: .T. if it was successful (.F. otherwise).

For PDF generation it uses a slightly modified version of the original HMG_HPDF by
Rathinagiri. I've renamed the source file and internal functions to avoid conflicts
with any other version of it.

Example:

Code: Select all

	cCommand := 'SELECT code,description,location,stock,price FROM hmgtest ORDER BY code'
	cTitle	 := 'STOCK REPORT'
	aHeaders := { 'CODE', 'DESCRIPTION', 'LOCATION', 'STOCK', 'PRICE' }
	aWidths	 := { 6,32,32,6,12 }
	aJustify := { 'C','L', 'L','R','R'}
	cPdfName := 'stock' + '.' + dtos(date()) + '_' + alltrim(str(int(seconds())))
	lPreview := .t.
	aFormats := { {|x| STRZERO(x,4)},{|x|UPPER(x)},{|x|UPPER(x)},NIL,{|x|TRANSFORM(x,'999,999.99')} }

	IF !:Report(cCommand,cTitle,aHeaders,aWidths,aJustify,cPdfName,lPreview,aFormats)
		RETURN
	ENDIF

- New: Export(cQuery,cOutFile,aFormats,cDelimiter,lQuote) method.
Creates a CSV file from a MySql Query.
Returns: .T. if it was successful (.F. otherwise).

Example:

Code: Select all

		cQuery   := 'SELECT * FROM hmgtest ORDER BY code'
		cOutFile := 'hmgtest.csv'
		
		* aFormats (optional)

		aFormats := { {|x| STRZERO(x, 4)},{|x| STRZERO(x, 4)}, {|x| UPPER(x) },NIL,NIL,{|x| TRANSFORM(x,'999,999.99') } }

		* cDelimiter is optional (default is ';')

		cDelimiter := NIL

		* Quote is optional (default is .F.)

		lQuote := NIL
		
		IF !:Export(cQuery,cOutFile,aFormats,cDelimiter,lQuote)
			RETURN
		ENDIF

I hope this be useful for someone.
Attachments
hmg.easy.sql.2025.09.04.zip
(1.91 MiB) Downloaded 36 times
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Steed
Posts: 438
Joined: Sat Dec 12, 2009 3:40 pm

Re: HMG.EASY.SQL.2025.09.04

Post by Steed »

Thanks a a lot!,

Sorry to ask: but when i compilied the test , i have the next error

hbmk2: Error: Referenced, missing, but unknown function(s): SDDMY()

I'm using HMG 3.6.1

*********************************************
Copyright (c) 1999-2023, https://harbour.github.io/
C:/Ins/hmg/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Ins/hmg/lib-64\libhmg-64.a(h_HMG_HPDF.o):h_HMG_HPDF.c:(.text+0xe0): multiple definition of `HB_FUN_HMG_HPDF_PAGECOUNT'; C:/Users/st_ed/AppData/Local/Temp/hbmk_vdwn32.dir/main.o:main.c:(.text+0x4e0): first defined here
C:/Ins/hmg/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Ins/hmg/lib-64\libhmg-64.a(h_HMG_HPDF.o):h_HMG_HPDF.c:(.text+0x100): multiple definition of `HB_FUN_HMG_HPDF_PAGENO'; C:/Users/st_ed/AppData/Local/Temp/hbmk_vdwn32.dir/main.o:main.c:(.text+0x500): first defined here
C:/Ins/hmg/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/st_ed/AppData/Local/Temp/hbmk_vdwn32.dir/main.o:main.c:(.data+0x2330): undefined reference to `HB_FUN_SDDMY'
collect2.exe: error: ld returned 1 exit status
hbmk2[test]: Error: Running linker. 1

**************************************************************************
User avatar
Steed
Posts: 438
Joined: Sat Dec 12, 2009 3:40 pm

Re: HMG.EASY.SQL.2025.09.04

Post by Steed »

Steed wrote: Sat Oct 04, 2025 1:48 am Thanks a a lot!,

Sorry to ask: but when i compilied the test , i have the next error

hbmk2: Error: Referenced, missing, but unknown function(s): SDDMY()

I'm using HMG 3.6.1

**************************************************************************
Finally add in the test.hbc file the next libraries

libs=libmysql
libs=hbsqldd
libs=sddmy

It´ts compile , but know I had this new error.
TestError.png
TestError.png (9.77 KiB) Viewed 389 times
Regards,

ES
Post Reply