@@ -424,6 +424,50 @@ func writeQuotedIdentifier(builder *strings.Builder, identifier string) {
424424	builder .WriteByte ('"' )
425425}
426426
427+ // writeTableRecordCollectionDecl writes the PL/SQL declarations needed to 
428+ // define a custom record type and a collection of that record type, 
429+ // based on the schema of the given table. 
430+ // 
431+ // Specifically, it generates: 
432+ //   - A RECORD type (`t_record`) with fields corresponding to the table's columns. 
433+ //   - A nested TABLE type (`t_records`) of `t_record`. 
434+ // 
435+ // The declarations are written into the provided strings.Builder in the 
436+ // correct PL/SQL syntax, so they can be used as part of a larger PL/SQL block. 
437+ // 
438+ // Example output: 
439+ // 
440+ //	TYPE t_record IS RECORD ( 
441+ //	  "id" "users"."id"%TYPE, 
442+ //	  "created_at" "users"."created_at"%TYPE, 
443+ //	  ... 
444+ //	); 
445+ //	TYPE t_records IS TABLE OF t_record; 
446+ // 
447+ // Parameters: 
448+ //   - plsqlBuilder: The builder to write the PL/SQL code into. 
449+ //   - dbNames: The slice containing the column names. 
450+ //   - table: The table name 
451+ func  writeTableRecordCollectionDecl (plsqlBuilder  * strings.Builder , dbNames  []string , table  string ) {
452+ 	// Declare a record where each element has the same structure as a row from the given table 
453+ 	plsqlBuilder .WriteString ("  TYPE t_record IS RECORD (\n " )
454+ 	for  i , field  :=  range  dbNames  {
455+ 		if  i  >  0  {
456+ 			plsqlBuilder .WriteString (",\n " )
457+ 		}
458+ 		plsqlBuilder .WriteString ("    " )
459+ 		writeQuotedIdentifier (plsqlBuilder , field )
460+ 		plsqlBuilder .WriteString (" " )
461+ 		writeQuotedIdentifier (plsqlBuilder , table )
462+ 		plsqlBuilder .WriteString ("." )
463+ 		writeQuotedIdentifier (plsqlBuilder , field )
464+ 		plsqlBuilder .WriteString ("%TYPE" )
465+ 	}
466+ 	plsqlBuilder .WriteString ("\n " )
467+ 	plsqlBuilder .WriteString ("  );\n " )
468+ 	plsqlBuilder .WriteString ("  TYPE t_records IS TABLE OF t_record;\n " )
469+ }
470+ 
427471// Helper function to check if a value represents NULL 
428472func  isNullValue (value  interface {}) bool  {
429473	if  value  ==  nil  {
0 commit comments